mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-09 01:52:32 +02:00
22897ea389
- **Benchmark:**
- (Add) PNG, GZip, Deflate and LZ4 compress tests
- (Change) Test against a known image instead of random noise
- (Change) Single-thread tests from 100 to 200 and multi-thread tests from 1000 to 5000
- (Improvement) Same image instance is shared between tests instead of create new per test
- (Fix) Encode typo
- **Core:**
- (Add) Layer compression method: Allow to choose the compression method for layer image
- **PNG:** Compression=High Speed=Slow (Use with low RAM)
- **GZip:** Compression=Medium Speed=Medium (Optimal)
- **Deflate:** Compression=Medium Speed=Medium (Optimal)
- **LZ4:** Compression=Low Speed=Fast (Use with high RAM)
- (Improvement) Better handling on cancel operations and more immediate response
- (Fix) Extract: Zip Slip Vulnerability (CWE-22)
- **File formats:**
- (Improvement) Better handling of encode/decoding layers from zip files
- (Fix) ZCode: Canceling the file load can trigger an error
- (Fix) VDA: Unable to open vda zip files
- **Tools:**
- (Improvement) Allow operations to be aware of ROI and Masks before execution (#436)
- (Improvement) Scripting: Allow save and load profiles (#436)
- (Fix) Adjust layer height: When using the Offset type the last layer in the range was not taken in account (#435)
- **UI:**
- (Improvement) Allow layer zoom levels of 0.1x and 64x but constrain minimum zoom to the level of image fit
- (Improvement) Update change log now shows with markdown style and more readable
- (Fix) Windows MSI upgrade to this version (#432)
- (Fix) Auto-updater for Mac ARM, was downloading x64 instead
114 lines
3.7 KiB
C#
114 lines
3.7 KiB
C#
/*
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE
|
|
* Version 3, 19 November 2007
|
|
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
* of this license document, but changing it is not allowed.
|
|
*/
|
|
|
|
using Emgu.CV.Cuda;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using UVtools.Core.Layers;
|
|
using UVtools.Core.Operations;
|
|
|
|
namespace UVtools.Core;
|
|
|
|
public static class CoreSettings
|
|
{
|
|
#region Members
|
|
private static int _maxDegreeOfParallelism = -1;
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
/// <summary>
|
|
/// Gets or sets the maximum number of concurrent tasks enabled by this ParallelOptions instance.
|
|
/// Less or equal to 0 will set to auto number
|
|
/// 1 = Single thread
|
|
/// n = Multi threads
|
|
/// </summary>
|
|
public static int MaxDegreeOfParallelism
|
|
{
|
|
get => _maxDegreeOfParallelism;
|
|
set => _maxDegreeOfParallelism = value > 0 ? Math.Min(value, Environment.ProcessorCount) : -1;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the ParallelOptions with <see cref="MaxDegreeOfParallelism"/> set
|
|
/// </summary>
|
|
public static ParallelOptions ParallelOptions => new() {MaxDegreeOfParallelism = _maxDegreeOfParallelism};
|
|
|
|
/// <summary>
|
|
/// Gets the ParallelOptions with <see cref="MaxDegreeOfParallelism"/> and the <see cref="CancellationToken"/> set
|
|
/// </summary>
|
|
public static ParallelOptions GetParallelOptions(CancellationToken token = default)
|
|
{
|
|
var options = ParallelOptions;
|
|
options.CancellationToken = token;
|
|
return options;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the ParallelOptions with <see cref="MaxDegreeOfParallelism"/> and the <see cref="CancellationToken"/> set
|
|
/// </summary>
|
|
public static ParallelOptions GetParallelOptions(OperationProgress progress) => GetParallelOptions(progress.Token);
|
|
|
|
/// <summary>
|
|
/// Gets or sets if operations run via CUDA when possible
|
|
/// </summary>
|
|
public static bool EnableCuda { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets if we can use cuda on operations
|
|
/// </summary>
|
|
public static bool CanUseCuda => EnableCuda && CudaInvoke.HasCuda;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the default compression type for layers
|
|
/// </summary>
|
|
public static Layer.LayerCompressionMethod DefaultLayerCompressionMethod { get; set; } = Layer.LayerCompressionMethod.Png;
|
|
|
|
/// <summary>
|
|
/// Gets the default folder to save the settings
|
|
/// </summary>
|
|
public static string DefaultSettingsFolder
|
|
{
|
|
get
|
|
{
|
|
var folder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
|
if (string.IsNullOrWhiteSpace(folder)) folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
|
if (string.IsNullOrWhiteSpace(folder)) folder = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
|
|
if (string.IsNullOrWhiteSpace(folder)) folder = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
|
var path = Path.Combine(folder, About.Software);
|
|
return path;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the default folder to save the settings
|
|
/// </summary>
|
|
public static string DefaultSettingsFolderAndEnsureCreation
|
|
{
|
|
get
|
|
{
|
|
var path = DefaultSettingsFolder;
|
|
try
|
|
{
|
|
if (!Directory.Exists(path))
|
|
Directory.CreateDirectory(path);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.WriteLine(e);
|
|
}
|
|
return path;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
} |