Skip to content

Commit

Permalink
v0.4
Browse files Browse the repository at this point in the history
* (Add) CWS file format
* (Add) Nova3D Elfin printer
* (Add) Zoom and pan functions to layer image
* (Add) Pixel editor to add or remove pixels
* (Add) Outline layer showing only borders
* (Add) Image mutators, Erode, Dilate, PyrDownUp, Smooth
* (Add) Task to save operation
* (Add) Printers can be installed from GUI Menu -> About -> Install printers into PrusaSlicer
* (Improvement) Layer Management
* (Improvement) Faster Save and Save As operation
* (Fix) Bad layer image when converting SL1 to PHZ
* (Fix) Corrected EncryptionMode for PHZ files
* (Fix) Save As can change file extension
* (Fix) Save As no longer reload file
* (Fix) SL1 files not accepting float numbers for exposures
* (Fix) SL1 files was calculating the wrong layer count when using slow layer settings
* (Fix) Modifiers can't accept float values
* (Fix) Sonic Mini prints mirroed
* (Fix) Layer resolution shows wrong values
  • Loading branch information
sn4k3 committed May 27, 2020
1 parent 1759fb0 commit 82f29a7
Show file tree
Hide file tree
Showing 35 changed files with 2,405 additions and 596 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## 27/05/2020 - v0.4 - Beta

* (Add) CWS file format
* (Add) Nova3D Elfin printer
* (Add) Zoom and pan functions to layer image
* (Add) Pixel editor to add or remove pixels
* (Add) Outline layer showing only borders
* (Add) Image mutators, Erode, Dilate, PyrDownUp, Smooth
* (Add) Task to save operation
* (Add) Printers can be installed from GUI Menu -> About -> Install printers into PrusaSlicer
* (Improvement) Layer Management
* (Improvement) Faster Save and Save As operation
* (Fix) Bad layer image when converting SL1 to PHZ
* (Fix) Corrected EncryptionMode for PHZ files
* (Fix) Save As can change file extension
* (Fix) Save As no longer reload file
* (Fix) SL1 files not accepting float numbers for exposures
* (Fix) SL1 files was calculating the wrong layer count when using slow layer settings
* (Fix) Modifiers can't accept float values
* (Fix) Sonic Mini prints mirroed
* (Fix) Layer resolution shows wrong values

## 21/05/2020 - v0.3.3.1 - Beta

* (Fix) Unable to convert Chitubox or PHZ files when enconter repeated layer images
Expand Down
19 changes: 19 additions & 0 deletions ImportPrinters.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@echo off
SET DIR=%~dp0
SET INPUT_DIR=%AppData%\PrusaSlicer\printer
SET OUTPUT_DIR=%~dp0PrusaSlicer\printer

SET files[0]=EPAX X1.ini
SET files[1]=Phrozen Sonic Mini.ini
SET files[2]=Zortrax Inkspire.ini
SET files[3]=Nova3D Elfin.ini

echo PrusaSlicer Printers Instalation
echo This will replace printers, all changes will be discarded
echo %INPUT_DIR%
echo %OUTPUT_DIR%

for /F "tokens=2 delims==" %%s in ('set files[') do xcopy /y "%INPUT_DIR%\%%s" "%OUTPUT_DIR%"

REM xcopy /i /e /y %INPUT_DIR% %OUTPUT_DIR%
pause
1 change: 1 addition & 0 deletions PrusaSL1Reader/About.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace PrusaSL1Reader
{
public static class About
{
public static string Software = "PrusaSL1Viewer";
public static string Author = "Tiago Conceição";
public static string Company = "PTRTECH";
public static string Website = "https://github.com/sn4k3/PrusaSL1Viewer";
Expand Down
444 changes: 444 additions & 0 deletions PrusaSL1Reader/CWSFile.cs

Large diffs are not rendered by default.

27 changes: 17 additions & 10 deletions PrusaSL1Reader/ChituboxFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ void rleRGB15()
{
Layer layer = new Layer();
Layer layerHash = null;
var image = GetLayerImage(layerIndex);
var image = this[layerIndex].Image;
rawData = IsCbtFile ? EncodeCbtImage(image, layerIndex) : EncodeCbddlpImage(image);

var byteArr = rawData.ToArray();
Expand Down Expand Up @@ -1014,15 +1014,11 @@ public override void Decode(string fileFullPath)
}
}

Layers = new byte[LayerCount][];
LayerManager = new LayerManager(LayerCount);

Parallel.For(0, LayerCount, layerIndex => {
var image = IsCbtFile ? DecodeCbtImage((uint) layerIndex) : DecodeCbddlpImage((uint) layerIndex);
using (var ms = new MemoryStream())
{
image.Save(ms, Helpers.PngEncoder);
Layers[layerIndex] = CompressLayer(ms.ToArray());
}
this[layerIndex] = new LayerManager.Layer((uint)layerIndex, image);
});

/*byte[,][] rleArr = new byte[LayerCount, HeaderSettings.AntiAliasLevel][];
Expand Down Expand Up @@ -1361,6 +1357,17 @@ void UpdateLayers()

public override void SaveAs(string filePath = null)
{
if (LayerManager.IsModified)
{
if (!string.IsNullOrEmpty(filePath))
{
FileFullPath = filePath;
}
Encode(FileFullPath);
return;
}


if (!string.IsNullOrEmpty(filePath))
{
File.Copy(FileFullPath, filePath, true);
Expand Down Expand Up @@ -1393,7 +1400,7 @@ public override void SaveAs(string filePath = null)
outputFile.Close();
}

Decode(FileFullPath);
//Decode(FileFullPath);
}

public override bool Convert(Type to, string fileFullPath)
Expand All @@ -1402,7 +1409,7 @@ public override bool Convert(Type to, string fileFullPath)
{
PHZFile file = new PHZFile
{
Layers = Layers
LayerManager = LayerManager
};


Expand Down Expand Up @@ -1513,7 +1520,7 @@ public override bool Convert(Type to, string fileFullPath)
}
},
},
Layers = Layers
LayerManager = LayerManager
};

float usedMaterial = UsedMaterial / LayerCount;
Expand Down
49 changes: 31 additions & 18 deletions PrusaSL1Reader/Extensions/ZipArchiveExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,41 +280,54 @@ public static void AddToArchive(string archiveFullName,
}

/// <summary>
/// Create a file into archive and write content to it
/// Get or put a file into archive
/// </summary>
/// <param name="input"><see cref="ZipArchive"/></param>
/// <param name="filename">Filename to create</param>
/// <returns>Created <see cref="ZipArchiveEntry"/></returns>
public static ZipArchiveEntry GetPutFile(this ZipArchive input, string filename)
{
return input.GetEntry(filename) ?? input.CreateEntry(filename);
}

/// <summary>
/// Create or update a file into archive and write content to it
/// </summary>
/// <param name="input"><see cref="ZipArchive"/></param>
/// <param name="filename">Filename to create</param>
/// <param name="content">Content to write</param>
/// <returns>Created <see cref="ZipArchiveEntry"/></returns>
public static ZipArchiveEntry PutFileContent(this ZipArchive input, string filename, string content, bool deleteFirst = true)
public static ZipArchiveEntry PutFileContent(this ZipArchive input, string filename, string content)
{
if(deleteFirst) input.GetEntry(filename)?.Delete();
ZipArchiveEntry entry = input.GetEntry(filename) ?? input.CreateEntry(filename);

var entry = input.CreateEntry(filename);
if (ReferenceEquals(content, null)) return entry;
using (TextWriter tw = new StreamWriter(entry.Open()))
if (string.IsNullOrEmpty(content)) return entry;
Stream stream = entry.Open();
stream.SetLength(0);
using (TextWriter tw = new StreamWriter(stream))
{
tw.Write(content);
tw.Close();
}

return entry;
}

public static ZipArchiveEntry PutFileContent(this ZipArchive input, string filename, Stream content, bool deleteFirst = true)
/// <summary>
/// Create or update a file into archive and write content to it
/// </summary>
/// <param name="input"><see cref="ZipArchive"/></param>
/// <param name="filename">Filename to create</param>
/// <param name="content">Content to write</param>
/// <returns>Created <see cref="ZipArchiveEntry"/></returns>
public static ZipArchiveEntry PutFileContent(this ZipArchive input, string filename, byte[] content)
{
if (deleteFirst) input.GetEntry(filename)?.Delete();
var entry = input.CreateEntry(filename);
if (ReferenceEquals(content, null)) return entry;
using (StreamWriter tw = new StreamWriter(entry.Open()))
{
tw.Write(content);
tw.Close();
}
ZipArchiveEntry entry = input.GetEntry(filename) ?? input.CreateEntry(filename);

if (ReferenceEquals(content, null)) return entry;
Stream stream = entry.Open();
stream.SetLength(0);
stream.Write(content, 0, content.Length);
return entry;
}


}
}
Loading

0 comments on commit 82f29a7

Please sign in to comment.