mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-10 17:29:08 +00:00
Fix #93: Ignore image resolutions
This commit is contained in:
@@ -21,7 +21,6 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using LibAPNG;
|
||||
using QuickLook.Helpers;
|
||||
|
||||
namespace QuickLook.Plugin.ImageViewer.AnimatedImage
|
||||
{
|
||||
@@ -33,9 +32,7 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage
|
||||
|
||||
if (decoder.IsSimplePNG)
|
||||
{
|
||||
animator.KeyFrames.Add(
|
||||
new DiscreteObjectKeyFrame(BitmapFrame.Create(new Uri(path)), TimeSpan.Zero));
|
||||
animator.Duration = Duration.Forever;
|
||||
new ImageMagickProvider().GetAnimator(animator, path);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -64,7 +61,9 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage
|
||||
private static BitmapSource MakeFrame(IHDRChunk header, Frame rawFrame, Frame previousFrame,
|
||||
BitmapSource previousRenderedFrame)
|
||||
{
|
||||
var fs = rawFrame.GetBitmapSource();
|
||||
var visual = new DrawingVisual();
|
||||
|
||||
using (var context = visual.RenderOpen())
|
||||
{
|
||||
switch (rawFrame.fcTLChunk.DisposeOp)
|
||||
@@ -95,12 +94,12 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage
|
||||
// draw current frame
|
||||
var frameRect = new Rect(rawFrame.fcTLChunk.XOffset, rawFrame.fcTLChunk.YOffset,
|
||||
rawFrame.fcTLChunk.Width, rawFrame.fcTLChunk.Height);
|
||||
context.DrawImage(rawFrame.GetBitmapSource(), frameRect);
|
||||
}
|
||||
|
||||
context.DrawImage(fs, frameRect);
|
||||
}
|
||||
var bitmap = new RenderTargetBitmap(
|
||||
header.Width, header.Height,
|
||||
DpiHelper.DefaultDpi, DpiHelper.DefaultDpi,
|
||||
Math.Floor(fs.DpiX), Math.Floor(fs.DpiY),
|
||||
PixelFormats.Pbgra32);
|
||||
bitmap.Render(visual);
|
||||
return bitmap;
|
||||
|
@@ -20,6 +20,8 @@ using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using QuickLook.ExtensionMethods;
|
||||
using QuickLook.Helpers;
|
||||
|
||||
namespace QuickLook.Plugin.ImageViewer.AnimatedImage
|
||||
{
|
||||
@@ -85,7 +87,7 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage
|
||||
}
|
||||
var bitmap = new RenderTargetBitmap(
|
||||
fullImage.PixelWidth, fullImage.PixelHeight,
|
||||
fullImage.DpiX, fullImage.DpiY,
|
||||
Math.Floor(fullImage.DpiX), Math.Floor(fullImage.DpiY),
|
||||
PixelFormats.Pbgra32);
|
||||
bitmap.Render(visual);
|
||||
return bitmap;
|
||||
|
@@ -33,6 +33,7 @@ namespace QuickLook.Plugin.ImageViewer.AnimatedImage
|
||||
|
||||
using (var image = new MagickImage(path))
|
||||
{
|
||||
image.Density = new Density(Math.Floor(image.Density.X), Math.Floor(image.Density.Y));
|
||||
image.AutoOrient();
|
||||
|
||||
animator.KeyFrames.Add(new DiscreteObjectKeyFrame(image.ToBitmapSource(), TimeSpan.Zero));
|
||||
|
@@ -45,8 +45,8 @@ namespace QuickLook.ExtensionMethods
|
||||
data = source.LockBits(new Rectangle(0, 0, source.Width, source.Height),
|
||||
ImageLockMode.ReadOnly, source.PixelFormat);
|
||||
}
|
||||
bs = BitmapSource.Create(source.Width, source.Height, source.HorizontalResolution,
|
||||
source.VerticalResolution, ConvertPixelFormat(source.PixelFormat), null,
|
||||
bs = BitmapSource.Create(source.Width, source.Height, Math.Floor(source.HorizontalResolution),
|
||||
Math.Floor(source.VerticalResolution), ConvertPixelFormat(source.PixelFormat), null,
|
||||
data.Scan0, data.Stride * source.Height, data.Stride);
|
||||
|
||||
source.UnlockBits(data);
|
||||
|
Reference in New Issue
Block a user