diff --git a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/Extensions.cs b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/Extensions.cs
index 3c6e21b..00858bb 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/Extensions.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/Extensions.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
-using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
@@ -37,12 +36,8 @@ namespace QuickLook.Plugin.PDFViewer
return foundElement;
}
- [DllImport("gdi32")]
- private static extern int DeleteObject(IntPtr o);
-
public static BitmapSource ToBitmapSource(this Bitmap source)
{
- var ip = source.GetHbitmap();
BitmapSource bs = null;
try
{
@@ -57,9 +52,9 @@ namespace QuickLook.Plugin.PDFViewer
bs.Freeze();
}
- finally
+ catch
{
- DeleteObject(ip);
+ // ignored
}
return bs;
diff --git a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PageIdToImageConverter.cs b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PageIdToImageConverter.cs
index 8d4bbb2..e2662cf 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PageIdToImageConverter.cs
+++ b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PageIdToImageConverter.cs
@@ -11,7 +11,7 @@ namespace QuickLook.Plugin.PDFViewer
if (values.Length < 2)
throw new Exception("PageIdToImageConverter");
- var zoom = 0.5f;
+ var zoom = 0.3f;
if (parameter != null)
float.TryParse((string) parameter, out zoom);
@@ -21,7 +21,13 @@ namespace QuickLook.Plugin.PDFViewer
var pageId = (int) values[1];
if (pageId < 0) return null;
- return handle.GetPage(pageId, zoom).ToBitmapSource();
+ var bitmap = handle.GetPage(pageId, zoom);
+ var bs = bitmap.ToBitmapSource();
+ bitmap.Dispose();
+
+ GC.Collect(GC.MaxGeneration, GCCollectionMode.Optimized);
+
+ return bs;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
diff --git a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PdfViewerControl.xaml b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PdfViewerControl.xaml
index 29ea080..d55cc6d 100644
--- a/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PdfViewerControl.xaml
+++ b/QuickLook.Plugin/QuickLook.Plugin.PDFViewer/PdfViewerControl.xaml
@@ -23,7 +23,7 @@