diff --git a/QuickLook.Plugin/QuickLook.Plugin.AppViewer/Translations.config b/QuickLook.Plugin/QuickLook.Plugin.AppViewer/Translations.config index 41b0f37..34563ce 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.AppViewer/Translations.config +++ b/QuickLook.Plugin/QuickLook.Plugin.AppViewer/Translations.config @@ -124,7 +124,7 @@ 裝置類型 最低支援 API 版本 目標 API 版本 - 編譯 SDK 版本 + 編譯 SDK 版本 架構 維護者 描述 diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Helper.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Helper.cs index 7a631dc..3c6d18e 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Helper.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Helper.cs @@ -20,13 +20,50 @@ using System; using System.IO; using System.Reflection; using System.Text; +using System.Windows; using System.Windows.Media.Imaging; namespace QuickLook.Plugin.ImageViewer; -internal class Helper +internal static class Helper { - public static void DpiHack(BitmapSource img) + public static BitmapSource InvertColors(this BitmapSource source) + { + WriteableBitmap writableBitmap = new(source); + writableBitmap.Lock(); + + nint pBackBuffer = writableBitmap.BackBuffer; + int stride = writableBitmap.BackBufferStride; + int width = writableBitmap.PixelWidth; + int height = writableBitmap.PixelHeight; + int bytesPerPixel = (writableBitmap.Format.BitsPerPixel + 7) / 8; + + unsafe + { + byte* pPixels = (byte*)pBackBuffer; + + for (int y = 0; y < height; y++) + { + Span row = new(pPixels + y * stride, width * bytesPerPixel); + + for (int x = 0; x < width; x++) + { + int index = x * bytesPerPixel; + + row[index] = (byte)(255 - row[index]); + row[index + 1] = (byte)(255 - row[index + 1]); + row[index + 2] = (byte)(255 - row[index + 2]); + } + } + } + + writableBitmap.AddDirtyRect(new Int32Rect(0, 0, width, height)); + writableBitmap.Unlock(); + + return writableBitmap; + } + + public static void DpiHack(this BitmapSource img) { // a dirty hack... but is the fastest diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/ImagePanel.xaml b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/ImagePanel.xaml index 4d5194b..b4ee352 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/ImagePanel.xaml +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/ImagePanel.xaml @@ -102,7 +102,24 @@ Content="" Style="{StaticResource CaptionButtonStyle}" Visibility="{Binding ElementName=imagePanel, Path=CopyIconVisibility}" /> - +