diff --git a/CHANGELOG.md b/CHANGELOG.md index 060ee864..22a3611e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - (Add) Title bar: Display the loaded file size and re-arrange the last operation run time to the right - (Improvement) Re-arrange some items on `File` and `Help` menu - (Improvement) Use icons instead UTF-8 character for buttons with drop-down menus + - (Fix) Benchmark tool: Allow to show percentages larger than 100% and increase progress height - **Tools:** - (Fix) Layer actions - Import layer(s): Unable to process image files (#815) - (Fix) PCB Exposure: Draw circles using ellipses in order to use non-square pixels (#822) diff --git a/UVtools.Core/Extensions/CompressionExtensions.cs b/UVtools.Core/Extensions/CompressionExtensions.cs index d94c2fd3..844c812b 100644 --- a/UVtools.Core/Extensions/CompressionExtensions.cs +++ b/UVtools.Core/Extensions/CompressionExtensions.cs @@ -32,7 +32,7 @@ public static int GetGzipUncompressedLength(Stream stream) return BitConverter.ToInt32(uncompressedLength); } - public static MemoryStream GZipCompress(Stream inputStream, CompressionLevel compressionLevel, bool leaveStreamOpen = false) + public static Stream GZipCompress(Stream inputStream, CompressionLevel compressionLevel, bool leaveStreamOpen = false) { if (inputStream.Position == inputStream.Length) inputStream.Seek(0, SeekOrigin.Begin); @@ -41,19 +41,20 @@ public static MemoryStream GZipCompress(Stream inputStream, CompressionLevel com { inputStream.CopyTo(gzipStream); } - if (!leaveStreamOpen) { inputStream.Close(); } + if (!leaveStreamOpen) inputStream.Close(); compressedStream.Seek(0, SeekOrigin.Begin); + return compressedStream; } - public static MemoryStream GZipCompress(byte[] inputStream, CompressionLevel compressionLevel) => + public static Stream GZipCompress(byte[] inputStream, CompressionLevel compressionLevel) => GZipCompress(new ReadOnlyMemory(inputStream).AsStream(), compressionLevel); public static byte[] GZipCompressToBytes(Stream inputStream, CompressionLevel compressionLevel) { - using var ms = GZipCompress(inputStream, compressionLevel); - return ms.ToArray(); + using var stream = GZipCompress(inputStream, compressionLevel); + return stream.ToArray(); } public static byte[] GZipCompressToBytes(byte[] inputStream, CompressionLevel compressionLevel) @@ -63,7 +64,7 @@ public static byte[] GZipCompressToBytes(byte[] inputStream, CompressionLevel co } - public static MemoryStream GZipDecompress(Stream compressedStream, bool leaveStreamOpen = false) + public static Stream GZipDecompress(Stream compressedStream, bool leaveStreamOpen = false) { if (compressedStream.Position == compressedStream.Length) { compressedStream.Seek(0, SeekOrigin.Begin); } @@ -87,7 +88,7 @@ public static ArraySegment GZipDecompress(ReadOnlyMemory compressedD : uncompressedStream.ToArray(); } - public static MemoryStream DeflateCompress(Stream inputStream, CompressionLevel compressionLevel, bool leaveStreamOpen = false) + public static Stream DeflateCompress(Stream inputStream, CompressionLevel compressionLevel, bool leaveStreamOpen = false) { if (inputStream.Position == inputStream.Length) { inputStream.Seek(0, SeekOrigin.Begin); } @@ -96,13 +97,13 @@ public static MemoryStream DeflateCompress(Stream inputStream, CompressionLevel { inputStream.CopyTo(gzipStream); } - if (!leaveStreamOpen) { inputStream.Close(); } + if (!leaveStreamOpen) inputStream.Close(); compressedStream.Seek(0, SeekOrigin.Begin); return compressedStream; } - public static MemoryStream DeflateCompress(byte[] inputStream, CompressionLevel compressionLevel) => + public static Stream DeflateCompress(byte[] inputStream, CompressionLevel compressionLevel) => DeflateCompress(new ReadOnlyMemory(inputStream).AsStream(), compressionLevel); public static byte[] DeflateCompressToBytes(Stream inputStream, CompressionLevel compressionLevel) @@ -117,7 +118,7 @@ public static byte[] DeflateCompressToBytes(byte[] inputStream, CompressionLevel return ms.ToArray(); } - public static MemoryStream DeflateDecompress(Stream compressedStream, bool leaveStreamOpen = false) + public static Stream DeflateDecompress(Stream compressedStream, bool leaveStreamOpen = false) { if (compressedStream.Position == compressedStream.Length) { compressedStream.Seek(0, SeekOrigin.Begin); } diff --git a/UVtools.Core/FileFormats/FileFormat.cs b/UVtools.Core/FileFormats/FileFormat.cs index 92250912..a1d1bf77 100644 --- a/UVtools.Core/FileFormats/FileFormat.cs +++ b/UVtools.Core/FileFormats/FileFormat.cs @@ -6035,7 +6035,7 @@ public Mat CreateMatWithDummyPixel(Point dummyPixelLocation, byte dummyPixelBrig public Mat CreateMatWithDummyPixel() => CreateMatWithDummyPixel(SupportGCode ? (byte)1 : (byte)128); /// - /// Creates a empty mat of file size + /// Creates an empty mat of file size /// /// True to black out the mat /// diff --git a/UVtools.Core/Layers/Layer.cs b/UVtools.Core/Layers/Layer.cs index ef61cfe3..186a94d0 100644 --- a/UVtools.Core/Layers/Layer.cs +++ b/UVtools.Core/Layers/Layer.cs @@ -928,12 +928,12 @@ public Mat LayerMat CvInvoke.Imdecode(_compressedBytes, ImreadModes.Grayscale, mat); break; case LayerCompressionCodec.Lz4: - mat = CreateMat(); + mat = CreateMat(false); LZ4Codec.Decode(_compressedBytes.AsSpan(), mat.GetDataByteSpan()); break; case LayerCompressionCodec.GZip: { - mat = CreateMat(); + mat = CreateMat(false); unsafe { fixed (byte* pBuffer = _compressedBytes) @@ -949,7 +949,7 @@ public Mat LayerMat } case LayerCompressionCodec.Deflate: { - mat = CreateMat(); + mat = CreateMat(false); unsafe { fixed (byte* pBuffer = _compressedBytes) @@ -1312,12 +1312,15 @@ public override string ToString() #region Methods /// - /// Creates an using this layer information + /// Creates an empty of file size /// + /// True to black out the mat /// - public Mat CreateMat() + public Mat CreateMat(bool initMat = true) { - return new Mat(Resolution, DepthType.Cv8U, 1); + return initMat + ? EmguExtensions.InitMat(Resolution) + : new Mat(Resolution, DepthType.Cv8U, 1); } /// @@ -2007,6 +2010,11 @@ public static byte[] CompressMat(Mat mat, LayerCompressionCodec codec) ArrayPool.Shared.Return(rent); return target; + + /*var span = mat.GetDataByteSpan(); + using var buffer = new PooledBufferWriter(); + LZ4Frame.Encode(span, buffer, LZ4Level.L00_FAST); + return buffer.WrittenMemory.ToArray();*/ } case LayerCompressionCodec.GZip: return CompressionExtensions.GZipCompressToBytes(mat.GetUnmanagedMemoryStream(FileAccess.Read), CompressionLevel.Fastest); diff --git a/UVtools.UI/MainWindow.Suggestions.cs b/UVtools.UI/MainWindow.Suggestions.cs index 02c5d38f..5c9bd235 100644 --- a/UVtools.UI/MainWindow.Suggestions.cs +++ b/UVtools.UI/MainWindow.Suggestions.cs @@ -6,7 +6,6 @@ * of this license document, but changing it is not allowed. */ -using Avalonia.Controls; using Avalonia.Threading; using System; using System.Collections.Generic; diff --git a/UVtools.UI/MainWindow.axaml.cs b/UVtools.UI/MainWindow.axaml.cs index 29aa8901..3d55cd88 100644 --- a/UVtools.UI/MainWindow.axaml.cs +++ b/UVtools.UI/MainWindow.axaml.cs @@ -1263,7 +1263,7 @@ private void UpdateTitle() if (IsFileLoaded) { - _titleStringBuilder.Append($"File: {SlicerFile!.Filename} Size: {_loadedFileSizeRepresentation}"); + _titleStringBuilder.Append($"File: {SlicerFile!.Filename} ({_loadedFileSizeRepresentation})"); } _titleStringBuilder.Append($" Version: {About.VersionStr} RAM: {SizeExtensions.SizeSuffix(Environment.WorkingSet)}"); diff --git a/UVtools.UI/Windows/BenchmarkWindow.axaml b/UVtools.UI/Windows/BenchmarkWindow.axaml index 93d1c493..27ab772c 100644 --- a/UVtools.UI/Windows/BenchmarkWindow.axaml +++ b/UVtools.UI/Windows/BenchmarkWindow.axaml @@ -9,6 +9,7 @@ Icon="/Assets/Icons/UVtools.ico" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterOwner" + MinWidth="560" CanResize="False" x:Class="UVtools.UI.Windows.BenchmarkWindow" x:DataType="windows:BenchmarkWindow"> @@ -81,17 +82,23 @@ + ShowProgressText="True" + ProgressTextFormat="{Binding #SingleThreadDiffProgressBar.Value, StringFormat='{}{0:0}%'}"/> + ShowProgressText="True" + ProgressTextFormat="{Binding #MultiThreadDiffProgressBar.Value, StringFormat='{}{0:0}%'}"/> diff --git a/UVtools.UI/Windows/BenchmarkWindow.axaml.cs b/UVtools.UI/Windows/BenchmarkWindow.axaml.cs index ce6c0d6d..e5173202 100644 --- a/UVtools.UI/Windows/BenchmarkWindow.axaml.cs +++ b/UVtools.UI/Windows/BenchmarkWindow.axaml.cs @@ -71,8 +71,8 @@ public enum BenchmarkResolution /*GZip 8K Compress*/ new BenchmarkTestResult(63.29f, 1020.41f), /*Deflate 4K Compress*/ new BenchmarkTestResult(246.91f, 4000.00f), /*Deflate 8K Compress*/ new BenchmarkTestResult(64.10f, 1033.06f), - /*LZ4 4K Compress*/ new BenchmarkTestResult(1052.63f, 6666.67f), - /*LZ4 8K Compress*/ new BenchmarkTestResult(281.69f, 2155.17f), + /*LZ4 4K Compress*/ new BenchmarkTestResult(1111.11f, 20833.33f), + /*LZ4 8K Compress*/ new BenchmarkTestResult(312.5f, 6097.56f), /*Stress CPU test*/ new BenchmarkTestResult(0f, 0f), }), new BenchmarkMachine("Intel® Core™ i9-9900K @ 5.0 GHz", "G.Skill Trident Z 32GB DDR4-3200MHz CL14", new [] @@ -198,7 +198,7 @@ public double MultiThreadDiffMaxValue get => _multiThreadDiffMaxValue; set => RaiseAndSetIfChanged(ref _multiThreadDiffMaxValue, value); } - + public IBrush SingleThreadDiffForeground { get => _singleThreadDiffForeground; diff --git a/documentation/UVtools.Core.xml b/documentation/UVtools.Core.xml index 7b7c756e..059c9273 100644 --- a/documentation/UVtools.Core.xml +++ b/documentation/UVtools.Core.xml @@ -4416,7 +4416,7 @@ - Creates a empty mat of file size + Creates an empty mat of file size True to black out the mat @@ -6189,10 +6189,11 @@ Gets tree contours cache for this layer. If not set it will calculate contours first - + - Creates an using this layer information + Creates an empty of file size + True to black out the mat diff --git a/wiki/UVtools_Compression.xlsx b/wiki/UVtools_Compression.xlsx index 75893e56..69ac25f2 100644 Binary files a/wiki/UVtools_Compression.xlsx and b/wiki/UVtools_Compression.xlsx differ