예제 #1
0
        public override void ConvertImage(MagickImage image, double scale, PixelInterpolateMethod pixelInterpolate, DitherMode dither, BitMode bitMode)
        {
            Reset();

            Mode = bitMode;

            int[] size = Utils.LCDSizeToNum((LCDSize)Converter.Instance.LCDSizeSelection.SelectedItem);

            image.InterpolativeResize(size[1] * Y, size[0] * X, pixelInterpolate);

            image.Depth = bitMode == BitMode.Bit3 ? 3 : 5;
            image.Settings.Compression = CompressionMethod.NoCompression;

            if (dither == DitherMode.Riemersma || dither == DitherMode.FloydSteinberg || dither == DitherMode.None)
            {
                image.Quantize(new QuantizeSettings()
                {
                    Colors = bitMode == BitMode.Bit3 ? 8 : 32, DitherMethod = (DitherMethod)dither, ColorSpace = ColorSpace.sRGB, TreeDepth = 100
                });
            }
            else
            {
                image.Quantize(new QuantizeSettings()
                {
                    Colors = bitMode == BitMode.Bit3 ? 8 : 32, DitherMethod = DitherMethod.No, ColorSpace = ColorSpace.sRGB, TreeDepth = 100
                });
                image.OrderedDither(dither.ToString());
            }
        }
        public void ConvertImage(MagickImage image)
        {
            double scale = ImageScaleSlider.Value;

            PixelInterpolateMethod method = (PixelInterpolateMethod)InterpolationSelection.SelectedItem;
            DitherMode             dither = (DitherMode)DitherModeSelection.SelectedItem;
            BitMode mode = (BitMode)BitModeSelection.SelectedItem;

            currentWindow?.ConvertImage(image, scale, method, dither, mode);
        }
예제 #3
0
        public virtual void ConvertImage(MagickImage image, double scale, PixelInterpolateMethod pixelInterpolate, DitherMode dither, BitMode bitMode)
        {
            image.InterpolativeResize(Math.Max(1, (int)(image.Width * scale)), Math.Max(1, (int)(image.Height * scale)), pixelInterpolate);

            if (dither == DitherMode.Riemersma || dither == DitherMode.FloydSteinberg || dither == DitherMode.None)
            {
                image.Quantize(new QuantizeSettings()
                {
                    DitherMethod = (DitherMethod)dither,
                    Colors       = 256,
                    ColorSpace   = ColorSpace.sRGB,
                    TreeDepth    = 100
                });
            }
            else
            {
                image.OrderedDither(dither.ToString());
            }
        }
예제 #4
0
 public void Wave(PixelInterpolateMethod method, double amplitude, double length)
 {
   IntPtr exception = IntPtr.Zero;
   IntPtr result;
   #if ANYCPU
   if (NativeLibrary.Is64Bit)
   #endif
   #if WIN64 || ANYCPU
   result = NativeMethods.X64.MagickImage_Wave(Instance, (UIntPtr)method, amplitude, length, out exception);
   #endif
   #if ANYCPU
   else
   #endif
   #if !WIN64 || ANYCPU
   result = NativeMethods.X86.MagickImage_Wave(Instance, (UIntPtr)method, amplitude, length, out exception);
   #endif
   CheckException(exception, result);
   Instance = result;
 }
예제 #5
0
 public void Swirl(PixelInterpolateMethod method, double degrees)
 {
   IntPtr exception = IntPtr.Zero;
   IntPtr result;
   #if ANYCPU
   if (NativeLibrary.Is64Bit)
   #endif
   #if WIN64 || ANYCPU
   result = NativeMethods.X64.MagickImage_Swirl(Instance, (UIntPtr)method, degrees, out exception);
   #endif
   #if ANYCPU
   else
   #endif
   #if !WIN64 || ANYCPU
   result = NativeMethods.X86.MagickImage_Swirl(Instance, (UIntPtr)method, degrees, out exception);
   #endif
   CheckException(exception, result);
   Instance = result;
 }
예제 #6
0
 public void Polaroid(DrawingSettings settings, string caption, double angle, PixelInterpolateMethod method)
 {
   using (INativeInstance settingsNative = DrawingSettings.CreateInstance(settings))
   {
     using (INativeInstance captionNative = UTF8Marshaler.CreateInstance(caption))
     {
       IntPtr exception = IntPtr.Zero;
       IntPtr result;
       #if ANYCPU
       if (NativeLibrary.Is64Bit)
       #endif
       #if WIN64 || ANYCPU
       result = NativeMethods.X64.MagickImage_Polaroid(Instance, settingsNative.Instance, captionNative.Instance, angle, (UIntPtr)method, out exception);
       #endif
       #if ANYCPU
       else
       #endif
       #if !WIN64 || ANYCPU
       result = NativeMethods.X86.MagickImage_Polaroid(Instance, settingsNative.Instance, captionNative.Instance, angle, (UIntPtr)method, out exception);
       #endif
       CheckException(exception, result);
       Instance = result;
     }
   }
 }
예제 #7
0
 public void Implode(double amount, PixelInterpolateMethod method)
 {
   IntPtr exception = IntPtr.Zero;
   IntPtr result;
   #if ANYCPU
   if (NativeLibrary.Is64Bit)
   #endif
   #if WIN64 || ANYCPU
   result = NativeMethods.X64.MagickImage_Implode(Instance, amount, (UIntPtr)method, out exception);
   #endif
   #if ANYCPU
   else
   #endif
   #if !WIN64 || ANYCPU
   result = NativeMethods.X86.MagickImage_Implode(Instance, amount, (UIntPtr)method, out exception);
   #endif
   CheckException(exception, result);
   Instance = result;
 }
예제 #8
0
 public void Clut(MagickImage image, PixelInterpolateMethod method, Channels channels)
 {
   IntPtr exception = IntPtr.Zero;
   #if ANYCPU
   if (NativeLibrary.Is64Bit)
   #endif
   #if WIN64 || ANYCPU
   NativeMethods.X64.MagickImage_Clut(Instance, MagickImage.GetInstance(image), (UIntPtr)method, (UIntPtr)channels, out exception);
   #endif
   #if ANYCPU
   else
   #endif
   #if !WIN64 || ANYCPU
   NativeMethods.X86.MagickImage_Clut(Instance, MagickImage.GetInstance(image), (UIntPtr)method, (UIntPtr)channels, out exception);
   #endif
   CheckException(exception);
 }