From 82447c3c66dc754c065e542362cbd4e26fea2601 Mon Sep 17 00:00:00 2001 From: Wang Su Ning Date: Wed, 15 Nov 2023 20:20:10 +0800 Subject: [PATCH 01/11] Frontend changes: In UserSettings.cs & Settings.xaml: Added Boolean value "DownloadWithMeteredNetwork". In Options.xaml & Options.xaml.cs: Added checkbox in Options binded with the value. In StringResources: Added StringResources description and info, en & zh. --- ScreenToGif.Util/Settings/UserSettings.cs | 6 ++++++ .../Resources/Localization/StringResources.en.xaml | 2 ++ .../Resources/Localization/StringResources.zh.xaml | 2 ++ ScreenToGif/Resources/Settings.xaml | 1 + ScreenToGif/Windows/Options.xaml | 8 +++++--- ScreenToGif/Windows/Options.xaml.cs | 3 ++- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ScreenToGif.Util/Settings/UserSettings.cs b/ScreenToGif.Util/Settings/UserSettings.cs index 945c91d7..f681615d 100644 --- a/ScreenToGif.Util/Settings/UserSettings.cs +++ b/ScreenToGif.Util/Settings/UserSettings.cs @@ -759,6 +759,12 @@ public bool CheckForUpdates set => SetValue(value); } + public bool DownloadWithMeteredNetwork + { + get => (bool)GetValue(); + set => SetValue(value); + } + public bool PortableUpdate { get => (bool)GetValue(); diff --git a/ScreenToGif/Resources/Localization/StringResources.en.xaml b/ScreenToGif/Resources/Localization/StringResources.en.xaml index a1937676..63ea9eb3 100644 --- a/ScreenToGif/Resources/Localization/StringResources.en.xaml +++ b/ScreenToGif/Resources/Localization/StringResources.en.xaml @@ -261,6 +261,8 @@ (Requires a manual installation by unzipping and replacing the executable) Force the update to run with elevated privileges. Prompt me before the installation starts. + Download updates with metered network. + (Set your connection type in system settings) Interface diff --git a/ScreenToGif/Resources/Localization/StringResources.zh.xaml b/ScreenToGif/Resources/Localization/StringResources.zh.xaml index 4b3f36b0..01d3a568 100644 --- a/ScreenToGif/Resources/Localization/StringResources.zh.xaml +++ b/ScreenToGif/Resources/Localization/StringResources.zh.xaml @@ -261,6 +261,8 @@ (需要通过解压缩和替换可执行文件来进行手动安装) 强制更新时提升特权 在安装开始之前提示我 + 使用按流量计费的连接下载更新 + (在系统设置中设置您的连接类型) 界面 diff --git a/ScreenToGif/Resources/Settings.xaml b/ScreenToGif/Resources/Settings.xaml index b0e900c7..a19b0773 100644 --- a/ScreenToGif/Resources/Settings.xaml +++ b/ScreenToGif/Resources/Settings.xaml @@ -57,6 +57,7 @@ False True True + True False False True diff --git a/ScreenToGif/Windows/Options.xaml b/ScreenToGif/Windows/Options.xaml index ae2b9840..3c8334cf 100644 --- a/ScreenToGif/Windows/Options.xaml +++ b/ScreenToGif/Windows/Options.xaml @@ -392,6 +392,8 @@ + @@ -507,7 +509,7 @@ - + @@ -523,7 +525,7 @@ - + @@ -1158,7 +1160,7 @@ - + diff --git a/ScreenToGif/Windows/Options.xaml.cs b/ScreenToGif/Windows/Options.xaml.cs index 5d5d3edc..2db15806 100644 --- a/ScreenToGif/Windows/Options.xaml.cs +++ b/ScreenToGif/Windows/Options.xaml.cs @@ -104,6 +104,7 @@ public Options() UpdatesCheckBox.Visibility = Visibility.Collapsed; CheckForUpdatesLabel.Visibility = Visibility.Collapsed; StoreTextBlock.Visibility = Visibility.Visible; + DownloadWithMeteredNetworkCheckBox.Visibility = Visibility.Collapsed; #elif FULL_MULTI_MSIX PortableUpdateCheckBox.Visibility = Visibility.Collapsed; AdminUpdateCheckBox.Visibility = Visibility.Collapsed; @@ -763,7 +764,7 @@ private void ForceUpdateSystemTray() var items = App.NotifyIcon.ContextMenu.Items.OfType(); foreach (var item in items) - item.Header = LocalizationHelper.Get((string) item.Tag); + item.Header = LocalizationHelper.Get((string)item.Tag); } #endregion From 9b73aa02f446db48eac84f902f5b116c3025a681 Mon Sep 17 00:00:00 2001 From: Wang Su Ning Date: Wed, 15 Nov 2023 21:25:31 +0800 Subject: [PATCH 02/11] Backend changes: In Other.cs: Added method IsMeteredNetwork, using WinRT API. In ScreenToGif.csproj: Since the API used in method was introduced in Windows 10 (10.0.10240.0), so I have to change projects target OS version. In ApplicationViewModel.cs: Use the method with option value to determine if we download new version automatically. --- ScreenToGif/Util/Other.cs | 22 +++++++++++++++++++ ScreenToGif/ViewModel/ApplicationViewModel.cs | 3 ++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ScreenToGif/Util/Other.cs b/ScreenToGif/Util/Other.cs index 1d328ef0..675f0521 100644 --- a/ScreenToGif/Util/Other.cs +++ b/ScreenToGif/Util/Other.cs @@ -14,6 +14,7 @@ using ScreenToGif.Native.External; using ScreenToGif.Native.Structs; using ScreenToGif.Util.Settings; +using Windows.Networking.Connectivity; namespace ScreenToGif.Util; @@ -231,6 +232,27 @@ public static void CopyPropertiesTo(this T source, TU dest) } } + public static bool IsMeteredNetwork() + { + ConnectionProfile internetConnectionProfile = NetworkInformation.GetInternetConnectionProfile(); + + if (internetConnectionProfile != null) + { + NetworkCostType networkCostType = internetConnectionProfile.GetConnectionCost().NetworkCostType; + + if (networkCostType == NetworkCostType.Unrestricted) + { + return false; + } + else if (networkCostType == NetworkCostType.Fixed || networkCostType == NetworkCostType.Variable) + { + return true; + } + } + + return false; + } + #region List public static List CopyList(this List target) diff --git a/ScreenToGif/ViewModel/ApplicationViewModel.cs b/ScreenToGif/ViewModel/ApplicationViewModel.cs index 761be71c..be98716f 100644 --- a/ScreenToGif/ViewModel/ApplicationViewModel.cs +++ b/ScreenToGif/ViewModel/ApplicationViewModel.cs @@ -985,7 +985,8 @@ private async Task CheckOnGithub() Global.UpdateAvailable.Version), StatusType.Update, "update", PromptUpdate)); //Download update to be installed when the app closes. - if (UserSettings.All.InstallUpdates && Global.UpdateAvailable.HasDownloadLink) + if (UserSettings.All.InstallUpdates && Global.UpdateAvailable.HasDownloadLink + && (UserSettings.All.DownloadWithMeteredNetwork || !Util.Other.IsMeteredNetwork())) await DownloadUpdate(); return true; From 4419499baf1f206ab232e43a29337dd9a265d766 Mon Sep 17 00:00:00 2001 From: Nicke Manarin Date: Sat, 13 Jan 2024 15:29:41 -0300 Subject: [PATCH 03/11] Fixed issue with allowing multiple instances of the app. --- ScreenToGif.Model/ScreenToGif.Domain.csproj | 2 +- ScreenToGif.Native/ScreenToGif.Native.csproj | 2 +- .../InstanceSwitcherChannel.cs | 3 +-- .../InterProcessChannel/PipeServer.cs | 19 +++++++++++++------ ScreenToGif.Util/ScreenToGif.Util.csproj | 2 +- .../ScreenToGif.ViewModel.csproj | 2 +- .../Localization/StringResources.en.xaml | 4 ++-- .../Localization/StringResources.pt.xaml | 2 ++ ScreenToGif/ScreenToGif.csproj | 2 +- 9 files changed, 23 insertions(+), 15 deletions(-) diff --git a/ScreenToGif.Model/ScreenToGif.Domain.csproj b/ScreenToGif.Model/ScreenToGif.Domain.csproj index 3590df27..2462f219 100644 --- a/ScreenToGif.Model/ScreenToGif.Domain.csproj +++ b/ScreenToGif.Model/ScreenToGif.Domain.csproj @@ -6,7 +6,7 @@ embedded True AnyCPU;ARM64;x64;x86 - 2.40.1 + 2.40.2 true diff --git a/ScreenToGif.Native/ScreenToGif.Native.csproj b/ScreenToGif.Native/ScreenToGif.Native.csproj index 426d03a7..b7742da6 100644 --- a/ScreenToGif.Native/ScreenToGif.Native.csproj +++ b/ScreenToGif.Native/ScreenToGif.Native.csproj @@ -6,7 +6,7 @@ True embedded AnyCPU;ARM64;x64;x86 - 2.40.1 + 2.40.2 10.0.17763.0 diff --git a/ScreenToGif.Util/InterProcessChannel/InstanceSwitcherChannel.cs b/ScreenToGif.Util/InterProcessChannel/InstanceSwitcherChannel.cs index 216596e9..2a8441d8 100644 --- a/ScreenToGif.Util/InterProcessChannel/InstanceSwitcherChannel.cs +++ b/ScreenToGif.Util/InterProcessChannel/InstanceSwitcherChannel.cs @@ -18,8 +18,7 @@ public static class InstanceSwitcherChannel private static PipeServer _server; private static Action _receivedAction; - - + public static void RegisterServer(Action receivedAction) { try diff --git a/ScreenToGif.Util/InterProcessChannel/PipeServer.cs b/ScreenToGif.Util/InterProcessChannel/PipeServer.cs index 2b852c02..0ff84487 100644 --- a/ScreenToGif.Util/InterProcessChannel/PipeServer.cs +++ b/ScreenToGif.Util/InterProcessChannel/PipeServer.cs @@ -35,16 +35,23 @@ public void Stop() private async void ServerLoop() { - while (true) + while (!_source.IsCancellationRequested) { - await _pipe.WaitForConnectionAsync(_source.Token); + try + { + await _pipe.WaitForConnectionAsync(_source.Token); - var message = await JsonSerializer.DeserializeAsync(_pipe, (JsonSerializerOptions) null, _source.Token); + var message = await JsonSerializer.DeserializeAsync(_pipe, (JsonSerializerOptions)null, _source.Token); - _pipe.Disconnect(); + _pipe.Disconnect(); - if (message != null) - _synchronizationContext.Post(OnMessageReceived, message); + if (message != null) + _synchronizationContext.Post(OnMessageReceived, message); + } + catch (Exception) + { + //Ignore. + } } } diff --git a/ScreenToGif.Util/ScreenToGif.Util.csproj b/ScreenToGif.Util/ScreenToGif.Util.csproj index 73607d4f..75de5e83 100644 --- a/ScreenToGif.Util/ScreenToGif.Util.csproj +++ b/ScreenToGif.Util/ScreenToGif.Util.csproj @@ -5,7 +5,7 @@ True embedded AnyCPU;ARM64;x64;x86 - 2.40.1 + 2.40.2 10.0.17763.0 diff --git a/ScreenToGif.ViewModel/ScreenToGif.ViewModel.csproj b/ScreenToGif.ViewModel/ScreenToGif.ViewModel.csproj index 815d4994..80d2267e 100644 --- a/ScreenToGif.ViewModel/ScreenToGif.ViewModel.csproj +++ b/ScreenToGif.ViewModel/ScreenToGif.ViewModel.csproj @@ -5,7 +5,7 @@ disable embedded AnyCPU;ARM64;x64;x86 - 2.40.1 + 2.40.2 10.0.17763.0 diff --git a/ScreenToGif/Resources/Localization/StringResources.en.xaml b/ScreenToGif/Resources/Localization/StringResources.en.xaml index 63ea9eb3..028007d1 100644 --- a/ScreenToGif/Resources/Localization/StringResources.en.xaml +++ b/ScreenToGif/Resources/Localization/StringResources.en.xaml @@ -261,8 +261,8 @@ (Requires a manual installation by unzipping and replacing the executable) Force the update to run with elevated privileges. Prompt me before the installation starts. - Download updates with metered network. - (Set your connection type in system settings) + Download updates on metered networks. + (Allows download of updates on metered networks) Interface diff --git a/ScreenToGif/Resources/Localization/StringResources.pt.xaml b/ScreenToGif/Resources/Localization/StringResources.pt.xaml index 1f0c319c..e98ee64f 100644 --- a/ScreenToGif/Resources/Localization/StringResources.pt.xaml +++ b/ScreenToGif/Resources/Localization/StringResources.pt.xaml @@ -261,6 +261,8 @@ (Requirer a instalação manual, descompactando e trocando o executável) Force a atualização para executar com privilégios de administrador. Avisar-me antes do início da instalação. + Baixe atualizações em redes limitadas. + (Permite baixar atualizações em redes com download limitado) Interface diff --git a/ScreenToGif/ScreenToGif.csproj b/ScreenToGif/ScreenToGif.csproj index f3f978d0..6ac2a17b 100644 --- a/ScreenToGif/ScreenToGif.csproj +++ b/ScreenToGif/ScreenToGif.csproj @@ -141,7 +141,7 @@ OnBuildSuccess Nicke Manarin Nicke Manarin - 2.40.1 + 2.40.2 Copyright© Nicke Manarin 2023 https://www.screentogif.com Readme.md From 46272af85dd73e9d93576105888af288005bfc4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20K=C5=91szeg?= Date: Wed, 14 Feb 2024 19:59:58 +0100 Subject: [PATCH 04/11] Upgrading KGySoft package versions --- ScreenToGif.Util/ScreenToGif.Util.csproj | 2 +- ScreenToGif.ViewModel/ScreenToGif.ViewModel.csproj | 2 +- ScreenToGif/ScreenToGif.csproj | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ScreenToGif.Util/ScreenToGif.Util.csproj b/ScreenToGif.Util/ScreenToGif.Util.csproj index 75de5e83..b4337a88 100644 --- a/ScreenToGif.Util/ScreenToGif.Util.csproj +++ b/ScreenToGif.Util/ScreenToGif.Util.csproj @@ -10,7 +10,7 @@ - + diff --git a/ScreenToGif.ViewModel/ScreenToGif.ViewModel.csproj b/ScreenToGif.ViewModel/ScreenToGif.ViewModel.csproj index 80d2267e..360159c7 100644 --- a/ScreenToGif.ViewModel/ScreenToGif.ViewModel.csproj +++ b/ScreenToGif.ViewModel/ScreenToGif.ViewModel.csproj @@ -9,7 +9,7 @@ 10.0.17763.0 - + diff --git a/ScreenToGif/ScreenToGif.csproj b/ScreenToGif/ScreenToGif.csproj index 6ac2a17b..41966abd 100644 --- a/ScreenToGif/ScreenToGif.csproj +++ b/ScreenToGif/ScreenToGif.csproj @@ -104,8 +104,8 @@ - - + + all From 6ca44992c74c3487ae822eea9783c7e962a6eabd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20K=C5=91szeg?= Date: Wed, 14 Feb 2024 20:10:48 +0100 Subject: [PATCH 05/11] KGySoft GIF preset: adding new default preset --- .../AnimatedImage/Gif/KGySoftGifPreset.cs | 22 ++++++++++++------- .../Localization/StringResources.en.xaml | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ScreenToGif.ViewModel/ExportPresets/AnimatedImage/Gif/KGySoftGifPreset.cs b/ScreenToGif.ViewModel/ExportPresets/AnimatedImage/Gif/KGySoftGifPreset.cs index 6fb36e2c..2f1a3be2 100644 --- a/ScreenToGif.ViewModel/ExportPresets/AnimatedImage/Gif/KGySoftGifPreset.cs +++ b/ScreenToGif.ViewModel/ExportPresets/AnimatedImage/Gif/KGySoftGifPreset.cs @@ -45,23 +45,31 @@ public class KGySoftGifPreset : GifPreset { new KGySoftGifPreset { - TitleKey = "S.Preset.Gif.KGySoft.Balanced.Title", - DescriptionKey = "S.Preset.Gif.KGySoft.Balanced.Description", + TitleKey = "S.Preset.Gif.KGySoft.Default.Title", + DescriptionKey = "S.Preset.Gif.KGySoft.Default.Description", HasAutoSave = true, IsSelected = true, IsDefault = true, IsSelectedForEncoder = true, - CreationDate = new DateTime(2021, 12, 15), - QuantizerId = $"{nameof(OptimizedPaletteQuantizer)}.{nameof(OptimizedPaletteQuantizer.Wu)}", + CreationDate = new DateTime(2024, 1, 25), + QuantizerId = $"{nameof(OptimizedPaletteQuantizer)}.{nameof(OptimizedPaletteQuantizer.MedianCut)}", }, + // Leaving here for reference because if someone already has a saved config with it, then it's still relevant. + //new KGySoftGifPreset + //{ + // TitleKey = "S.Preset.Gif.KGySoft.Balanced.Title", + // DescriptionKey = "S.Preset.Gif.KGySoft.Balanced.Description", + // HasAutoSave = true, + // IsDefault = true, + // CreationDate = new DateTime(2021, 12, 15), + // QuantizerId = $"{nameof(OptimizedPaletteQuantizer)}.{nameof(OptimizedPaletteQuantizer.Wu)}", + //}, new KGySoftGifPreset { TitleKey = "S.Preset.Gif.KGySoft.High.Title", DescriptionKey = "S.Preset.Gif.KGySoft.High.Description", HasAutoSave = true, - IsSelected = true, IsDefault = true, - IsSelectedForEncoder = true, CreationDate = new DateTime(2021, 12, 15), QuantizerId = $"{nameof(OptimizedPaletteQuantizer)}.{nameof(OptimizedPaletteQuantizer.Wu)}", DithererId = $"{nameof(ErrorDiffusionDitherer)}.{nameof(ErrorDiffusionDitherer.FloydSteinberg)}", @@ -72,9 +80,7 @@ public class KGySoftGifPreset : GifPreset TitleKey = "S.Preset.Gif.KGySoft.Fast.Title", DescriptionKey = "S.Preset.Gif.KGySoft.Fast.Description", HasAutoSave = true, - IsSelected = true, IsDefault = true, - IsSelectedForEncoder = true, CreationDate = new DateTime(2021, 12, 15), QuantizerId = $"{nameof(PredefinedColorsQuantizer)}.{nameof(PredefinedColorsQuantizer.SystemDefault8BppPalette)}", DithererId = $"{nameof(OrderedDitherer)}.{nameof(OrderedDitherer.Bayer8x8)}", diff --git a/ScreenToGif/Resources/Localization/StringResources.en.xaml b/ScreenToGif/Resources/Localization/StringResources.en.xaml index 028007d1..c69e942a 100644 --- a/ScreenToGif/Resources/Localization/StringResources.en.xaml +++ b/ScreenToGif/Resources/Localization/StringResources.en.xaml @@ -797,6 +797,8 @@ Supports saving the animation with a transparent background. High quality • Graphics Better for recordings with a lower quantity of colors. + KGy SOFT • Default + Recommended for screen recording of regular UI. Uses Median Cut quantizer without dithering. KGy SOFT • Balanced Good quality for photo-like images using Wu's quantizer without dithering. KGy SOFT • High quality From 304e82ca3010431ca332d4bbd412957490c6246a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20K=C5=91szeg?= Date: Wed, 14 Feb 2024 20:58:13 +0100 Subject: [PATCH 06/11] KGySoft GIF encoder: Adding Linear color space option --- .../AnimatedImage/Gif/KGySoftGifPreset.cs | 11 +++++++++++ .../Resources/Localization/StringResources.en.xaml | 2 ++ ScreenToGif/UserControls/KGySoftGifOptionsPanel.xaml | 12 ++++++++++-- ScreenToGif/ViewModel/KGySoftGifOptionsViewModel.cs | 6 ++++-- ScreenToGif/ViewModel/QuantizerDescriptor.cs | 8 +++++++- 5 files changed, 34 insertions(+), 5 deletions(-) diff --git a/ScreenToGif.ViewModel/ExportPresets/AnimatedImage/Gif/KGySoftGifPreset.cs b/ScreenToGif.ViewModel/ExportPresets/AnimatedImage/Gif/KGySoftGifPreset.cs index 2f1a3be2..03972d5b 100644 --- a/ScreenToGif.ViewModel/ExportPresets/AnimatedImage/Gif/KGySoftGifPreset.cs +++ b/ScreenToGif.ViewModel/ExportPresets/AnimatedImage/Gif/KGySoftGifPreset.cs @@ -31,6 +31,7 @@ public class KGySoftGifPreset : GifPreset private bool _allowDeltaFrames = true; private bool _allowClippedFrames = true; private byte _deltaTolerance; + private bool _linearColorSpace; #endregion @@ -74,6 +75,7 @@ public class KGySoftGifPreset : GifPreset QuantizerId = $"{nameof(OptimizedPaletteQuantizer)}.{nameof(OptimizedPaletteQuantizer.Wu)}", DithererId = $"{nameof(ErrorDiffusionDitherer)}.{nameof(ErrorDiffusionDitherer.FloydSteinberg)}", BitLevel = 7, + LinearColorSpace = true }, new KGySoftGifPreset { @@ -161,6 +163,15 @@ public byte? BitLevel set => SetProperty(ref _bitLevel, value); } + /// + /// Gets or sets whether the quantizing is processed in the linear color space (as opposed to sRGB). + /// + public bool LinearColorSpace + { + get => _linearColorSpace; + set => SetProperty(ref _linearColorSpace, value); + } + #endregion #region Ditherer Settings diff --git a/ScreenToGif/Resources/Localization/StringResources.en.xaml b/ScreenToGif/Resources/Localization/StringResources.en.xaml index c69e942a..54655902 100644 --- a/ScreenToGif/Resources/Localization/StringResources.en.xaml +++ b/ScreenToGif/Resources/Localization/StringResources.en.xaml @@ -1625,6 +1625,8 @@ Custom bit level. When checked, the bit level can be configured manually. ⚠️ Warning: The highest bit level might require a LOT of memory! Higher value means more accuracy, larger target color space, slower processing and larger memory usage. For example, if 1, then the result can have no more than 8 colors, or when 2, no more than 64 colors. For Octree and Wu quantizers it affects also maximum number of monochromatic shades. For example, if 5 (which is the default for Wu quantizer), only 32 monochromatic shades can be differentiated. ⚠️ Caution: The Wu quantizer consumes at least 650 MB with the highest value. + Linear color space + When checked, some operations (alpha blending with background color, quantizing, dithering, looking up the nearest colors in the palette) are performed in the linear color space rather than the sRGB one. Working in the linear color space is slower but provides a better quality result, especially when the quantizer uses only a few colors. ⚠️ Remark: When using just a few colors, the brightness of a possibly resized preview may be incorrect because WPF performs resizing in the sRGB color space. Black and White Fixed 1 bpp palette with the black and white colors. Grayscale 4 colors diff --git a/ScreenToGif/UserControls/KGySoftGifOptionsPanel.xaml b/ScreenToGif/UserControls/KGySoftGifOptionsPanel.xaml index e9d29839..d25253a3 100644 --- a/ScreenToGif/UserControls/KGySoftGifOptionsPanel.xaml +++ b/ScreenToGif/UserControls/KGySoftGifOptionsPanel.xaml @@ -26,6 +26,7 @@ + @@ -81,6 +82,13 @@ + + + + @@ -180,11 +188,11 @@ - - Get(_preset.PaletteSize); set => Set(_preset.PaletteSize = value); } public byte? BitLevel { get => Get(_preset.BitLevel); set => Set(_preset.BitLevel = value); } public bool IsCustomBitLevel { get => Get(_preset.BitLevel.HasValue); set => Set(value); } + public bool LinearColorSpace { get => Get(_preset.LinearColorSpace); set => Set(_preset.LinearColorSpace = value); } // Ditherer public bool UseDitherer { get => Get(_preset.DithererId != null); set => Set(value); } @@ -320,7 +322,7 @@ private async Task GeneratePreviewAsync() await WaitForPendingGenerate(); // Workaround: The awaits make this method reentrant, and a continuation can be spawn after any await at any time. - // Therefore it is possible that despite of the line above _generatePreviewTask is not null here. + // Therefore, it is possible that despite the line above _generatePreviewTask is not null here. // It could not happen after a synchronous Wait but that could cause a slight lagging (only for a short time because the task is already canceled here) while (_generatePreviewTask != null) { @@ -337,7 +339,7 @@ private async Task GeneratePreviewAsync() // The instance is created only for the first time or when resolution changes (eg. when toggling built-in/current frame preview) _previewBitmap ??= new WriteableBitmap(_currentFrame.Width, _currentFrame.Height, 96, 96, PixelFormats.Pbgra32, null); - // Storing the task and cancellation source to a field so it can be canceled/awaited on reentering, disposing, etc. + // Storing the task and cancellation source to a field, so it can be canceled/awaited on reentering, disposing, etc. var tokenSource = _cancelGeneratingPreview = new CancellationTokenSource(); var token = tokenSource.Token; diff --git a/ScreenToGif/ViewModel/QuantizerDescriptor.cs b/ScreenToGif/ViewModel/QuantizerDescriptor.cs index 4031a044..93ecd9c1 100644 --- a/ScreenToGif/ViewModel/QuantizerDescriptor.cs +++ b/ScreenToGif/ViewModel/QuantizerDescriptor.cs @@ -129,9 +129,15 @@ internal static IQuantizer Create(string id, KGySoftGifPreset preset) } var result = (IQuantizer)descriptor._method.Invoke(null, args); - if (result is OptimizedPaletteQuantizer opt && preset.BitLevel != 0) result = opt.ConfigureBitLevel(preset.BitLevel); + if (preset.LinearColorSpace) + result = result switch + { + OptimizedPaletteQuantizer o => o.ConfigureColorSpace(WorkingColorSpace.Linear), + PredefinedColorsQuantizer p => p.ConfigureColorSpace(WorkingColorSpace.Linear), + _ => throw new InvalidOperationException($"Unexpected quantizer: {result.GetType()}") + }; return result; } From c04c6781e3c163cd7e0a8a2043f38c0ac5878ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20K=C5=91szeg?= Date: Thu, 15 Feb 2024 23:19:37 +0100 Subject: [PATCH 07/11] Adding Hungarian translation for the new options --- ScreenToGif/Resources/Localization/StringResources.hu.xaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ScreenToGif/Resources/Localization/StringResources.hu.xaml b/ScreenToGif/Resources/Localization/StringResources.hu.xaml index fa5913a0..6d4df55d 100644 --- a/ScreenToGif/Resources/Localization/StringResources.hu.xaml +++ b/ScreenToGif/Resources/Localization/StringResources.hu.xaml @@ -794,6 +794,8 @@ Támogatja az animáció mentését átlátszó háttérrel. Kiváló minőség • Grafika Jobb a kisebb színmennyiségű felvételekhez. + KGy SOFT • Alapértelmezett + Szokványos felhasználói felület felvételéhez ajánlott. Medián vágás kvantálót használ árnyalás nélkül. KGy SOFT • Kiegyensúlyozott Jó minőség fénykép jellegű képekhez Wu kvantáló használatával árnyalás nélkül. KGy SOFT • Magas minőség @@ -1618,8 +1620,10 @@ Palettaméret: Meghatározza a képkockánkénti maximális palettaméretet. Egyedi bitmélység - Ha ki van jelölve, a színtér bitmélysége szabadon állítható ⚠️ Vigyázat: A legmagasabb érték NAGYON sok memóriát igényelhet! + Ha ki van jelölve, a bitmélység szabadon állítható ⚠️ Vigyázat: A legmagasabb érték NAGYON sok memóriát igényelhet! A magasabb érték nagyobb pontosságot, nagyobb színteret, lassabb feldolgozást és nagyobb memóriahasználatot jelent. Pl. ha 1, akkor az eredmény legfeljebb 8 színű lehet, vagy 2 esetén legfeljebb 64 színű. Oktális fa és Wu kvantálók esetén meghatározza a maximálisan megkülönböztethető monokróm árnyalatok színét is. Pl. ha 5 (az alapérték Wu kvantáló esetén), akkor legfeljebb 32 monokróm árnyalat különböztethető meg. ⚠️ Vigyázat: A Wu kvantáló legalább 650 MB memóriát igényel a legmagasabb érték esetén. + Lineáris színtér + Ha ki van jelölve, egyes műveletek (háttérszínnel való összemosás, kvantálás, árnyalás, legközelebbi szín keresése a palettában) a lineáris szintérben történnek az sRGB színtér helyett. A lineáris színtérben való feldolgozás lassabb, de jobb minőségű eredményt biztosít, különösen, ha a kvantáló kevés színt használ. ⚠️ Megjegyzés: Kevés szín használata esetén az esetleg átméretezett előnézet fényessége hibás lehet, mert a WPF az átméretezést az sRGB színtérben végzi. Fekete-fehér Fix 1 bites paletta fekete és fehér színekkel. Szürkeárnyalatos 4 színű From c97882d4516743f52e535789c70e6c5ee2147050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20K=C5=91szeg?= Date: Thu, 15 Feb 2024 23:59:26 +0100 Subject: [PATCH 08/11] Updating resources --- ScreenToGif/Resources/Localization/StringResources.en.xaml | 2 +- ScreenToGif/Resources/Localization/StringResources.hu.xaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ScreenToGif/Resources/Localization/StringResources.en.xaml b/ScreenToGif/Resources/Localization/StringResources.en.xaml index 54655902..54357fbc 100644 --- a/ScreenToGif/Resources/Localization/StringResources.en.xaml +++ b/ScreenToGif/Resources/Localization/StringResources.en.xaml @@ -1706,7 +1706,7 @@ Repeat Count: Specifies how many times the animation will be played. Allow delta frames. - When checked, unchanged pixels are attempted to be detected during the encoding. When using with an optimized quantizer, this option makes possible for a frame to have more than 256 colors. This option is ignored if the quantizer does not use transparency and Allow Clipped Frames is unchecked. + When checked, unchanged pixels are attempted to be detected during the encoding. When using with an optimized quantizer, this option makes possible for a frame to have more than 256 colors. This option is ignored if the quantizer does not use transparency and Allow Clipped Frames is unchecked. ⚠️ Remark: This option may cause noticeable artifacts in colors or in the dithering pattern. Delta Tolerance: Specifies the maximum tolerance when detecting changed pixels. If 0, then no difference is tolerated at all. If 255, then there might be frames (or even all of them) that are added with no content. Reasonable range is between 0 and 16 for an optimized quantizer. The ones with fixed colors can be used with somewhat larger values with dithering. If Delta Tolerance is too high the result might have poor quality. Click to reset delta tolerance. diff --git a/ScreenToGif/Resources/Localization/StringResources.hu.xaml b/ScreenToGif/Resources/Localization/StringResources.hu.xaml index 6d4df55d..27447459 100644 --- a/ScreenToGif/Resources/Localization/StringResources.hu.xaml +++ b/ScreenToGif/Resources/Localization/StringResources.hu.xaml @@ -1703,7 +1703,7 @@ Ismétlések száma: Meghatározza, hányszor legyen az animáció lejátszva. Delta képkockák engedélyezése - Ha ki van jelölve, a kódolás során kísérlet történik a változatlan pixelek detektálására. Optimalizált kvantáló esetén ez lehetővé teszi, hogy egy képkocka több mint 256 színt tartalmazzon. Ez a beállítás nincs figyelembe véve, ha a kvantáló nem használ átlátszóságot és nincs kijelölve a Levágott képkockák engedélyezése. + Ha ki van jelölve, a kódolás során kísérlet történik a változatlan pixelek detektálására. Optimalizált kvantáló esetén ez lehetővé teszi, hogy egy képkocka több mint 256 színt tartalmazzon. Ez a beállítás nincs figyelembe véve, ha a kvantáló nem használ átlátszóságot és nincs kijelölve a Levágott képkockák engedélyezése. ⚠️ Megjegyzés: Ez a beállítás szemmel látható zajt okozhat a színekben vagy az árnyalási mintázatokban. Delta tűréshatár: Meghatározza a maximális tűréshatárt a változott pixelek detektálása során. Ha 0, akkor semmilyen különbség nincs tolerálva. Ha 255, akkor lehetséges, hogy egyes képkockák (vagy akár az összes) üres lesz. Optimalizált kvantáló esetén az észszerű tartomány 0 és 16 között van, míg a fix színeket alkalmazók használhatók valamivel nagyobb értékekkel, különösen árnyalás esetén. A túl magas delta tűréshatár gyenge minőségű eredménnyel járhat. A linkre kattintással visszaállítható a delta tűréshatár. From bbb34077665295c6310cd39020e5ec28cfd8492c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20=C5=81ukasik?= Date: Sun, 10 Mar 2024 10:55:36 +0100 Subject: [PATCH 09/11] Fix calculation of the processed frame for Ffmpeg --- ScreenToGif/Util/EncodingManager.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ScreenToGif/Util/EncodingManager.cs b/ScreenToGif/Util/EncodingManager.cs index aa71689b..fa594639 100644 --- a/ScreenToGif/Util/EncodingManager.cs +++ b/ScreenToGif/Util/EncodingManager.cs @@ -1,4 +1,3 @@ -using KGySoft.Drawing; using System; using System.Collections.Generic; using System.Collections.Specialized; @@ -17,6 +16,8 @@ using System.Windows.Media; using System.Windows.Media.Imaging; +using KGySoft.CoreLibraries; +using KGySoft.Drawing; using KGySoft.Drawing.Imaging; using KGySoft.Threading; @@ -46,7 +47,6 @@ using Encoder = ScreenToGif.Windows.Other.Encoder; using LegacyGifEncoder = ScreenToGif.Util.Codification.Gif.LegacyEncoder.GifEncoder; using KGySoftGifEncoder = KGySoft.Drawing.Imaging.GifEncoder; -using ScreenToGif.ViewModel.ExportPresets.AnimatedImage.Bpg; namespace ScreenToGif.Util; @@ -1401,7 +1401,7 @@ private static void EncodeWithFfmpeg(ExportPreset preset, List