示例#1
0
 public static int Compress(string input, string output, bool progressive, bool lossless, int quality)
 {
     using (INativeInstance inputNative = UTF8Marshaler.CreateInstance(input))
     {
         using (INativeInstance outputNative = UTF8Marshaler.CreateInstance(output))
         {
 #if ANYCPU
             if (NativeLibrary.Is64Bit)
 #endif
 #if WIN64 || ANYCPU
             return((int)NativeMethods.X64.JpegOptimizer_Compress(inputNative.Instance, outputNative.Instance, progressive, lossless, (UIntPtr)quality));
 #endif
 #if ANYCPU
             else
 #endif
 #if !WIN64 || ANYCPU
             return((int)NativeMethods.X86.JpegOptimizer_Compress(inputNative.Instance, outputNative.Instance, progressive, lossless, (UIntPtr)quality));
 #endif
         }
     }
 }
示例#2
0
 public static int Optimize(string input, string output, bool progressive)
 {
     using (INativeInstance inputNative = UTF8Marshaler.CreateInstance(input))
     {
         using (INativeInstance outputNative = UTF8Marshaler.CreateInstance(output))
         {
 #if ANYCPU
             if (NativeLibrary.Is64Bit)
 #endif
 #if WIN64 || ANYCPU
             return((int)NativeMethods.X64.JpegOptimizer_Optimize(inputNative.Instance, outputNative.Instance, progressive));
 #endif
 #if ANYCPU
             else
 #endif
 #if !WIN64 || ANYCPU
             return((int)NativeMethods.X86.JpegOptimizer_Optimize(inputNative.Instance, outputNative.Instance, progressive));
 #endif
         }
     }
 }
示例#3
0
 public int PageCount(string fileName)
 {
     using (INativeInstance fileNameNative = UTF8Marshaler.CreateInstance(fileName))
     {
         IntPtr  exception = IntPtr.Zero;
         UIntPtr result;
         #if PLATFORM_AnyCPU
         if (OperatingSystem.Is64Bit)
         #endif
         #if PLATFORM_x64 || PLATFORM_AnyCPU
         result = NativeMethods.X64.PdfInfo_PageCount(fileNameNative.Instance, out exception);
         #endif
         #if PLATFORM_AnyCPU
         else
         #endif
         #if PLATFORM_x86 || PLATFORM_AnyCPU
         result = NativeMethods.X86.PdfInfo_PageCount(fileNameNative.Instance, out exception);
         #endif
         CheckException(exception);
         return((int)result);
     }
 }
示例#4
0
 public void CompressFile(string input, string output, bool progressive, bool lossless, int quality)
 {
     using (INativeInstance inputNative = UTF8Marshaler.CreateInstance(input))
     {
         using (INativeInstance outputNative = UTF8Marshaler.CreateInstance(output))
         {
             IntPtr exception = IntPtr.Zero;
             #if PLATFORM_AnyCPU
             if (NativeLibrary.Is64Bit)
             #endif
             #if PLATFORM_x64 || PLATFORM_AnyCPU
             NativeMethods.X64.JpegOptimizer_CompressFile(inputNative.Instance, outputNative.Instance, progressive, lossless, (UIntPtr)quality, out exception);
             #endif
             #if PLATFORM_AnyCPU
             else
             #endif
             #if PLATFORM_x86 || PLATFORM_AnyCPU
             NativeMethods.X86.JpegOptimizer_CompressFile(inputNative.Instance, outputNative.Instance, progressive, lossless, (UIntPtr)quality, out exception);
             #endif
             CheckException(exception);
         }
     }
 }