mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-20 16:34:55 +00:00
x64 Any CPU support
This commit is contained in:
@@ -31,6 +31,24 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\Build\Debug\QuickLook.Plugin\QuickLook.Plugin.ArchiveViewer\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<OutputPath>..\..\Build\Release\QuickLook.Plugin\QuickLook.Plugin.ArchiveViewer\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
|
@@ -34,6 +34,24 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\Build\Debug\QuickLook.Plugin\QuickLook.Plugin.HtmlViewer\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<OutputPath>..\..\Build\Release\QuickLook.Plugin\QuickLook.Plugin.HtmlViewer\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System" />
|
||||
|
@@ -32,6 +32,24 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\Build\Debug\QuickLook.Plugin\QuickLook.Plugin.IPreviewHandlers\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<OutputPath>..\..\Build\Release\QuickLook.Plugin\QuickLook.Plugin.IPreviewHandlers\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
@@ -33,7 +33,7 @@ namespace QuickLook.Plugin.ImageViewer
|
||||
|
||||
public void Prepare(string path, ContextObject context)
|
||||
{
|
||||
// ImageMagick want to have dcraw.exe
|
||||
// set dcraw.exe for Magick.NET
|
||||
Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
|
||||
|
||||
_imageSize = ImageFileHelper.GetImageSize(path) ?? Size.Empty;
|
||||
|
@@ -33,12 +33,30 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\Build\Debug\QuickLook.Plugin\QuickLook.Plugin.ImageViewer\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<OutputPath>..\..\Build\Release\QuickLook.Plugin\QuickLook.Plugin.ImageViewer\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ExifLib, Version=1.7.0.0, Culture=neutral, PublicKeyToken=30284005913968db, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\ExifLib.1.7.0.0\lib\net45\ExifLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Magick.NET-Q8-x86, Version=7.0.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=x86">
|
||||
<HintPath>..\..\packages\Magick.NET-Q8-x86.7.0.5.900\lib\net40-client\Magick.NET-Q8-x86.dll</HintPath>
|
||||
<Reference Include="Magick.NET-Q8-AnyCPU, Version=7.0.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Magick.NET-Q8-AnyCPU.7.0.5.900\lib\net40-client\Magick.NET-Q8-AnyCPU.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
@@ -84,11 +102,4 @@
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\..\packages\Magick.NET-Q8-x86.7.0.5.900\build\net40-client\Magick.NET-Q8-x86.targets" Condition="Exists('..\..\packages\Magick.NET-Q8-x86.7.0.5.900\build\net40-client\Magick.NET-Q8-x86.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\packages\Magick.NET-Q8-x86.7.0.5.900\build\net40-client\Magick.NET-Q8-x86.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Magick.NET-Q8-x86.7.0.5.900\build\net40-client\Magick.NET-Q8-x86.targets'))" />
|
||||
</Target>
|
||||
</Project>
|
@@ -2,6 +2,6 @@
|
||||
|
||||
<packages>
|
||||
<package id="ExifLib" version="1.7.0.0" targetFramework="net462" />
|
||||
<package id="Magick.NET-Q8-x86" version="7.0.5.900" targetFramework="net462" />
|
||||
<package id="Magick.NET-Q8-AnyCPU" version="7.0.5.900" targetFramework="net462" />
|
||||
<package id="XamlAnimatedGif" version="1.1.9" targetFramework="net462" />
|
||||
</packages>
|
@@ -31,6 +31,24 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\Build\Debug\QuickLook.Plugin\QuickLook.Plugin.MarkdownViewer\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<OutputPath>..\..\Build\Release\QuickLook.Plugin\QuickLook.Plugin.MarkdownViewer\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
|
@@ -15,7 +15,10 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
var pix = IntPtr.Zero;
|
||||
var dev = IntPtr.Zero;
|
||||
|
||||
NativeMethods.BoundPage(document, page, ref pageBound);
|
||||
if (App.Is64Bit)
|
||||
NativeMethods.BoundPage_64(document, page, ref pageBound);
|
||||
else
|
||||
NativeMethods.BoundPage_32(document, page, ref pageBound);
|
||||
|
||||
var currentDpi = DpiHelper.GetCurrentDpi();
|
||||
var zoomX = zoomFactor * (currentDpi.HorizontalDpi / DpiHelper.DEFAULT_DPI);
|
||||
@@ -30,17 +33,33 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
ctm.D = (float) zoomY;
|
||||
|
||||
// creates a pixmap the same size as the width and height of the page
|
||||
pix = NativeMethods.NewPixmap(context, NativeMethods.LookupDeviceColorSpace(context, "DeviceRGB"), width,
|
||||
height);
|
||||
if (App.Is64Bit)
|
||||
pix = NativeMethods.NewPixmap_64(context,
|
||||
NativeMethods.LookupDeviceColorSpace_64(context, "DeviceRGB"), width, height);
|
||||
else
|
||||
pix = NativeMethods.NewPixmap_32(context,
|
||||
NativeMethods.LookupDeviceColorSpace_32(context, "DeviceRGB"), width, height);
|
||||
// sets white color as the background color of the pixmap
|
||||
NativeMethods.ClearPixmap(context, pix, 0xFF);
|
||||
if (App.Is64Bit)
|
||||
NativeMethods.ClearPixmap_64(context, pix, 0xFF);
|
||||
else
|
||||
NativeMethods.ClearPixmap_32(context, pix, 0xFF);
|
||||
|
||||
// creates a drawing device
|
||||
dev = NativeMethods.NewDrawDevice(context, pix);
|
||||
if (App.Is64Bit)
|
||||
dev = NativeMethods.NewDrawDevice_64(context, pix);
|
||||
else
|
||||
dev = NativeMethods.NewDrawDevice_32(context, pix);
|
||||
// draws the page on the device created from the pixmap
|
||||
NativeMethods.RunPage(document, page, dev, ref ctm, IntPtr.Zero);
|
||||
if (App.Is64Bit)
|
||||
NativeMethods.RunPage_64(document, page, dev, ref ctm, IntPtr.Zero);
|
||||
else
|
||||
NativeMethods.RunPage_32(document, page, dev, ref ctm, IntPtr.Zero);
|
||||
|
||||
NativeMethods.FreeDevice(dev); // frees the resources consumed by the device
|
||||
if (App.Is64Bit)
|
||||
NativeMethods.FreeDevice_64(dev); // frees the resources consumed by the device
|
||||
else
|
||||
NativeMethods.FreeDevice_32(dev); // frees the resources consumed by the device
|
||||
dev = IntPtr.Zero;
|
||||
|
||||
// creates a colorful bitmap of the same size of the pixmap
|
||||
@@ -50,7 +69,13 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
unsafe
|
||||
{
|
||||
// converts the pixmap data to Bitmap data
|
||||
var ptrSrc = (byte*) NativeMethods.GetSamples(context, pix); // gets the rendered data from the pixmap
|
||||
byte* ptrSrc;
|
||||
if (App.Is64Bit)
|
||||
ptrSrc =
|
||||
(byte*) NativeMethods.GetSamples_64(context, pix); // gets the rendered data from the pixmap
|
||||
else
|
||||
ptrSrc = (byte*) NativeMethods
|
||||
.GetSamples_32(context, pix); // gets the rendered data from the pixmap
|
||||
var ptrDest = (byte*) imageData.Scan0;
|
||||
for (var y = 0; y < height; y++)
|
||||
{
|
||||
@@ -72,7 +97,10 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
}
|
||||
}
|
||||
bmp.UnlockBits(imageData);
|
||||
NativeMethods.DropPixmap(context, pix);
|
||||
if (App.Is64Bit)
|
||||
NativeMethods.DropPixmap_64(context, pix);
|
||||
else
|
||||
NativeMethods.DropPixmap_32(context, pix);
|
||||
|
||||
bmp.SetResolution(currentDpi.HorizontalDpi, currentDpi.VerticalDpi);
|
||||
|
||||
@@ -104,70 +132,137 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
|
||||
internal class NativeMethods
|
||||
{
|
||||
private const uint FZ_STORE_DEFAULT = 256 << 20;
|
||||
private const string DLL = "libmupdf.dll";
|
||||
// please modify the version number to match the FZ_VERSION definition in "fitz\version.h" file
|
||||
private const string MuPDFVersion = "1.6";
|
||||
|
||||
[DllImport(DLL, EntryPoint = "fz_new_context_imp", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr NewContext(IntPtr alloc, IntPtr locks, uint max_store, string version);
|
||||
private const uint FzStoreDefault = 256 << 20;
|
||||
private const string MuPdfVersion = "1.6";
|
||||
|
||||
public static IntPtr NewContext()
|
||||
{
|
||||
return NewContext(IntPtr.Zero, IntPtr.Zero, FZ_STORE_DEFAULT, MuPDFVersion);
|
||||
return App.Is64Bit
|
||||
? NewContext_64(IntPtr.Zero, IntPtr.Zero, FzStoreDefault, MuPdfVersion)
|
||||
: NewContext_32(IntPtr.Zero, IntPtr.Zero, FzStoreDefault, MuPdfVersion);
|
||||
}
|
||||
|
||||
[DllImport(DLL, EntryPoint = "fz_free_context", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr FreeContext(IntPtr ctx);
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "fz_new_context_imp", CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr NewContext_32(IntPtr alloc, IntPtr locks, uint maxStore, string version);
|
||||
|
||||
[DllImport(DLL, EntryPoint = "fz_open_file_w", CharSet = CharSet.Unicode,
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "fz_free_context", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr FreeContext_32(IntPtr ctx);
|
||||
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "fz_open_file_w", CharSet = CharSet.Unicode,
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr OpenFile(IntPtr ctx, string fileName);
|
||||
public static extern IntPtr OpenFile_32(IntPtr ctx, string fileName);
|
||||
|
||||
[DllImport(DLL, EntryPoint = "pdf_open_document_with_stream", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr OpenDocumentStream(IntPtr ctx, IntPtr stm);
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "pdf_open_document_with_stream",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr OpenDocumentStream_32(IntPtr ctx, IntPtr stm);
|
||||
|
||||
[DllImport(DLL, EntryPoint = "fz_close", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr CloseStream(IntPtr stm);
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "fz_close", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr CloseStream_32(IntPtr stm);
|
||||
|
||||
[DllImport(DLL, EntryPoint = "pdf_close_document", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr CloseDocument(IntPtr doc);
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "pdf_close_document", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr CloseDocument_32(IntPtr doc);
|
||||
|
||||
[DllImport(DLL, EntryPoint = "pdf_count_pages", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int CountPages(IntPtr doc);
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "pdf_count_pages", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int CountPages_32(IntPtr doc);
|
||||
|
||||
[DllImport(DLL, EntryPoint = "pdf_bound_page", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void BoundPage(IntPtr doc, IntPtr page, ref Rectangle bound);
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "pdf_bound_page", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void BoundPage_32(IntPtr doc, IntPtr page, ref Rectangle bound);
|
||||
|
||||
[DllImport(DLL, EntryPoint = "fz_clear_pixmap_with_value", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void ClearPixmap(IntPtr ctx, IntPtr pix, int byteValue);
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "fz_clear_pixmap_with_value",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void ClearPixmap_32(IntPtr ctx, IntPtr pix, int byteValue);
|
||||
|
||||
[DllImport(DLL, EntryPoint = "fz_lookup_device_colorspace", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr LookupDeviceColorSpace(IntPtr ctx, string colorspace);
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "fz_lookup_device_colorspace",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr LookupDeviceColorSpace_32(IntPtr ctx, string colorspace);
|
||||
|
||||
[DllImport(DLL, EntryPoint = "fz_free_device", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void FreeDevice(IntPtr dev);
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "fz_free_device", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void FreeDevice_32(IntPtr dev);
|
||||
|
||||
[DllImport(DLL, EntryPoint = "pdf_free_page", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void FreePage(IntPtr doc, IntPtr page);
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "pdf_free_page", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void FreePage_32(IntPtr doc, IntPtr page);
|
||||
|
||||
[DllImport(DLL, EntryPoint = "pdf_load_page", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr LoadPage(IntPtr doc, int pageNumber);
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "pdf_load_page", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr LoadPage_32(IntPtr doc, int pageNumber);
|
||||
|
||||
[DllImport(DLL, EntryPoint = "fz_new_draw_device", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr NewDrawDevice(IntPtr ctx, IntPtr pix);
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "fz_new_draw_device", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr NewDrawDevice_32(IntPtr ctx, IntPtr pix);
|
||||
|
||||
[DllImport(DLL, EntryPoint = "fz_new_pixmap", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr NewPixmap(IntPtr ctx, IntPtr colorspace, int width, int height);
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "fz_new_pixmap", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr NewPixmap_32(IntPtr ctx, IntPtr colorspace, int width, int height);
|
||||
|
||||
[DllImport(DLL, EntryPoint = "pdf_run_page", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void RunPage(IntPtr doc, IntPtr page, IntPtr dev, ref Matrix transform, IntPtr cookie);
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "pdf_run_page", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void RunPage_32(IntPtr doc, IntPtr page, IntPtr dev, ref Matrix transform,
|
||||
IntPtr cookie);
|
||||
|
||||
[DllImport(DLL, EntryPoint = "fz_drop_pixmap", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void DropPixmap(IntPtr ctx, IntPtr pix);
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "fz_drop_pixmap", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void DropPixmap_32(IntPtr ctx, IntPtr pix);
|
||||
|
||||
[DllImport(DLL, EntryPoint = "fz_pixmap_samples", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr GetSamples(IntPtr ctx, IntPtr pix);
|
||||
[DllImport("LibMuPdf.dll", EntryPoint = "fz_pixmap_samples", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr GetSamples_32(IntPtr ctx, IntPtr pix);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "fz_new_context_imp",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
private static extern IntPtr NewContext_64(IntPtr alloc, IntPtr locks, uint maxStore, string version);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "fz_free_context", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr FreeContext_64(IntPtr ctx);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "fz_open_file_w", CharSet = CharSet.Unicode,
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr OpenFile_64(IntPtr ctx, string fileName);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "pdf_open_document_with_stream",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr OpenDocumentStream_64(IntPtr ctx, IntPtr stm);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "fz_close", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr CloseStream_64(IntPtr stm);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "pdf_close_document",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr CloseDocument_64(IntPtr doc);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "pdf_count_pages", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern int CountPages_64(IntPtr doc);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "pdf_bound_page", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void BoundPage_64(IntPtr doc, IntPtr page, ref Rectangle bound);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "fz_clear_pixmap_with_value",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void ClearPixmap_64(IntPtr ctx, IntPtr pix, int byteValue);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "fz_lookup_device_colorspace",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr LookupDeviceColorSpace_64(IntPtr ctx, string colorspace);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "fz_free_device", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void FreeDevice_64(IntPtr dev);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "pdf_free_page", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void FreePage_64(IntPtr doc, IntPtr page);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "pdf_load_page", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr LoadPage_64(IntPtr doc, int pageNumber);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "fz_new_draw_device",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr NewDrawDevice_64(IntPtr ctx, IntPtr pix);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "fz_new_pixmap", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr NewPixmap_64(IntPtr ctx, IntPtr colorspace, int width, int height);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "pdf_run_page", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void RunPage_64(IntPtr doc, IntPtr page, IntPtr dev, ref Matrix transform,
|
||||
IntPtr cookie);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "fz_drop_pixmap", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void DropPixmap_64(IntPtr ctx, IntPtr pix);
|
||||
|
||||
[DllImport("LibMuPdf.x64.dll", EntryPoint = "fz_pixmap_samples",
|
||||
CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern IntPtr GetSamples_64(IntPtr ctx, IntPtr pix);
|
||||
}
|
||||
}
|
||||
}
|
BIN
QuickLook.Plugin/QuickLook.Plugin.PDFViewer/LibMuPdf.x64.dll
Normal file
BIN
QuickLook.Plugin/QuickLook.Plugin.PDFViewer/LibMuPdf.x64.dll
Normal file
Binary file not shown.
@@ -12,11 +12,20 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
|
||||
public PdfFile(string path)
|
||||
{
|
||||
_ctx = LibMuPdf.NativeMethods.NewContext();
|
||||
_stm = LibMuPdf.NativeMethods.OpenFile(_ctx, path);
|
||||
_doc = LibMuPdf.NativeMethods.OpenDocumentStream(_ctx, _stm);
|
||||
|
||||
TotalPages = LibMuPdf.NativeMethods.CountPages(_doc);
|
||||
if (App.Is64Bit)
|
||||
{
|
||||
_ctx = LibMuPdf.NativeMethods.NewContext();
|
||||
_stm = LibMuPdf.NativeMethods.OpenFile_64(_ctx, path);
|
||||
_doc = LibMuPdf.NativeMethods.OpenDocumentStream_64(_ctx, _stm);
|
||||
TotalPages = LibMuPdf.NativeMethods.CountPages_64(_doc);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ctx = LibMuPdf.NativeMethods.NewContext();
|
||||
_stm = LibMuPdf.NativeMethods.OpenFile_32(_ctx, path);
|
||||
_doc = LibMuPdf.NativeMethods.OpenDocumentStream_32(_ctx, _stm);
|
||||
TotalPages = LibMuPdf.NativeMethods.CountPages_32(_doc);
|
||||
}
|
||||
}
|
||||
|
||||
public int TotalPages { get; }
|
||||
@@ -25,9 +34,18 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
LibMuPdf.NativeMethods.CloseDocument(_doc);
|
||||
LibMuPdf.NativeMethods.CloseStream(_stm);
|
||||
LibMuPdf.NativeMethods.FreeContext(_ctx);
|
||||
if (App.Is64Bit)
|
||||
{
|
||||
LibMuPdf.NativeMethods.CloseDocument_64(_doc);
|
||||
LibMuPdf.NativeMethods.CloseStream_64(_stm);
|
||||
LibMuPdf.NativeMethods.FreeContext_64(_ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
LibMuPdf.NativeMethods.CloseDocument_32(_doc);
|
||||
LibMuPdf.NativeMethods.CloseStream_32(_stm);
|
||||
LibMuPdf.NativeMethods.FreeContext_32(_ctx);
|
||||
}
|
||||
}
|
||||
|
||||
~PdfFile()
|
||||
@@ -46,10 +64,15 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
throw new OverflowException(
|
||||
$"Page id {pageId} should greater or equal than 0 and less than total page count {TotalPages}.");
|
||||
|
||||
var p = LibMuPdf.NativeMethods.LoadPage(_doc, pageId);
|
||||
var p = App.Is64Bit
|
||||
? LibMuPdf.NativeMethods.LoadPage_64(_doc, pageId)
|
||||
: LibMuPdf.NativeMethods.LoadPage_32(_doc, pageId);
|
||||
|
||||
var realSize = new LibMuPdf.Rectangle();
|
||||
LibMuPdf.NativeMethods.BoundPage(_doc, p, ref realSize);
|
||||
if (App.Is64Bit)
|
||||
LibMuPdf.NativeMethods.BoundPage_64(_doc, p, ref realSize);
|
||||
else
|
||||
LibMuPdf.NativeMethods.BoundPage_32(_doc, p, ref realSize);
|
||||
|
||||
var size = new Size
|
||||
{
|
||||
@@ -57,7 +80,10 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
Height = realSize.Bottom * zoomFactor
|
||||
};
|
||||
|
||||
LibMuPdf.NativeMethods.FreePage(_doc, p);
|
||||
if (App.Is64Bit)
|
||||
LibMuPdf.NativeMethods.FreePage_64(_doc, p);
|
||||
else
|
||||
LibMuPdf.NativeMethods.FreePage_32(_doc, p);
|
||||
|
||||
return size;
|
||||
}
|
||||
@@ -68,11 +94,16 @@ namespace QuickLook.Plugin.PDFViewer
|
||||
throw new OverflowException(
|
||||
$"Page id {pageId} should greater or equal than 0 and less than total page count {TotalPages}.");
|
||||
|
||||
var p = LibMuPdf.NativeMethods.LoadPage(_doc, pageId);
|
||||
var p = App.Is64Bit
|
||||
? LibMuPdf.NativeMethods.LoadPage_64(_doc, pageId)
|
||||
: LibMuPdf.NativeMethods.LoadPage_32(_doc, pageId);
|
||||
|
||||
var bmp = LibMuPdf.RenderPage(_ctx, _doc, p, zoomFactor);
|
||||
|
||||
LibMuPdf.NativeMethods.FreePage(_doc, p);
|
||||
if (App.Is64Bit)
|
||||
LibMuPdf.NativeMethods.FreePage_64(_doc, p);
|
||||
else
|
||||
LibMuPdf.NativeMethods.FreePage_32(_doc, p);
|
||||
|
||||
return bmp;
|
||||
}
|
||||
|
@@ -33,6 +33,26 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\Build\Debug\QuickLook.Plugin\QuickLook.Plugin.PDFViewer\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<OutputPath>..\..\Build\Release\QuickLook.Plugin\QuickLook.Plugin.PDFViewer\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
@@ -69,6 +89,9 @@
|
||||
<Content Include="LibMuPdf.dll">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="LibMuPdf.x64.dll">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="ListBoxItemStyleNoFocusedBorder.xaml">
|
||||
|
@@ -31,6 +31,24 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\Build\Debug\QuickLook.Plugin\QuickLook.Plugin.TextViewer\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<OutputPath>..\..\Build\Release\QuickLook.Plugin\QuickLook.Plugin.TextViewer\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ICSharpCode.AvalonEdit, Version=5.0.3.0, Culture=neutral, PublicKeyToken=9cc39be672370310, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\AvalonEdit.5.0.3\lib\Net40\ICSharpCode.AvalonEdit.dll</HintPath>
|
||||
|
@@ -13,6 +13,8 @@
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -32,6 +34,24 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\..\Build\Debug\QuickLook.Plugin\QuickLook.Plugin.VideoViewer\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<OutputPath>..\..\Build\Release\QuickLook.Plugin\QuickLook.Plugin.VideoViewer\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FontAwesome.WPF, Version=4.7.0.37774, Culture=neutral, PublicKeyToken=0758b07a11a4f466, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\FontAwesome.WPF.4.7.0.9\lib\net40\FontAwesome.WPF.dll</HintPath>
|
||||
@@ -41,7 +61,8 @@
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="Unosquare.FFmpegMediaElement">
|
||||
<Reference Include="Unosquare.FFmpegMediaElement, Version=1.3.1.4, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>References\Unosquare.FFmpegMediaElement.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
|
Binary file not shown.
@@ -38,9 +38,10 @@
|
||||
</DockPanel>
|
||||
<Grid>
|
||||
<ffmpeg:MediaElement x:Name="mediaElement" />
|
||||
<Border x:Name="buttonMute" VerticalAlignment="Bottom" HorizontalAlignment="Right" Cursor="Hand" Margin="10,10" Width="100" Height="100">
|
||||
<Border x:Name="buttonMute" VerticalAlignment="Bottom" HorizontalAlignment="Right" Cursor="Hand"
|
||||
Margin="10,10" Width="100" Height="100">
|
||||
<Border.Background>
|
||||
<SolidColorBrush Color="Gray" Opacity="0.9"/>
|
||||
<SolidColorBrush Color="Gray" Opacity="0.9" />
|
||||
</Border.Background>
|
||||
<fa:ImageAwesome Icon="VolumeOff"
|
||||
Height="60" Width="60" Foreground="White" />
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using FontAwesome.WPF;
|
||||
@@ -25,7 +26,7 @@ namespace QuickLook.Plugin.VideoViewer
|
||||
buttonMute.MouseLeftButtonUp += (sender, e) =>
|
||||
{
|
||||
mediaElement.IsMuted = false;
|
||||
buttonMute.Visibility = System.Windows.Visibility.Collapsed;
|
||||
buttonMute.Visibility = Visibility.Collapsed;
|
||||
};
|
||||
|
||||
mediaElement.PropertyChanged += ChangePlayPauseButton;
|
||||
|
Reference in New Issue
Block a user