mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-10 17:29:08 +00:00
Fix #329: respect monitor ICC
This commit is contained in:
@@ -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<AnimationProvider>(path, meta);
|
||||
var provider = type.CreateInstance<AnimationProvider>(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);
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -16,12 +16,13 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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();
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user