/// <summary> Gets or sets the color of the background. </summary> /// <value> The color of the background. </value> /*private PixelWand BackgroundColor * { * /* NOT WORKINGget * { * IntPtr background = MagickWandInterop.MagickGetBackgroundColor(this); * return new PixelWand(background); * }*/ /*set { this.CheckError(MagickWandInterop.MagickSetBackgroundColor(this, value)); } * }*/ #endregion #region [Magick Wand Methods] /// <summary> Clone magick wand. </summary> /// <returns> A MagickWand. </returns> public MagickWand CloneMagickWand() { MagickWand wand = new MagickWand(MagickWandInterop.CloneMagickWand(this)); wand.ReloadImageList(); return(wand); }
/// <summary> Gets or sets the size of the page. </summary> /// <value> The size of the page. </value> /*private WandRectangle PageSize * { * get * { * int width; * int height; * int x; * int y; * MagickWandInterop.MagickGetPage(this, out width, out height, out x, out y); * return new WandRectangle(x, y, width, height); * } * set * { * MagickWandInterop.MagickSetPage(this, value.Width, value.Height, value.X, value.Y); * } * } * * /// <summary> Combine images. </summary> * /// <param name="channel"> The channel. </param> * /// <returns> A MagickWand. </returns> * private MagickWand CombineImages(int channel) * { * MagickWand wand = new MagickWand(MagickWandInterop.MagickCombineImages(this, channel)); * wand.ReloadImageList(); * return wand; * } * * /// <summary> Merge image layers. </summary> * /// <param name="method"> The method. </param> * /// <returns> A MagickWand. </returns> * private MagickWand MergeImageLayers(ImageLayerType method) * { * MagickWand wand = new MagickWand(MagickWandInterop.MagickMergeImageLayers(this, method)); * wand.ReloadImageList(); * return wand; * }*/ /// <summary> Appends the images. </summary> /// <param name="stack"> true to stack. </param> /// <returns> A MagickWand. </returns> public MagickWand AppendImages(bool stack = false) { this.ResetIterator(); MagickWand wand = new MagickWand(MagickWandInterop.MagickAppendImages(this, stack)); wand.ReloadImageList(); return(wand); }
/// <summary> /// Releases the unmanaged resources used by the ImageMagickSharp.MagickWand and optionally /// releases the managed resources. </summary> /// <param name="disposing"> true to release both managed and unmanaged resources; false to /// release only unmanaged resources. </param> protected virtual void Dispose(bool disposing) { if (this.Handle != IntPtr.Zero) { this.Handle = MagickWandInterop.DestroyMagickWand(this); this.Handle = IntPtr.Zero; } }
/// <summary> /// MagickPingImage() is like MagickReadImage() except the only valid information returned is the /// image width, height, size, and format. It is designed to efficiently obtain this information /// from a file without reading the entire image sequence into memory. </summary> /// <param name="file_name"> Filename of the file. </param> /// <returns> true if it succeeds, false if it fails. </returns> public bool PingImage(string path) { bool checkErrorBool = this.CheckErrorBool(MagickWandInterop.MagickPingImage(this, path)); if (checkErrorBool) { this._ImageList.Add(new ImageWand(this, this.IteratorIndex)); } return(checkErrorBool); }
public MagickWand(int width, int height) { Wand.EnsureInitialized(); this.Handle = MagickWandInterop.NewMagickWand(); if (this.Handle == IntPtr.Zero) { throw new Exception("Error acquiring wand."); } this.Size = new WandSize(width, height); }
public MagickWand(params string[] paths) { Wand.EnsureInitialized(); this.Handle = MagickWandInterop.NewMagickWand(); if (this.Handle == IntPtr.Zero) { throw new Exception("Error acquiring wand."); } this.OpenImages(paths); }
/// <summary> Initializes a new instance of the ImageMagickSharp.MagickWand class. </summary> /// <exception cref="Exception"> Thrown when an exception error condition occurs. </exception> /// <param name="width"> The width. </param> /// <param name="height"> The height. </param> /// <param name="pixelWand"> The pixel wand. </param> public MagickWand(int width, int height, PixelWand pixelWand) { Wand.EnsureInitialized(); this.Handle = MagickWandInterop.NewMagickWand(); if (this.Handle == IntPtr.Zero) { throw new Exception("Error acquiring wand."); } this.NewImage(width, height, pixelWand); }
/// <summary> Adds an image. </summary> /// <param name="wand"> The wand. </param> /// <returns> true if it succeeds, false if it fails. </returns> public bool AddImage(MagickWand wand, bool prepent = false) { if (prepent) { this.SetFirstIterator(); } else { this.SetLastIterator(); } bool result = this.CheckError(MagickWandInterop.MagickAddImage(this, wand)); this.ReloadImageList(); return(result); }
/// <summary> Queries font metrics. </summary> /// <param name="drawing_wand"> The drawing wand. </param> /// <param name="text"> The text. </param> /// <param name="multiline"> true to multiline. </param> /// <returns> The font metrics. </returns> public FontMetrics QueryFontMetrics(IntPtr drawing_wand, string text, bool multiline = false) { double[] rowArray = new double[13]; // TODO: Memory leak IntPtr metrics; if (multiline) { metrics = MagickWandInterop.MagickQueryMultilineFontMetrics(this, drawing_wand, text); } else { metrics = MagickWandInterop.MagickQueryFontMetrics(this, drawing_wand, text); } Marshal.Copy(metrics, rowArray, 0, 13); return(new FontMetrics(rowArray)); }
/// <summary> Loads. </summary> /// <param name="pointer"> The pointer. </param> /// <param name="relinquish"> true to relinquish. </param> /// <returns> A string. </returns> internal static string Load(IntPtr pointer, bool relinquish = true) { List <byte> bytes = new List <byte>(); byte[] buf = new byte[1]; int index = 0; while (true) { Marshal.Copy(pointer + index, buf, 0, 1); if (buf[0] == 0) { break; } bytes.Add(buf[0]); ++index; } if (relinquish) { MagickWandInterop.MagickRelinquishMemory(pointer); } return(Encoding.UTF8.GetString(bytes.ToArray())); }
/// <summary> /// ClearMagickWand() clears resources associated with the wand, leaving the wand blank, and /// ready to be used for a new set of images. </summary> /*private void ClearMagickWand() * { * MagickWandInterop.ClearMagickWand(this); * this._ImageList.Clear(); * }*/ #endregion #region [Magick Wand Methods - Image] /// <summary> Creates a new image. </summary> /// <param name="width"> The width. </param> /// <param name="height"> The height. </param> /// <param name="pixelWand"> The pixel wand. </param> private void NewImage(int width, int height, PixelWand pixelWand) { this.CheckError(MagickWandInterop.MagickNewImage(this, width, height, pixelWand)); this._ImageList.Add(new ImageWand(this, this.IteratorIndex)); }
/// <summary> Clears the exception. </summary> /// <returns> An IntPtr. </returns> public override void ClearException() { MagickWandInterop.MagickClearException(this); }
/// <summary> Determines if we can next image. </summary> /// <returns> true if it succeeds, false if it fails. </returns> /*private bool NextImage() * { * return this.CheckError(MagickWandInterop.MagickNextImage(this)); * } * * /// <summary> Determines if we can previous image. </summary> * /// <returns> true if it succeeds, false if it fails. </returns> * private bool PreviousImage() * { * return this.CheckError(MagickWandInterop.MagickPreviousImage(this)); * }*/ #endregion #region [Private Methods] #endregion #region [Wand Methods - Exception] /// <summary> Gets the exception. </summary> /// <returns> The exception. </returns> public override IntPtr GetException(out int exceptionSeverity) { IntPtr exceptionPtr = MagickWandInterop.MagickGetException(this, out exceptionSeverity); return(exceptionPtr); }
/// <summary> Gets number images. </summary> /// <returns> The number images. </returns> private int GetNumberImages() { return((int)MagickWandInterop.MagickGetNumberImages(this)); }
private void SetLastIterator() { MagickWandInterop.MagickSetLastIterator(this); }
/// <summary> Gets the image. </summary> /// <returns> The image. </returns> internal MagickWand GetImage() { return(new MagickWand(MagickWandInterop.MagickGetImage(this))); }
/// <summary> Sets first iterator. </summary> public void SetFirstIterator() { MagickWandInterop.MagickSetFirstIterator(this); }
/// <summary> Gets a value indicating whether this object has next image. </summary> /// <value> true if this object has next image, false if not. </value> /*private bool HasNextImage * { * get { return this.CheckError(MagickWandInterop.MagickHasNextImage(this)); } * } * * /// <summary> Gets a value indicating whether this object has previous image. </summary> * /// <value> true if this object has previous image, false if not. </value> * private bool HasPreviousImage * { * get { return this.CheckError(MagickWandInterop.MagickHasPreviousImage(this)); } * } * * /// <summary> Iterator set image. </summary> * /// <param name="source"> Source for the. </param> * /// <param name="target"> Target for the. </param> * private void IteratorSetImage(MagickWand target) * { * this.CheckError(MagickWandInterop.MagickSetImage(this, target.Handle)); * }*/ /// <summary> Resets the iterator. </summary> private void ResetIterator() { MagickWandInterop.MagickResetIterator(this); }
/// <summary> Initializes a new instance of the ImageMagickSharp.MagickWand class. </summary> private MagickWand() { Wand.EnsureInitialized(); this.Handle = MagickWandInterop.NewMagickWand(); }
/// <summary> Saves the images. </summary> /// <param name="path"> Full pathname of the file. </param> /// <param name="adjoin"> true to adjoin. </param> public void SaveImages(string path, bool adjoin = false) { this.CheckError(MagickWandInterop.MagickWriteImages(this, path, adjoin)); }
/// <summary> Removes the image. </summary> /// <returns> true if it succeeds, false if it fails. </returns> /*private bool RemoveImage() * { * bool checkErrorBool = this.CheckErrorBool(MagickWandInterop.MagickRemoveImage(this)); * if (checkErrorBool) * this._ImageList.RemoveAt(this.IteratorIndex); * return checkErrorBool; * }*/ /// <summary> Removes the image. </summary> /// <param name="indexs"> A variable-length parameters list containing indexs. </param> /*private void RemoveImage(params int[] indexs) * { * foreach (int index in indexs) * { * this.IteratorIndex = index; * this.RemoveImage(); * } * }*/ /// <summary> Saves an image. </summary> /// <param name="path"> Full pathname of the file. </param> public void SaveImage(string path) { this.CheckError(MagickWandInterop.MagickWriteImage(this, path)); }