Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GifDecoder"/> class.
        /// </summary>
        /// <param name="image">The image to decode.</param>
        public GifDecoder(Gif image)
        {
            this.image            = image;
            this.ActiveFrameIndex = 0;

            if (ImageAnimator.CanAnimate(image))
            {
                this.IsAnimated = true;
                this.FrameCount = image.Image.GetFrameCount(FrameDimension.Time);
                const int LoopCount  = (int)ExifPropertyTag.LoopCount;
                const int FrameDelay = (int)ExifPropertyTag.FrameDelay;

                // Loop info is stored at byte 20737. Default to infinite loop if not found.
                this.LoopCount = Array.IndexOf(image.Image.PropertyIdList, LoopCount) != -1
                    ? BitConverter.ToInt16(image.Image.GetPropertyItem(LoopCount).Value, 0)
                    : 0;

                // Get the times stored in the gif. Default to 0 if not found.
                if (Array.IndexOf(this.image.Image.PropertyIdList, FrameDelay) != -1)
                {
                    this.times = this.image.Image.GetPropertyItem(FrameDelay).Value;
                }
            }
            else
            {
                this.FrameCount = 1;
            }
        }
Exemple #2
0
        /// <summary>
        /// Loads an iamge using the standard method.
        /// </summary>
        /// <param name="path">The path to the file.</param>
        protected void LoadSafe(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            Clear();
            this.Image = IMAGE.StandardLoad(path);
        }
Exemple #3
0
 /// <summary>
 /// Loads a BMP image and returns it as a bitmap object.
 /// </summary>
 /// <param name="path">The path of the image.</param>
 /// <returns>A <see cref="Bitmap"/> object.</returns>
 public static Bitmap FromFileAsBitmap(string path)
 {
     try
     {
         return(IMAGE.StandardLoad(path));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message + "\r\nIn BMP.FromFileAsBitmap(string)");
     }
 }
Exemple #4
0
 /// <summary>
 /// Loads a ICO image and returns it as a bitmap object.
 /// </summary>
 /// <param name="path">The path of the image.</param>
 /// <returns>A <see cref="Bitmap"/> object.</returns>
 public static Bitmap FromFileAsBitmap(string path)
 {
     try
     {
         Bitmap bmp = IMAGE.StandardLoad(path);
         ImageHelper.RotateImageByExifOrientationData(bmp);
         return(bmp);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message + "\r\nIn ICO.FromFileAsBitmap(string)");
     }
 }