Esempio n. 1
0
 public NativeDrawingWand(MagickImage image, DrawingSettings settings)
 {
   using (INativeInstance settingsNative = DrawingSettings.CreateInstance(settings))
   {
     #if ANYCPU
     if (NativeLibrary.Is64Bit)
     #endif
     #if WIN64 || ANYCPU
     Instance = NativeMethods.X64.DrawingWand_Create(MagickImage.GetInstance(image), settingsNative.Instance);
     #endif
     #if ANYCPU
     else
     #endif
     #if !WIN64 || ANYCPU
     Instance = NativeMethods.X86.DrawingWand_Create(MagickImage.GetInstance(image), settingsNative.Instance);
     #endif
     if (Instance == IntPtr.Zero)
       throw new InvalidOperationException();
   }
 }
Esempio n. 2
0
    internal MagickSettings()
    {
      using (NativeMagickSettings instance = new NativeMagickSettings())
      {
        BackgroundColor = instance.BackgroundColor;
        ColorSpace = instance.ColorSpace;
        ColorType = instance.ColorType;
        CompressionMethod = instance.CompressionMethod;
        Debug = instance.Debug;
        Density = Density.Create(instance.Density);
        Endian = instance.Endian;
        _Font = instance.Font;
        _FontPointsize = instance.FontPointsize;
        Format = EnumHelper.Parse(instance.Format, MagickFormat.Unknown);
        Interlace = instance.Interlace;
        Monochrome = instance.Monochrome;
        Verbose = instance.Verbose;
      }

      Drawing = new DrawingSettings();
    }
Esempio n. 3
0
    internal DrawingSettings Clone()
    {
      DrawingSettings clone = new DrawingSettings();
      clone.BorderColor = MagickColor.Clone(BorderColor);
      clone.FillColor = MagickColor.Clone(FillColor);
      clone.FillRule = FillRule;
      clone.Font = Font;
      clone.FontFamily = FontFamily;
      clone.FontPointsize = FontPointsize;
      clone.FontStyle = FontStyle;
      clone.FontWeight = FontWeight;
      clone.StrokeAntiAlias = StrokeAntiAlias;
      clone.StrokeColor = MagickColor.Clone(StrokeColor);
      clone.StrokeDashOffset = StrokeDashOffset;
      clone.StrokeLineCap = StrokeLineCap;
      clone.StrokeLineJoin = StrokeLineJoin;
      clone.StrokeMiterLimit = StrokeMiterLimit;
      clone.StrokeWidth = StrokeWidth;
      clone.TextAntiAlias = TextAntiAlias;
      clone.TextDirection = TextDirection;
      clone.TextEncoding = TextEncoding;
      clone.TextGravity = TextGravity;
      clone.TextInterlineSpacing = TextInterlineSpacing;
      clone.TextInterwordSpacing = TextInterwordSpacing;
      clone.TextKerning = TextKerning;
      clone.TextUnderColor = MagickColor.Clone(TextUnderColor);

      clone.Affine = Affine;
      clone.FillPattern = MagickImage.Clone(FillPattern);
      clone._StrokeDashArray = _StrokeDashArray != null ? (double[])_StrokeDashArray.Clone() : null;
      clone.StrokePattern = MagickImage.Clone(StrokePattern);
      clone.Text = Text;

      return clone;
    }
Esempio n. 4
0
 private MagickSettings(NativeMagickSettings instance)
 {
     _NativeInstance = instance;
     Drawing         = new DrawingSettings();
 }
Esempio n. 5
0
 internal static INativeInstance CreateInstance(DrawingSettings instance)
 {
   if (instance == null)
     return NativeInstance.Zero;
   return instance.CreateNativeInstance();
 }
Esempio n. 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;
     }
   }
 }
Esempio n. 7
0
 public IntPtr FontTypeMetrics(DrawingSettings settings, bool ignoreNewLines)
 {
   using (INativeInstance settingsNative = DrawingSettings.CreateInstance(settings))
   {
     IntPtr exception = IntPtr.Zero;
     IntPtr result;
     #if ANYCPU
     if (NativeLibrary.Is64Bit)
     #endif
     #if WIN64 || ANYCPU
     result = NativeMethods.X64.MagickImage_FontTypeMetrics(Instance, settingsNative.Instance, ignoreNewLines, out exception);
     #endif
     #if ANYCPU
     else
     #endif
     #if !WIN64 || ANYCPU
     result = NativeMethods.X86.MagickImage_FontTypeMetrics(Instance, settingsNative.Instance, ignoreNewLines, out exception);
     #endif
     MagickException magickException = MagickExceptionHelper.Create(exception);
     if (MagickExceptionHelper.IsError(magickException))
     {
       if (result != IntPtr.Zero)
         ImageMagick.TypeMetric.Dispose(result);
       throw magickException;
     }
     RaiseWarning(magickException);
     return result;
   }
 }
Esempio n. 8
0
 public void FloodFill(DrawingSettings settings, int x, int y, MagickColor target, bool invert)
 {
   using (INativeInstance settingsNative = DrawingSettings.CreateInstance(settings))
   {
     using (INativeInstance targetNative = MagickColor.CreateInstance(target))
     {
       IntPtr exception = IntPtr.Zero;
       #if ANYCPU
       if (NativeLibrary.Is64Bit)
       #endif
       #if WIN64 || ANYCPU
       NativeMethods.X64.MagickImage_FloodFill(Instance, settingsNative.Instance, (IntPtr)x, (IntPtr)y, targetNative.Instance, invert, out exception);
       #endif
       #if ANYCPU
       else
       #endif
       #if !WIN64 || ANYCPU
       NativeMethods.X86.MagickImage_FloodFill(Instance, settingsNative.Instance, (IntPtr)x, (IntPtr)y, targetNative.Instance, invert, out exception);
       #endif
       CheckException(exception);
     }
   }
 }
Esempio n. 9
0
 public void AnnotateGravity(DrawingSettings settings, string text, Gravity gravity)
 {
   using (INativeInstance settingsNative = DrawingSettings.CreateInstance(settings))
   {
     using (INativeInstance textNative = UTF8Marshaler.CreateInstance(text))
     {
       IntPtr exception = IntPtr.Zero;
       #if ANYCPU
       if (NativeLibrary.Is64Bit)
       #endif
       #if WIN64 || ANYCPU
       NativeMethods.X64.MagickImage_AnnotateGravity(Instance, settingsNative.Instance, textNative.Instance, (UIntPtr)gravity, out exception);
       #endif
       #if ANYCPU
       else
       #endif
       #if !WIN64 || ANYCPU
       NativeMethods.X86.MagickImage_AnnotateGravity(Instance, settingsNative.Instance, textNative.Instance, (UIntPtr)gravity, out exception);
       #endif
       CheckException(exception);
     }
   }
 }