예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
 /// <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;
     }
 }
예제 #4
0
        /// <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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        /// <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);
        }
예제 #8
0
        /// <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);
        }
예제 #9
0
        /// <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));
        }
예제 #10
0
        /// <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()));
        }
예제 #11
0
        /// <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));
        }
예제 #12
0
 /// <summary> Clears the exception. </summary>
 /// <returns> An IntPtr. </returns>
 public override void ClearException()
 {
     MagickWandInterop.MagickClearException(this);
 }
예제 #13
0
        /// <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);
        }
예제 #14
0
 /// <summary> Gets number images. </summary>
 /// <returns> The number images. </returns>
 private int GetNumberImages()
 {
     return((int)MagickWandInterop.MagickGetNumberImages(this));
 }
예제 #15
0
 private void SetLastIterator()
 {
     MagickWandInterop.MagickSetLastIterator(this);
 }
예제 #16
0
 /// <summary> Gets the image. </summary>
 /// <returns> The image. </returns>
 internal MagickWand GetImage()
 {
     return(new MagickWand(MagickWandInterop.MagickGetImage(this)));
 }
예제 #17
0
 /// <summary> Sets first iterator. </summary>
 public void SetFirstIterator()
 {
     MagickWandInterop.MagickSetFirstIterator(this);
 }
예제 #18
0
        /// <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);
        }
예제 #19
0
 /// <summary> Initializes a new instance of the ImageMagickSharp.MagickWand class. </summary>
 private MagickWand()
 {
     Wand.EnsureInitialized();
     this.Handle = MagickWandInterop.NewMagickWand();
 }
예제 #20
0
 /// <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));
 }
예제 #21
0
        /// <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));
        }