Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sn4k3/UVtools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Conceição <Tiago_caza@hotmail.com>2021-08-13 01:19:47 +0300
committerTiago Conceição <Tiago_caza@hotmail.com>2021-08-13 01:19:47 +0300
commit80a9adbcd0d80a62eec3f2714ee902af6fb562f1 (patch)
tree54e5d6b0eb55a963a24ee743fd1c5406349d3c62 /UVtools.Core/FileFormats/PhotonSFile.cs
parentb8e05db1133b98ae3c023318b963962834c842eb (diff)
v2.18.0v2.18.0
- **Command line arguments:** - (Add) Convert files: UVtools.exe -c \<inputfile\> \<outputfile1/ext1\> [outputfile2/ext2] - (Add) Extract files: UVtools.exe -e \<inputfile\> [output_folder] - https://github.com/sn4k3/UVtools#command-line-arguments - **File formats:** - (Add) Implement TSMC (Two Stage Motor Control) for the supported formats - (Add) Implement 'Bottom retract speed' for the supported formats - (Add) LGS: Support for lgs120 and lg4k (#218) - (Add) CTB: Special/virtual file extensions .v2.ctb, .v3.ctb, .v4.ctb to force a convertion to the set version (2 to 4). The .ctb is Version 3 by default when creating/converting files - (Improvement) Better performance for file formats that decode images in sequential pixels groups - **GCode:** - (Improvement) Better parsing of the movements / lifts - (Improvement) Better handling of lifts performed after cure the layer - (Improvement) More fail-safe checks and sanitize of gcode while parsing - (Improvement) CTBv3: Enable per layer settings if disabled when fast save without reencode - (Upgrade) .NET from 5.0.8 to 5.0.9 - (Fix) PrusaSlicer printer: Longer Orange 4k with correct resolution and display size - (Fix) Odd error when changing properties too fast in multi-thread
Diffstat (limited to 'UVtools.Core/FileFormats/PhotonSFile.cs')
-rw-r--r--UVtools.Core/FileFormats/PhotonSFile.cs44
1 files changed, 27 insertions, 17 deletions
diff --git a/UVtools.Core/FileFormats/PhotonSFile.cs b/UVtools.Core/FileFormats/PhotonSFile.cs
index 21436be..429cdf2 100644
--- a/UVtools.Core/FileFormats/PhotonSFile.cs
+++ b/UVtools.Core/FileFormats/PhotonSFile.cs
@@ -165,44 +165,52 @@ namespace UVtools.Core.FileFormats
public unsafe Mat Decode(bool consumeRle = true)
{
var mat = EmguExtensions.InitMat(new Size((int) ResolutionX, (int) ResolutionY));
- var matSpan = mat.GetBytePointer();
+ //var matSpan = mat.GetBytePointer();
var imageLength = mat.GetLength();
- uint pixel = 0;
+ int pixelPos = 0;
foreach (var run in EncodedRle)
{
+ if (pixelPos > imageLength)
+ {
+ mat.Dispose();
+ throw new FileLoadException($"Error image ran off the end, expecting {imageLength} pixels.");
+ }
+
byte brightness = (byte) ((run & 0x01) * 255);
- uint numPixelsInRun =
- (uint) ((((run & 128) > 0 ? 1 : 0) |
- ((run & 64) > 0 ? 2 : 0) |
- ((run & 32) > 0 ? 4 : 0) |
- ((run & 16) > 0 ? 8 : 0) |
- ((run & 8) > 0 ? 16 : 0) |
- ((run & 4) > 0 ? 32 : 0) |
- ((run & 2) > 0 ? 64 : 0)) + 1);
+ int numPixelsInRun =
+ (((run & 128) > 0 ? 1 : 0) |
+ ((run & 64) > 0 ? 2 : 0) |
+ ((run & 32) > 0 ? 4 : 0) |
+ ((run & 16) > 0 ? 8 : 0) |
+ ((run & 8) > 0 ? 16 : 0) |
+ ((run & 4) > 0 ? 32 : 0) |
+ ((run & 2) > 0 ? 64 : 0)) + 1;
- if (brightness == 0) // Don't fill black pixels
+ mat.FillSpan(ref pixelPos, numPixelsInRun, brightness);
+
+ /*if (brightness == 0) // Don't fill black pixels
{
- pixel += numPixelsInRun;
+ pixelPos += numPixelsInRun;
continue;
}
for (; numPixelsInRun > 0; numPixelsInRun--)
{
- if (pixel > imageLength)
+ if (pixelPos > imageLength)
{
mat.Dispose();
throw new FileLoadException($"Error image ran off the end, expecting {imageLength} pixels.");
}
- matSpan[pixel++] = brightness;
- }
+ matSpan[pixelPos++] = brightness;
+ }*/
}
- if (pixel != imageLength && pixel-1 != imageLength)
+ if (pixelPos != imageLength && pixelPos-1 != imageLength)
{
mat.Dispose();
- throw new FileLoadException($"Error image ran shortly or off the end, expecting {imageLength} pixels, got {pixel} pixels.");
+ throw new FileLoadException($"Error image ran shortly or off the end, expecting {imageLength} pixels, got {pixelPos} pixels.");
}
// Not required as mat is all black by default
@@ -369,6 +377,8 @@ namespace UVtools.Core.FileFormats
set => base.LiftSpeed = (float) (HeaderSettings.LiftSpeed = Math.Round(value / 60.0, 2));
}
+ public override float BottomRetractSpeed => RetractSpeed;
+
public override float RetractSpeed
{
get => (float)Math.Round(HeaderSettings.RetractSpeed * 60.0, 2);