Skip to content

Commit

Permalink
v4.3.2
Browse files Browse the repository at this point in the history
- (Fix) "Index was outside the bounds of the array" when detecting issues (Fixes #869)
  • Loading branch information
sn4k3 committed Apr 19, 2024
1 parent 430f376 commit 2cf889e
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 35 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# Changelog

## 19/04/2024 - v4.3.2

- (Fix) "Index was outside the bounds of the array" when detecting issues (Fixes #869)

## 19/04/2024 - v4.3.1

- **Tool - Change resolution:**
- (Add) 12K resolution profile
- (Improvement) Do not mark the option "Resize layers with the proposed ratio" when a machine preset results in the same pixel size / ratio of (1.0x, 1.0x)
- (Fix) Wait time before cure suggestion for GOO and PRZ file formats, it now allows the use of the create first empty layer (#864)
- **Thumbnail sanitizer:**
- (Add) Check if the thumbnails have the correct number of channels, if not it will throw an error
- (Improvement) When full encode a file, strip all extra thumbnails that are not used by the file format if they are not an archive
Expand All @@ -14,7 +17,7 @@
- (Add) Tool - Light bleed compensation: Add "Dim subject" option to select from different subjects to dim, "Bridges" was added (#868)
- (Add) Settings - Notifications: Allow to define beeps sounds to play after ran long operations (#863)
- (Improvement) CTB, FDG, PHZ: Make possible to encode a thumbnail using 1 and 4 channels, this fixes the issue where the file format could encode invalid thumbnail data
- (Improvement) Add empty layer for Goo file format when running the wait time before cure suggestion
- (Fix) Wait time before cure suggestion for GOO and PRZ file formats, it now allows the use of the create first empty layer (#864)
- (Fix) Terminal: The run globals was lost from the previous version update
- (Upgrade) .NET from 6.0.28 to 6.0.29

Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<CommonPublishDir>$(MSBuildThisFileDirectory)publish</CommonPublishDir>

<UVtoolsVersion>4.3.1</UVtoolsVersion>
<UVtoolsVersion>4.3.2</UVtoolsVersion>
<AvaloniaVersion>11.0.7</AvaloniaVersion>
</PropertyGroup>

Expand Down
16 changes: 1 addition & 15 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,2 @@
- **Tool - Change resolution:**
- (Add) 12K resolution profile
- (Improvement) Do not mark the option "Resize layers with the proposed ratio" when a machine preset results in the same pixel size / ratio of (1.0x, 1.0x)
- (Fix) Wait time before cure suggestion for GOO and PRZ file formats, it now allows the use of the create first empty layer (#864)
- **Thumbnail sanitizer:**
- (Add) Check if the thumbnails have the correct number of channels, if not it will throw an error
- (Improvement) When full encode a file, strip all extra thumbnails that are not used by the file format if they are not an archive
- (Improvement) Resize all thumbnails to the same size as the original from file format even when there are more than file format requires, this fixes a problem when converting from zip that have many thumbnails but file format selects the larger and the smallest, leading to encode the wrong size
- (Improvement) Convert thumbnails to BGR and strip the alpha channel when required, this fixes the issue where format conversion from zip such as sl1 and vdt where corrupting the final file with invalid thumbnail rle
- (Add) Tool - Light bleed compensation: Add "Dim subject" option to select from different subjects to dim, "Bridges" was added (#868)
- (Add) Settings - Notifications: Allow to define beeps sounds to play after ran long operations (#863)
- (Improvement) CTB, FDG, PHZ: Make possible to encode a thumbnail using 1 and 4 channels, this fixes the issue where the file format could encode invalid thumbnail data
- (Improvement) Add empty layer for Goo file format when running the wait time before cure suggestion
- (Fix) Terminal: The run globals was lost from the previous version update
- (Upgrade) .NET from 6.0.28 to 6.0.29
- (Fix) "Index was outside the bounds of the array" when detecting issues (Fixes #869)

40 changes: 30 additions & 10 deletions UVtools.Core/Extensions/EmguExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,31 @@ public static UnmanagedMemoryStream GetUnmanagedMemoryStream(this Mat mat, FileA
/// <returns></returns>
public static Span2D<T> GetDataSpan2D<T>(this Mat mat) where T : struct
{
var step = mat.GetRealStep();
var step = mat.GetRealStep() / Marshal.SizeOf<T>();
unsafe
{
if (mat.IsContinuous) return new(mat.DataPointer.ToPointer(), mat.Height, step, 0);
return new(mat.DataPointer.ToPointer(), mat.Height, step, mat.Step / mat.DepthToByteCount() - step);
return new(mat.DataPointer.ToPointer(), mat.Height, step, mat.Step / Marshal.SizeOf<T>() - step);
}
}

/// <summary>
/// Gets the whole data span to read pixels, use this when possibly using ROI
/// </summary>
/// <returns></returns>
public static ReadOnlySpan2D<byte> GetDataByteReadOnlySpan2D(this Mat mat) => mat.GetDataSpan2D<byte>();

/// <summary>
/// Gets the whole data span to read pixels, use this when possibly using ROI
/// </summary>
/// <returns></returns>
public static ReadOnlySpan2D<T> GetDataReadOnlySpan2D<T>(this Mat mat) where T : struct
{
var step = mat.GetRealStep() / Marshal.SizeOf<T>();
unsafe
{
if (mat.IsContinuous) return new(mat.DataPointer.ToPointer(), mat.Height, step, 0);
return new(mat.DataPointer.ToPointer(), mat.Height, step, mat.Step / Marshal.SizeOf<T>() - step);
}
}

Expand Down Expand Up @@ -388,8 +408,8 @@ public static unsafe Span<T> GetColSpan<T>(this Mat mat, int x, int length = 0,

if (offset < 0)
throw new ArgumentOutOfRangeException(nameof(offset), offset, "Offset must be a positive value.");

int maxLength = mat.GetLength() / Marshal.SizeOf<T>() - offset;
var maxLength = mat.GetLength() / Marshal.SizeOf<T>() - offset;

if (maxLength < 0)
throw new ArgumentOutOfRangeException(nameof(offset), offset, "Offset value overflow this Mat size.");
Expand Down Expand Up @@ -558,24 +578,24 @@ public static byte DepthToByteCount(this Mat mat)
}

/// <summary>
/// Step return the original Mat step, if ROI step still from original matrix which lead to errors.
/// Return the original Mat step in bytes, if ROI step still from original matrix which lead to errors.
/// Use this to get the real step size
/// </summary>
/// <param name="mat"></param>
/// <returns></returns>
public static int GetRealStep(this Mat mat)
{
return mat.Width * mat.NumberOfChannels;
return mat.Width * mat.NumberOfChannels * mat.DepthToByteCount();
}

/// <summary>
/// Gets the total length of this <see cref="Mat"/>
/// Gets the total length in bytes of this <see cref="Mat"/>
/// </summary>
/// <param name="mat"></param>
/// <returns>The total length of this <see cref="Mat"/></returns>
public static int GetLength(this Mat mat)
{
return mat.Total.ToInt32() * mat.NumberOfChannels;
return mat.Total.ToInt32() * mat.NumberOfChannels * mat.DepthToByteCount();
}

/// <summary>
Expand Down Expand Up @@ -1435,7 +1455,7 @@ public static List<GreyLine> ScanLines(this Mat mat, bool vertically = false, by

if (vertically)
{
var span = mat.GetDataByteSpan2D();
var span = mat.GetDataByteReadOnlySpan2D();
for (x = 0; x < matSize.Width; x++)
{
line.StartX = x + offset.X;
Expand Down Expand Up @@ -1547,7 +1567,7 @@ public static List<GreyLine> ScanLines(this Mat mat, Func<byte, byte> greyFunc,

if (vertically)
{
var span = mat.GetDataByteSpan2D();
var span = mat.GetDataByteReadOnlySpan2D();
for (x = 0; x < matSize.Width; x++)
{
line.StartX = x + offset.X;
Expand Down
10 changes: 5 additions & 5 deletions UVtools.Core/Managers/IssueManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ void GenerateAirMap(IInputArray input, IInputOutputArray output, VectorOfVectorO
using (var image = layer.GetLayerMat(layerIndex == 0 ? SlicerFile.BoundingRectangle : Layer.GetBoundingRectangleUnion(SlicerFile[layerIndex - 1], layer)))
{
var sourceSpan = image.SourceMat.GetDataByteSpan2D();
var roiSpan = image.RoiMat.GetDataByteSpan2D();
var sourceSpan = image.SourceMat.GetDataByteReadOnlySpan2D();
var roiSpan = image.RoiMat.GetDataByteReadOnlySpan2D();
if (touchBoundConfig.Enabled)
{
Expand Down Expand Up @@ -368,7 +368,7 @@ void GenerateAirMap(IInputArray input, IInputOutputArray output, VectorOfVectorO
if (layerIndex > 0 && layer.PositionZ > firstLayer!.PositionZ) // No islands nor overhangs for layer 0 or on plate
{
MatRoi? previousImage = null;
Span2D<byte> previousSpan = null;
ReadOnlySpan2D<byte> previousSpan = null;
Mat? overhangImage = null;
var previousLayer = SlicerFile[layerIndex - 1];
Expand Down Expand Up @@ -494,7 +494,7 @@ void GenerateAirMap(IInputArray input, IInputOutputArray output, VectorOfVectorO
if (previousSpan == null)
{
previousSpan = previousImage.RoiMat.GetDataByteSpan2D();
previousSpan = previousImage.RoiMat.GetDataByteReadOnlySpan2D();
}
List<Point> points = new();
Expand Down Expand Up @@ -559,7 +559,7 @@ void GenerateAirMap(IInputArray input, IInputOutputArray output, VectorOfVectorO
using var subtractedImage = islandOverhangMat.Roi(wasNull ? Rectangle.Empty : rect, EmptyRoiBehaviour.CaptureSource);
var subtractedSpan = subtractedImage.GetDataByteSpan2D();
var subtractedSpan = subtractedImage.GetDataByteReadOnlySpan2D();
var subtractedStep = subtractedImage.GetRealStep();
int overhangPixels = 0;
Expand Down
16 changes: 14 additions & 2 deletions documentation/UVtools.Core.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2cf889e

Please sign in to comment.