diff --git a/QuickLook.Common b/QuickLook.Common index 7d048bc..81028d2 160000 --- a/QuickLook.Common +++ b/QuickLook.Common @@ -1 +1 @@ -Subproject commit 7d048bc2582aee1abbfc469280aaf2def0f39fda +Subproject commit 81028d2e420e8975b930dc44732083fbb2d5283d diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/AnimatedImage.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/AnimatedImage.cs index f5780d1..1cf0197 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/AnimatedImage.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/AnimatedImage.cs @@ -48,12 +48,12 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage public event EventHandler ImageLoaded; public event EventHandler DoZoomToFit; - private static AnimationProvider InitAnimationProvider(Uri path, MetaProvider meta) + private static AnimationProvider InitAnimationProvider(Uri path, MetaProvider meta, ContextObject contextObject) { var ext = Path.GetExtension(path.LocalPath).ToLower(); var type = Providers.First(p => p.Key.Contains(ext) || p.Key.Contains("*")).Value; - var provider = type.CreateInstance(path, meta); + var provider = type.CreateInstance(path, meta, contextObject); return provider; } @@ -106,7 +106,7 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage //var thumbnail = instance.Meta?.GetThumbnail(true); //instance.Source = thumbnail; - instance._animation = InitAnimationProvider((Uri) ev.NewValue, instance.Meta); + instance._animation = InitAnimationProvider((Uri) ev.NewValue, instance.Meta, instance.ContextObject); ShowThumbnailAndStartAnimation(instance); } diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/AnimationProvider.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/AnimationProvider.cs index ed6f773..bec84b9 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/AnimationProvider.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/AnimationProvider.cs @@ -20,21 +20,25 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; +using QuickLook.Common.Plugin; namespace QuickLook.Plugin.ImageViewer.AnimatedImage { internal abstract class AnimationProvider : IDisposable { - protected AnimationProvider(Uri path, MetaProvider meta) + protected AnimationProvider(Uri path, MetaProvider meta, ContextObject contextObject) { Path = path; Meta = meta; + ContextObject = contextObject; } public Uri Path { get; } public MetaProvider Meta { get; } + public ContextObject ContextObject { get; } + public Int32AnimationUsingKeyFrames Animator { get; protected set; } public abstract void Dispose(); diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/APngProvider.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/APngProvider.cs index 1c3360a..c2e3d30 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/APngProvider.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/APngProvider.cs @@ -26,6 +26,7 @@ using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using LibAPNG; using QuickLook.Common.ExtensionMethods; +using QuickLook.Common.Plugin; namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers { @@ -37,11 +38,11 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers private int _lastEffectivePreviousPreviousFrameIndex; private NativeProvider _nativeImageProvider; - public APngProvider(Uri path, MetaProvider meta) : base(path, meta) + public APngProvider(Uri path, MetaProvider meta, ContextObject contextObject) : base(path, meta, contextObject) { if (!IsAnimatedPng(path.LocalPath)) { - _nativeImageProvider = new NativeProvider(path, meta); + _nativeImageProvider = new NativeProvider(path, meta, contextObject); Animator = _nativeImageProvider.Animator; return; } diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/DcrawProvider.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/DcrawProvider.cs index 409edc1..8a1784f 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/DcrawProvider.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/DcrawProvider.cs @@ -16,12 +16,13 @@ // along with this program. If not, see . using System; +using QuickLook.Common.Plugin; namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers { internal class DcrawProvider : NativeProvider { - public DcrawProvider(Uri path, MetaProvider meta) : base(path, meta) + public DcrawProvider(Uri path, MetaProvider meta, ContextObject contextObject) : base(path, meta, contextObject) { throw new NotImplementedException(); } diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/GifProvider.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/GifProvider.cs index ff5837f..7b84d0a 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/GifProvider.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/GifProvider.cs @@ -22,6 +22,7 @@ using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using QuickLook.Common.ExtensionMethods; using QuickLook.Common.Helpers; +using QuickLook.Common.Plugin; using Size = System.Windows.Size; namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers @@ -33,11 +34,11 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers private bool _isPlaying; private NativeProvider _nativeProvider; - public GifProvider(Uri path, MetaProvider meta) : base(path, meta) + public GifProvider(Uri path, MetaProvider meta, ContextObject contextObject) : base(path, meta, contextObject) { if (!ImageAnimator.CanAnimate(Image.FromFile(path.LocalPath))) { - _nativeProvider = new NativeProvider(path, meta); + _nativeProvider = new NativeProvider(path, meta, contextObject); return; } diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/ImageMagickProvider.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/ImageMagickProvider.cs index 84549dc..63503dd 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/ImageMagickProvider.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/ImageMagickProvider.cs @@ -25,12 +25,13 @@ using System.Windows.Media.Imaging; using ImageMagick; using ImageMagick.Formats; using QuickLook.Common.Helpers; +using QuickLook.Common.Plugin; namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers { internal class ImageMagickProvider : AnimationProvider { - public ImageMagickProvider(Uri path, MetaProvider meta) : base(path, meta) + public ImageMagickProvider(Uri path, MetaProvider meta, ContextObject contextObject) : base(path, meta, contextObject) { Animator = new Int32AnimationUsingKeyFrames(); Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(0, @@ -93,11 +94,15 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers { using (var mi = new MagickImage(Path.LocalPath, settings)) { - var profile = mi.GetColorProfile(); - if (mi.ColorSpace == ColorSpace.RGB || mi.ColorSpace == ColorSpace.sRGB || - mi.ColorSpace == ColorSpace.scRGB) - if (profile?.Description != null && !profile.Description.Contains("sRGB")) + if (SettingHelper.Get("UseColorProfile", false, "QuickLook.Plugin.ImageViewer")) + { + if (mi.ColorSpace == ColorSpace.RGB || mi.ColorSpace == ColorSpace.sRGB || mi.ColorSpace == ColorSpace.scRGB) + { mi.SetProfile(ColorProfile.SRGB); + if (ContextObject.ColorProfileName != null) + mi.SetProfile(new ColorProfile(ContextObject.ColorProfileName)); // map to monitor color + } + } mi.AutoOrient(); diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/NativeProvider.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/NativeProvider.cs index 48c02f9..c053ca9 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/NativeProvider.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/AnimatedImage/Providers/NativeProvider.cs @@ -22,12 +22,13 @@ using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using QuickLook.Common.Helpers; +using QuickLook.Common.Plugin; namespace QuickLook.Plugin.ImageViewer.AnimatedImage.Providers { internal class NativeProvider : AnimationProvider { - public NativeProvider(Uri path, MetaProvider meta) : base(path, meta) + public NativeProvider(Uri path, MetaProvider meta, ContextObject contextObject) : base(path, meta, contextObject) { Animator = new Int32AnimationUsingKeyFrames(); Animator.KeyFrames.Add(new DiscreteInt32KeyFrame(0, diff --git a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Plugin.cs b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Plugin.cs index 444cfc7..013aa6f 100644 --- a/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Plugin.cs +++ b/QuickLook.Plugin/QuickLook.Plugin.ImageViewer/Plugin.cs @@ -59,14 +59,18 @@ namespace QuickLook.Plugin.ImageViewer public void Init() { + var useColorProfile = SettingHelper.Get("UseColorProfile", false, "QuickLook.Plugin.ImageViewer"); + AnimatedImage.AnimatedImage.Providers.Add( - new KeyValuePair(new[] {".apng", ".png"}, + new KeyValuePair( + useColorProfile ? new[] { ".apng" } : new[] { ".apng", ".png" }, typeof(APngProvider))); AnimatedImage.AnimatedImage.Providers.Add( new KeyValuePair(new[] {".gif"}, typeof(GifProvider))); AnimatedImage.AnimatedImage.Providers.Add( - new KeyValuePair(new[] {".bmp", ".jpg", ".jpeg", ".jfif", ".tif", ".tiff"}, + new KeyValuePair( + useColorProfile ? new string[0] : new[] { ".bmp", ".jpg", ".jpeg", ".jfif", ".tif", ".tiff" }, typeof(NativeProvider))); AnimatedImage.AnimatedImage.Providers.Add( new KeyValuePair(new[] {"*"}, diff --git a/QuickLook/ViewerWindow.Actions.cs b/QuickLook/ViewerWindow.Actions.cs index 194fd98..4236d0d 100644 --- a/QuickLook/ViewerWindow.Actions.cs +++ b/QuickLook/ViewerWindow.Actions.cs @@ -171,6 +171,11 @@ namespace QuickLook _path = path; Plugin = matchedPlugin; + ContextObject.Reset(); + + // assign monitor color profile + ContextObject.ColorProfileName = DisplayDeviceHelper.GetMonitorColorProfileFromWindow(this); + // get window size before showing it try {