Skip to content

Commit

Permalink
v0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sn4k3 committed Apr 30, 2020
1 parent 788f12c commit ed77f86
Show file tree
Hide file tree
Showing 18 changed files with 1,882 additions and 1,057 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 30/04/2020 - v0.3.1 - Beta

* (Add) Thumbnails to converted photon and cbddlp files
* (Add) ctb file format
* (Add) Show possible extensions/files under "Convert To" menu
* (Add) Open new file in a new window without lose current work
* (Improvement) Rename and complete some Chitubox properties
* (Improvement) More completion of cbddlp file
* (Improvement) Optimized layer read from cbddlp file
* (Improvement) Add layer hash code to encoded Chitubox layers in order to optimize file size in case of repeated layer images
* (Improvement) GUI thumbnail preview now auto scale splitter height to a max of 400px when change thumbnail
* (Improvement) After convertion program prompt for open the result file in a new window
* (Change) Move layer rotate from view menu to layer menu
* (Change) Cbbdlp convertion name to Chitubox
* (Change) On covert, thumbnails now are resized to match exactly the target thumbnail size
* (Change) GUI will now show thumbnails from smaller to larger
* (Fixed) RetractFeedrate was incorrectly used instead of LiftFeedrate on Zcodex gcode

## 27/04/2020 - v0.3.0 - Beta

* (Add) zcodex file format
Expand Down
5 changes: 5 additions & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
* For information about cbddlp file format
* https://github.com/Photonsters

### Cliff L. Biffle
* Catibo: read/write/analyze CTB, CBDDLP, and PHZ files
* For information about cbddlp and cbt file format
* https://github.com/cbiffle/catibo

### Jason S. McMullan (ezrec)

* For ideas and permission to use his project (uv3dp)
Expand Down
797 changes: 0 additions & 797 deletions PrusaSL1Reader/CbddlpFile.cs

This file was deleted.

1,413 changes: 1,413 additions & 0 deletions PrusaSL1Reader/ChituboxFile.cs

Large diffs are not rendered by default.

95 changes: 79 additions & 16 deletions PrusaSL1Reader/FileFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
* of this license document, but changing it is not allowed.
*/
using System;
using System.Dynamic;
using System.Drawing;
using System.IO;
using System.Linq;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;

namespace PrusaSL1Reader
{
Expand All @@ -30,6 +31,15 @@ public enum FileFormatType : byte
Archive,
Binary
}

/// <summary>
/// Enumeration of file thumbnail size types
/// </summary>
public enum FileThumbnailSize : byte
{
Small = 0,
Large
}
#endregion

#region Sub Classes
Expand All @@ -48,9 +58,9 @@ public class PrintParameterModifier
public static PrintParameterModifier LayerOffTime { get; } = new PrintParameterModifier("Layer Off Time", @"Modify 'Layer Off Time' seconds", "s");
public static PrintParameterModifier BottomLiftHeight { get; } = new PrintParameterModifier("Bottom Lift Height", @"Modify 'Bottom Lift Height' millimeters between bottom layers", "mm");
public static PrintParameterModifier BottomLiftSpeed { get; } = new PrintParameterModifier("Bottom Lift Speed", @"Modify 'Bottom Lift Speed' mm/min between bottom layers", "mm/min");
public static PrintParameterModifier ZRetractHeight { get; } = new PrintParameterModifier("Z Retract Height", @"Modify 'Z Retract Height' millimeters between layers", "mm");
public static PrintParameterModifier ZRetractSpeed { get; } = new PrintParameterModifier("Z Retract Speed", @"Modify 'Z Retract Speed' mm/min between layers", "mm/min", 10, 5000);
public static PrintParameterModifier ZDetractSpeed { get; } = new PrintParameterModifier("Z Detract Speed", @"Modify 'Z Detract Speed' mm/min between layers", "mm/min", 10, 5000);
public static PrintParameterModifier LiftHeight { get; } = new PrintParameterModifier("Lift Height", @"Modify 'Lift Height' millimeters between layers", "mm");
public static PrintParameterModifier LiftSpeed { get; } = new PrintParameterModifier("Lift Speed", @"Modify 'Lift Speed' mm/min between layers", "mm/min", 10, 5000);
public static PrintParameterModifier RetractSpeed { get; } = new PrintParameterModifier("Retract Speed", @"Modify 'Retract Speed' mm/min between layers", "mm/min", 10, 5000);

public static PrintParameterModifier BottomLightPWM { get; } = new PrintParameterModifier("Bottom Light PWM", @"Modify 'Bottom Light PWM' value", null, 50, byte.MaxValue);
public static PrintParameterModifier LightPWM { get; } = new PrintParameterModifier("Light PWM", @"Modify 'Light PWM' value", null, 50, byte.MaxValue);
Expand Down Expand Up @@ -116,7 +126,7 @@ public override string ToString()
public static FileFormat[] AvaliableFormats { get; } =
{
new SL1File(), // Prusa SL1
new CbddlpFile(), // cbddlp, photon
new ChituboxFile(), // cbddlp, cbt, photon
new ZCodexFile(), // zcodex
};

Expand Down Expand Up @@ -203,7 +213,7 @@ public string FileFilterExtensionsOnly
}
}

public abstract string FileFullPath { get; set; }
public string FileFullPath { get; set; }

public abstract byte ThumbnailsCount { get; }

Expand All @@ -223,7 +233,9 @@ public byte CreatedThumbnailsCount {
}
}

public abstract Image<Rgba32>[] Thumbnails { get; set; }
public abstract Size[] ThumbnailsOriginalSize { get; }

public Image<Rgba32>[] Thumbnails { get; set; }

public abstract uint ResolutionX { get; }

Expand All @@ -241,11 +253,11 @@ public byte CreatedThumbnailsCount {

public abstract float LayerExposureTime { get; }

public abstract float ZRetractHeight { get; }
public abstract float LiftHeight { get; }

public abstract float ZRetractSpeed { get; }
public abstract float RetractSpeed { get; }

public abstract float ZDetractSpeed { get; }
public abstract float LiftSpeed { get; }

public abstract float PrintTime { get; }

Expand Down Expand Up @@ -328,12 +340,62 @@ public bool IsExtensionValid(string extension, bool isFilePath = false)
return FileExtensions.Any(fileExtension => fileExtension.Extension.Equals(extension));
}

public string GetFileExtensions(string prepend = ".", string separator = ", ")
{
var result = string.Empty;

foreach (var fileExt in FileExtensions)
{
if (!ReferenceEquals(result, string.Empty))
{
result += separator;
}
result += $"{prepend}{fileExt.Extension}";
}

return result;
}

public Image<Rgba32> GetThumbnail(uint maxHeight = 400)
{
for (int i = 0; i < ThumbnailsCount; i++)
{
if(ReferenceEquals(Thumbnails[i], null)) continue;
if (Thumbnails[i].Height <= maxHeight) return Thumbnails[i];
}

return null;
}

public void SetThumbnails(Image<Rgba32>[] images)
{
for (var i = 0; i < ThumbnailsCount; i++)
{
Thumbnails[i] = images[Math.Min(i, images.Length - 1)].Clone();
}
}

public void SetThumbnails(Image<Rgba32> image)
{
for (var i = 0; i < ThumbnailsCount; i++)
{
Thumbnails[i] = image.Clone();
}
}

public virtual void BeginEncode(string fileFullPath)
{
if (File.Exists(fileFullPath))
{
File.Delete(fileFullPath);
}

for (var i = 0; i < Thumbnails.Length; i++)
{
if(ReferenceEquals(Thumbnails[i], null)) continue;

Thumbnails[i].Mutate(x => x.Resize(ThumbnailsOriginalSize[i].Width, ThumbnailsOriginalSize[i].Height));
}
}

public abstract void InsertLayerImageEncode(Image<Gray8> image, uint layerIndex);
Expand Down Expand Up @@ -421,12 +483,13 @@ public virtual object GetValueFromPrintParameterModifier(PrintParameterModifier
if (ReferenceEquals(modifier, PrintParameterModifier.ExposureSeconds))
return LayerExposureTime;

if (ReferenceEquals(modifier, PrintParameterModifier.ZRetractHeight))
return ZRetractHeight;
if (ReferenceEquals(modifier, PrintParameterModifier.ZRetractSpeed))
return ZRetractSpeed;
if (ReferenceEquals(modifier, PrintParameterModifier.ZDetractSpeed))
return ZDetractSpeed;
if (ReferenceEquals(modifier, PrintParameterModifier.LiftHeight))
return LiftHeight;
if (ReferenceEquals(modifier, PrintParameterModifier.LiftSpeed))
return LiftSpeed;
if (ReferenceEquals(modifier, PrintParameterModifier.RetractSpeed))
return RetractSpeed;



return null;
Expand Down
8 changes: 8 additions & 0 deletions PrusaSL1Reader/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* of this license document, but changing it is not allowed.
*/

using System;
using System.IO;
using System.Security.Cryptography;
using BinarySerialization;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.PixelFormats;
Expand Down Expand Up @@ -86,5 +88,11 @@ public static uint SerializeWriteFileStream(FileStream fs, object value, uint of
return WriteFileStream(fs, stream);
}
}

public static SHA1CryptoServiceProvider SHA1 { get; } = new SHA1CryptoServiceProvider();
public static string ComputeSHA1Hash(byte[] input)
{
return Convert.ToBase64String(SHA1.ComputeHash(input));
}
}
}
43 changes: 37 additions & 6 deletions PrusaSL1Reader/IFileFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

using System;
using System.Drawing;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;

Expand Down Expand Up @@ -58,6 +59,11 @@ public interface IFileFormat
/// Gets the number of created thumbnails
/// </summary>
byte CreatedThumbnailsCount { get; }

/// <summary>
/// Gets the original thumbnail sizes
/// </summary>
Size[] ThumbnailsOriginalSize { get; }

/// <summary>
/// Gets the thumbnails for this <see cref="FileFormat"/>
Expand Down Expand Up @@ -105,19 +111,19 @@ public interface IFileFormat
float LayerExposureTime { get; }

/// <summary>
/// Gets the height in mm to retract between layers
/// Gets the speed in mm/min for the detracts
/// </summary>
float ZRetractHeight { get; }
float LiftSpeed { get; }

/// <summary>
/// Gets the speed in mm/min for the retracts
/// Gets the height in mm to retract between layers
/// </summary>
float ZRetractSpeed { get; }
float LiftHeight { get; }

/// <summary>
/// Gets the speed in mm/min for the detracts
/// Gets the speed in mm/min for the retracts
/// </summary>
float ZDetractSpeed { get; }
float RetractSpeed { get; }

/// <summary>
/// Gets the estimate print time in seconds
Expand Down Expand Up @@ -181,6 +187,31 @@ public interface IFileFormat
/// <returns>True if valid, otherwise false</returns>
bool IsExtensionValid(string extension, bool isFilePath = false);

/// <summary>
/// Gets all valid file extensions in a specified format
/// </summary>

string GetFileExtensions(string prepend = ".", string separator = ", ");

/// <summary>
/// Gets a thumbnail by it height or lower
/// </summary>
/// <param name="maxHeight">Max height allowed</param>
/// <returns></returns>
Image<Rgba32> GetThumbnail(uint maxHeight = 400);

/// <summary>
/// Sets thumbnails from a list of thumbnails and clone them
/// </summary>
/// <param name="images"></param>
void SetThumbnails(Image<Rgba32>[] images);

/// <summary>
/// Sets all thumbnails the same image
/// </summary>
/// <param name="images">Image to set</param>
void SetThumbnails(Image<Rgba32> images);

/// <summary>
/// Begin encode to an output file
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions PrusaSL1Reader/PrusaSL1Reader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<PackageProjectUrl>https://github.com/sn4k3/PrusaSL1Viewer</PackageProjectUrl>
<PackageIcon></PackageIcon>
<RepositoryUrl>https://github.com/sn4k3/PrusaSL1Viewer</RepositoryUrl>
<AssemblyVersion>0.3.0.0</AssemblyVersion>
<FileVersion>0.3.0.0</FileVersion>
<Version>0.3.0</Version>
<AssemblyVersion>0.3.1.0</AssemblyVersion>
<FileVersion>0.3.1.0</FileVersion>
<Version>0.3.1</Version>
<Description>Open, view, edit, extract and convert DLP/SLA files generated from Slicers</Description>
</PropertyGroup>

Expand Down
Loading

0 comments on commit ed77f86

Please sign in to comment.