Example #1
0
        //-------------------------------------------------------------------------------
        //
        public ImageAnimation(Image img)
        {
            _image = img;
            FrameDimension = new FrameDimension(img.FrameDimensionsList[0]);
            MaxFrameCount = img.GetFrameCount(FrameDimension);
            PropertyItem pItemFrameDelay = img.GetPropertyItem(FRAME_DELAY);
            PropertyItem pItemFrameNum = img.GetPropertyItem(FRAME_NUM);
            FrameDelays = new int[MaxFrameCount];

            for (int i = 0; i < MaxFrameCount; i++) {
                FrameDelays[i] = BitConverter.ToInt32(pItemFrameDelay.Value, 4 * i);
            }
            MaxLoopCount = BitConverter.ToInt16(pItemFrameNum.Value, 0);

            LoopInfinity = (MaxLoopCount == 0);

            _timer = new Timer(Timer_Elapsed, null, Timeout.Infinite, Timeout.Infinite);
            try {
                _image.SelectActiveFrame(FrameDimension, 0);
            }
            catch (InvalidOperationException/* ex*/) {
                //Log.DebugLog(ex);
                //Debug.Assert(false, "Image.SelectActiveFrame失敗");
            }
        }
 public AnimatedImage(Image Image)
 {
     gifImage = Image; //initialize
     dimension = new FrameDimension(gifImage.FrameDimensionsList[0]); //gets the GUID
     frameCount = gifImage.GetFrameCount(dimension); //total frames in the animation
     _timer.Elapsed += new System.Timers.ElapsedEventHandler(_timer_Elapsed);
 }
 public PagingImage(string filename)
 {
     _filename = filename;
     img = Bitmap.FromFile(filename);
     _pages = img.GetFrameCount(FrameDimension.Page);
     img.Dispose();
 }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="stream"></param>
        public GifReader(Stream stream)
        {
            _gifImage = Image.FromStream(stream); //initialize

            _dimension = new FrameDimension(_gifImage.FrameDimensionsList[0]); //gets the GUID
            _frameCount = _gifImage.GetFrameCount(_dimension); //total frames in the animation
        }
            /// <devdoc> 
            /// </devdoc>  
            public ImageInfo(Image image) {
                this.image = image;
                animated = ImageAnimator.CanAnimate(image);

                if (animated) {
                    frameCount = image.GetFrameCount(FrameDimension.Time);

                    PropertyItem frameDelayItem = image.GetPropertyItem(PropertyTagFrameDelay);

                    // If the image does not have a frame delay, we just return 0.                                     
                    //
                    if (frameDelayItem != null) {
                        // Convert the frame delay from byte[] to int
                        //
                        byte[] values = frameDelayItem.Value;
                        Debug.Assert(values.Length == 4 * FrameCount, "PropertyItem has invalid value byte array");
                        frameDelay = new int[FrameCount];
                        for (int i=0; i < FrameCount; ++i) {
                            frameDelay[i] = values[i * 4] + 256 * values[i * 4 + 1] + 256 * 256 * values[i * 4 + 2] + 256 * 256 * 256 * values[i * 4 + 3];
                        }
                    }
                }
                else {
                    frameCount = 1;
                }
                if (frameDelay == null) {
                    frameDelay = new int[FrameCount];
                }
            }                                               
Example #6
0
 public GifImage(Image path)
 {
     gifImage = path;
     //initialize
     dimension = new FrameDimension(gifImage.FrameDimensionsList[0]);
     //gets the GUID
     //total frames in the animation
     frameCount = gifImage.GetFrameCount(dimension);
 }
Example #7
0
		public GifHandler( Image Image ) {
			mImage = Image.Clone() as Image;
			mFrameDimension = new FrameDimension( mImage.FrameDimensionsList[ 0 ] );
			mFrameCount = mImage.GetFrameCount( mFrameDimension );

			mFrameTimes = new int[ mFrameCount ];
			byte[] times = mImage.GetPropertyItem( 0x5100 ).Value;
			for( int i = 0; i < mFrameCount; i++ )
				mFrameTimes[ i ] = BitConverter.ToInt32( times, 4 * i ) * 10;
		}
Example #8
0
        private void GifBox(Image gif, PictureBox pic)
        {
            FrameDimension fd = new FrameDimension(gif.FrameDimensionsList[0]);
            int count = gif.GetFrameCount(System.Drawing.Imaging.FrameDimension.Time);

            for (int i = 0; i < count; i++)
            {
                gif.SelectActiveFrame(fd, i);
                pic.Image = gif;
            }
        }
Example #9
0
        /// <summary>   
        /// 实例化一个AnimateImage。   
        /// </summary>   
        /// <param name="img">动画图片。</param>   
        public AnimateImage(Image img) {
            image = img;

            lock (image) {
                mCanAnimate = ImageAnimator.CanAnimate(image);
                if (mCanAnimate) {
                    Guid[] guid = image.FrameDimensionsList;
                    frameDimension = new FrameDimension(guid[0]);
                    mFrameCount = image.GetFrameCount(frameDimension);
                }
            }
        }
Example #10
0
        public GifImage(string path)
        {
            _lastRequest = DateTime.Now;
            _gifImage = Image.FromFile(path); //initialize
            _dimension = new FrameDimension(_gifImage.FrameDimensionsList[0]); //gets the GUID
            FrameCount = _gifImage.GetFrameCount(_dimension); //total frames in the animation

            Source = path;

            var item = _gifImage.GetPropertyItem(0x5100); // FrameDelay in libgdiplus
            _delay = (item.Value[0] + item.Value[1]*256)*10; // Time is in 1/100th of a second
        }
Example #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GifDecoder"/> class.
        /// </summary>
        /// <param name="image">
        /// The <see cref="Image"/> to decode.
        /// </param>
        public GifDecoder(Image image)
        {
            this.Height = image.Height;
            this.Width = image.Width;

            if (FormatUtilities.IsAnimated(image))
            {
                this.IsAnimated = true;

                if (this.IsAnimated)
                {
                    int frameCount = image.GetFrameCount(FrameDimension.Time);
                    int last = frameCount - 1;
                    double length = 0;

                    List<GifFrame> gifFrames = new List<GifFrame>();

                    // Get the times stored in the gif.
                    byte[] times = image.GetPropertyItem((int)ExifPropertyTag.FrameDelay).Value;

                    for (int i = 0; i < frameCount; i++)
                    {
                        // Convert each 4-byte chunk into an integer.
                        // GDI returns a single array with all delays, while Mono returns a different array for each frame.
                        TimeSpan delay = TimeSpan.FromMilliseconds(BitConverter.ToInt32(times, (4 * i) % times.Length) * 10);

                        // Find the frame
                        image.SelectActiveFrame(FrameDimension.Time, i);
                        Bitmap frame = new Bitmap(image);
                        frame.SetResolution(image.HorizontalResolution, image.VerticalResolution);
                        
                        // TODO: Get positions.
                        gifFrames.Add(new GifFrame { Delay = delay, Image = frame });

                        // Reset the position.
                        if (i == last)
                        {
                            image.SelectActiveFrame(FrameDimension.Time, 0);
                        }

                        length += delay.TotalMilliseconds;
                    }

                    this.GifFrames = gifFrames;
                    this.AnimationLength = length;

                    // Loop info is stored at byte 20737.
                    this.LoopCount = BitConverter.ToInt16(image.GetPropertyItem((int)ExifPropertyTag.LoopCount).Value, 0);
                    this.IsLooped = this.LoopCount != 1;
                }
            }
        }
Example #12
0
 public static bool IsGIFAnimation(Image image)
 {
     System.Guid[] frameDimensionsList = image.FrameDimensionsList;
     for (int i = 0; i < frameDimensionsList.Length; i++)
     {
         System.Guid guid = frameDimensionsList[i];
         FrameDimension dimension = new FrameDimension(guid);
         if (image.GetFrameCount(dimension) > 1)
         {
             return true;
         }
     }
     return false;
 }
Example #13
0
        public static Bitmap GetStackImage(Image image, int count, Item item) {
            if (image == null) return new Bitmap(item.image);
            int max = image.GetFrameCount(FrameDimension.Time);
            int index = 0;

            if (count <= 5) index = count - 1;
            else if (count <= 10) index = 5;
            else if (count <= 25) index = 6;
            else if (count <= 50) index = 7;
            else index = 8;

            if (index >= max) index = max - 1;
            image.SelectActiveFrame(FrameDimension.Time, index);
            return new Bitmap((Image)image.Clone());
        }
Example #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GifDecoder"/> class.
        /// </summary>
        /// <param name="image">
        /// The <see cref="Image"/> to decode.
        /// </param>
        /// <param name="animationProcessMode">
        /// The <see cref="AnimationProcessMode" /> to use.
        /// </param>
        public GifDecoder(Image image, AnimationProcessMode animationProcessMode)
        {
            this.Height = image.Height;
            this.Width = image.Width;

            if (FormatUtilities.IsAnimated(image) && animationProcessMode == AnimationProcessMode.All)
            {
                this.IsAnimated = true;
                this.FrameCount = image.GetFrameCount(FrameDimension.Time);

                // Loop info is stored at byte 20737.
                this.LoopCount = BitConverter.ToInt16(image.GetPropertyItem((int)ExifPropertyTag.LoopCount).Value, 0);
            }
            else
            {
                this.FrameCount = 1;
            }
        }
Example #15
0
        //-------------------------------------------------------------------------------
        //
        public ImageAnimation(Image img)
        {
            _image = img;
            FrameDimension = new FrameDimension(img.FrameDimensionsList[0]);
            MaxFrameCount = img.GetFrameCount(FrameDimension);
            PropertyItem pItemFrameDelay = img.GetPropertyItem(FRAME_DELAY);
            PropertyItem pItemFrameNum = img.GetPropertyItem(FRAME_NUM);
            FrameDelays = new int[MaxFrameCount];

            for (int i = 0; i < MaxFrameCount; i++) {
                FrameDelays[i] = BitConverter.ToInt32(pItemFrameDelay.Value, 4 * i);
            }
            MaxLoopCount = BitConverter.ToInt16(pItemFrameNum.Value, 0);

            LoopInfinity = (MaxLoopCount == 0);

            _timer = new Timer(Timer_Elapsed, null, Timeout.Infinite, Timeout.Infinite);
            _image.SelectActiveFrame(FrameDimension, 0);
        }
Example #16
0
        private void btnOpenImage_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = "All Supported Images(*.BMP,*.PNG,*.JPEG,*.JPG,*.JPE,*.JFIF,*.TIF,*.TIFF,*.GIF)|*.BMP;*.PNG;*.JPEG;*.JPG;*.JPE;*.JFIF;*.TIF;*.TIFF;*.GIF|JPEG|*.JPG;*.JPEG;*.JPE;*.JFIF|BMP|*.BMP|PNG|*.PNG|TIFF|*.TIF;*.TIFF|GIF|*.GIF";
                dlg.InitialDirectory = lastOpenedDirectory;
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    lastOpenedDirectory = System.IO.Directory.GetParent(dlg.FileName).FullName;
                    if (m_data != null)
                    {
                        m_data.Dispose();
                        m_data = null;
                        iPageCount = 0;
                    }
                    m_results.Clear();
                    tbResults.Clear();

                    this.Text = dlg.FileName;

                    filePath = dlg.FileName;

                    m_data = Image.FromFile(filePath);
                    if (m_data.RawFormat.Equals(ImageFormat.Gif))
                        iPageCount = 1;
                    else
                    {
                        iPageCount = m_data.GetFrameCount(new FrameDimension(m_data.FrameDimensionsList[0]));
                    }

                    if (iPageCount > 0 && iCheckedFormatCount > 0)
                        btnRead.Enabled = true;
                    CurrentIndex = iPageCount - 1;
                    tbxTotalImageNum.Text = iPageCount.ToString();
                    if (iPageCount > 1)
                    {
                        EnableControls(picboxFirst);
                        EnableControls(picboxPrevious);
                        //EnableControls(picboxNext);
                        //EnableControls(picboxLast);
                    }
                    else
                    {
                        DisableControls(picboxFirst);
                        DisableControls(picboxPrevious);
                        DisableControls(picboxNext);
                        DisableControls(picboxLast);
                    }
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message, "Barcode Reader Demo", MessageBoxButtons.OK);
            }
        }
Example #17
0
        private void loadImage(Guid guid)
        {
            try
            {
                this.Show();
                if (_strFilePath == null)
                {
                    ultraToolbarsManagerStandard.Tools["PdfConvert"].SharedProps.Enabled = false;
                    ultraToolbarsManagerStandard.Tools["Delete"].SharedProps.Enabled = false;
                    ultraToolbarsManagerStandard.Tools["ZoomIn"].SharedProps.Enabled = false;
                    ultraToolbarsManagerStandard.Tools["ZoomOut"].SharedProps.Enabled = false;
                    ultraToolbarsManagerStandard.Tools["RotateLeft"].SharedProps.Enabled = false;
                    ultraToolbarsManagerStandard.Tools["RotateRight"].SharedProps.Enabled = false;
                    if (_ultraToolbarAttivita != null)
                    {
                        _ultraToolbarAttivita.Visible = false;
                        _ultraMenuAttivita.SharedProps.Visible = false;
                    }
                }
                else
                {
                    ultraToolbarsManagerStandard.Tools["PdfConvert"].SharedProps.Enabled = true;
                    ultraToolbarsManagerStandard.Tools["Delete"].SharedProps.Enabled = true;
                    ultraToolbarsManagerStandard.Tools["ZoomIn"].SharedProps.Enabled = true;
                    ultraToolbarsManagerStandard.Tools["ZoomOut"].SharedProps.Enabled = true;
                    ultraToolbarsManagerStandard.Tools["RotateLeft"].SharedProps.Enabled = true;
                    ultraToolbarsManagerStandard.Tools["RotateRight"].SharedProps.Enabled = true;
                    if (_ultraToolbarAttivita != null)
                    {
                        _ultraToolbarAttivita.Visible = true;
                        _ultraMenuAttivita.SharedProps.Visible = true;
                    }

                    _imageGuid = guid;
                    picBoxSize();

                    // Changed the cursor to waitCursor
                    Cursor = System.Windows.Forms.Cursors.WaitCursor;
                    // Sets the tiff file as an image object.
                    _objImage = System.Drawing.Image.FromFile(_strFilePath);
                    Guid objGuid = _objImage.FrameDimensionsList[0];
                    System.Drawing.Imaging.FrameDimension objDimension = new System.Drawing.Imaging.FrameDimension(objGuid);

                    //Gets the total number of frames in the .tiff file
                    _totFrame = _objImage.GetFrameCount(objDimension);
                    if (_totFrame > 1)
                        base.ultraToolbarsManagerStandard.Tools["Next"].SharedProps.Enabled = true;

                    //Adds number of frames to the combo box for displaying purposes.
                    _cboFrameNo.ResetValueList();
                    for (int i = 1; i <= _totFrame; i++)
                    {
                        _cboFrameNo.ValueList.ValueListItems.Add(new Infragistics.Win.ValueListItem(i, i.ToString()));
                    }

                    //Sets the temporary folder
                    _strPath = System.IO.Path.GetTempPath() + "FaxGest\\";

                    //Saves every frame as a seperate file.
                    _curF = 0;
                    for (int z = 0; z < _totFrame; z++)
                    {
                        _objImage.SelectActiveFrame(objDimension, _curF);
                        _objImage.Save(_strPath + _imageGuid + "_" + _curF + ".tif", System.Drawing.Imaging.ImageFormat.Tiff);
                        _curF++;
                    }
                    _curF = 0;

                    // Displayes the frames
                    displayFrame();
                    Cursor = System.Windows.Forms.Cursors.Default;
                }
            }

            catch { }

        }
Example #18
0
        public void DisposeImg(Image img)
        {
            try
            {
                if (img != null)
                {
                    if (img.GetFrameCount(new FrameDimension(img.FrameDimensionsList[0])) > 1)
                        ImageAnimator.StopAnimate(img, new EventHandler(this.OnFrameChanged));

                    img.Dispose();
                }
            }
            catch
            {
                //img is disposed so do nothing
            }
        }
Example #19
0
 Image[] getFrames(Image originalImg)
 {
     int numberOfFrames = originalImg.GetFrameCount(FrameDimension.Time);
     Image[] frames = new Image[numberOfFrames];
     for (int i = 0; i < numberOfFrames; i++)
     {
         originalImg.SelectActiveFrame(FrameDimension.Time, i);
         frames[i] = ((Image)originalImg.Clone());
     }
     return frames;
 }
Example #20
0
        /// <summary>
        /// Checks and restores an animated GIF.
        /// </summary>
        /// <param name="image">The image.</param>
        /// <remarks>Documented by Dev03, 2008-03-21</remarks>
        private void CheckAndRestoreGIF(ref Image image)
        {
            if (!image.RawFormat.Guid.Equals(ImageFormat.Gif.Guid))
                return;

            List<int> badframeIndexes = new List<int>();
            int count = 0;

            count = image.GetFrameCount(FrameDimension.Time);

            if (count > 1)
            {
                //string fn = Path.GetTempFileName();
                //image.Save(fn);
                //image = Image.FromFile(fn);

                //MemoryStream str = new MemoryStream();
                //image.Save(str, ImageFormat.Gif);
                //str.Seek(0, SeekOrigin.Begin);
                //image = Image.FromStream(str);
            }

            for (int i = 0; i < count; i++)
            {
                try
                {
                    image.SelectActiveFrame(FrameDimension.Time, i);
                }
                catch
                {
                    badframeIndexes.Add(i);
                }
            }
            if (badframeIndexes.Count > 0)
            {
                string indexes = String.Empty;
                for (int i = 0; i < badframeIndexes.Count; i++)
                {
                    indexes += badframeIndexes[i].ToString() + ",";
                }
                indexes = indexes.Substring(0, indexes.Length - 1);
                System.Diagnostics.Debug.Write("Frames No." + indexes + " are damaged!");
            }
            else
            {
                return;
            }

            if ((badframeIndexes.Count) > 0 && (badframeIndexes.Count < count))
            {
                using (MemoryStream stream = new MemoryStream())
                {
                    EncoderParameters encoderpara = new EncoderParameters(1);

                    for (int i = 0; i < count; i++)
                    {
                        if (!badframeIndexes.Contains(i))
                        {
                            image.SelectActiveFrame(FrameDimension.Time, i);
                            image.Save(stream, ImageFormat.Png);
                            break;
                        }
                    }
                    image = Bitmap.FromStream(stream);
                }
            }
        }
Example #21
0
        internal static void EnsureSave(Image image, string filename, Stream dataStream) {

            if (image.RawFormat.Equals(ImageFormat.Gif)) {
                bool animatedGif = false;

                Guid[] dimensions = image.FrameDimensionsList;
                foreach (Guid guid in dimensions) {
                    FrameDimension dimension = new FrameDimension(guid);
                    if (dimension.Equals(FrameDimension.Time)) {
                        animatedGif = image.GetFrameCount(FrameDimension.Time) > 1;
                        break;
                    }
                }


                if (animatedGif) {
                    try {
                        Stream created = null;
                        long lastPos = 0;
                        if (dataStream != null) {
                            lastPos = dataStream.Position;
                            dataStream.Position = 0;
                        }

                        try {
                            if (dataStream == null) {
                                created = dataStream = File.OpenRead(filename);
                            }

                            image.rawData = new byte[(int)dataStream.Length];
                            dataStream.Read(image.rawData, 0, (int)dataStream.Length);
                        }
                        finally {
                            if (created != null) {
                                created.Close();
                            }
                            else {
                                dataStream.Position = lastPos;
                            }
                        }
                    }
                    // possible exceptions for reading the filename
                    catch (UnauthorizedAccessException) {
                    }
                    catch (DirectoryNotFoundException) {
                    }
                    catch (IOException) {
                    }
                    // possible exceptions for setting/getting the position inside dataStream
                    catch (NotSupportedException) {
                    }
                    catch (ObjectDisposedException) {
                    }
                    // possible exception when reading stuff into dataStream
                    catch (ArgumentException) {
                    }
                }
            }
        }
    public static int LoadFromMemory(Image memoryImage, string name, long lColorKey, int iMaxWidth, int iMaxHeight)
    {
      Log.Debug("TextureManager: load from memory: {0}", name);
      string cacheName = name;
      string cacheKey = name.ToLowerInvariant();

      CachedTexture cached;
      if (_cacheTextures.TryGetValue(cacheKey, out cached))
      {
        return cached.Frames;
      }

      if (memoryImage == null)
      {
        return 0;
      }
      if (memoryImage.FrameDimensionsList == null)
      {
        return 0;
      }
      if (memoryImage.FrameDimensionsList.Length == 0)
      {
        return 0;
      }

      try
      {
        CachedTexture newCache = new CachedTexture();

        newCache.Name = cacheName;
        FrameDimension oDimension = new FrameDimension(memoryImage.FrameDimensionsList[0]);
        newCache.Frames = memoryImage.GetFrameCount(oDimension);
        if (newCache.Frames != 1)
        {
          return 0;
        }
        //load gif into texture
        using (MemoryStream stream = new MemoryStream())
        {
          memoryImage.Save(stream, ImageFormat.Png);
          ImageInformation info2 = new ImageInformation();
          stream.Flush();
          stream.Seek(0, SeekOrigin.Begin);
          Texture texture = TextureLoader.FromStream(
            GUIGraphicsContext.DX9Device,
            stream,
            0, 0, //width/height
            1, //mipslevels
            0, //Usage.Dynamic,
            Format.A8R8G8B8,
            GUIGraphicsContext.GetTexturePoolType(),
            Filter.None,
            Filter.None,
            (int)lColorKey,
            ref info2);
          newCache.Width = info2.Width;
          newCache.Height = info2.Height;
          newCache.Texture = new TextureFrame(cacheName, texture, 0);
        }
        memoryImage.SafeDispose();
        memoryImage = null;
        newCache.Disposed += new EventHandler(cachedTexture_Disposed);

        _cacheTextures[cacheKey] = newCache;

        Log.Debug("TextureManager: added: memoryImage  " + " total count: " + _cacheTextures.Count + ", mem left (MB): " +
                  ((uint)GUIGraphicsContext.DX9Device.AvailableTextureMemory / 1048576));
        return newCache.Frames;
      }
      catch (Exception ex)
      {
        Log.Error("TextureManager: exception loading texture memoryImage");
        Log.Error(ex);
      }
      return 0;
    }
Example #23
0
 private void InitImage(Image image)
 {
     _gifImage = image;
     _dimension = new FrameDimension(_gifImage.FrameDimensionsList[0]);
     _frameCount = _gifImage.GetFrameCount(_dimension);
 }
Example #24
0
 public static bool IsGif(Image img)
 {
     Guid[] guids = img.FrameDimensionsList;
     FrameDimension fd = new FrameDimension(guids[0]);
     return img.GetFrameCount(fd) > 1;
 }
        /// <devdoc>
        ///    Whether or not the image has multiple time-based frames.
        /// </devdoc>
        public static bool CanAnimate(Image image) {
            if( image == null ) {
                return false;
            }

            // See comment in the class header about locking the image ref.
            lock( image ) {
                Guid[] dimensions = image.FrameDimensionsList;
                    
                foreach (Guid guid in dimensions) {
                    FrameDimension dimension = new FrameDimension(guid);
                    if (dimension.Equals(FrameDimension.Time)) {
                        return image.GetFrameCount(FrameDimension.Time) > 1;
                    }
                }
            }

            return false;
        }
    public void loadImage()
    {
        gifImage = ByteArrayToImage(www.bytes);

        if (gifImage == null)
            return;
        debugText.text = "Creating Image";
        var dimension = new System.Drawing.Imaging.FrameDimension(gifImage.FrameDimensionsList[0]);
        int frameCount = gifImage.GetFrameCount(dimension);
        for (int i = 0; i < frameCount; i++)
        {
            gifImage.SelectActiveFrame(dimension, i);
            var frame = new System.Drawing.Bitmap(gifImage.Width, gifImage.Height);
            System.Drawing.Graphics.FromImage(frame).DrawImage(gifImage, System.Drawing.Point.Empty);
            Texture2D frameTexture = new Texture2D(frame.Width, frame.Height);

            //Debug.logger.Log("width: " + frame.Width + " height: " + frame.Height + " frame count: " + frameCount + " total: " + (frame.Width * frame.Height * frameCount));
            for (int x = 0; x < frame.Width; x++)
                for (int y = 0; y < frame.Height; y++)
                {
                    System.Drawing.Color sourceColor = frame.GetPixel(x, y);
                    frameTexture.SetPixel(frame.Width - 1 + x, -y, new Color32(sourceColor.R, sourceColor.G, sourceColor.B, sourceColor.A)); // for some reason, x is flipped
                }
            frameTexture.Apply();
            gifFrames.Add(frameTexture);
        }
        debugText.text = "Created Image";
        canOnGUI = true;
    }
Example #27
0
 public static Image selectLargestPage( Image img )
 {
     if ( img==null )
         return null;
     int nLargestIndex = 0;
     int nLargestSize = 0;
     int nCount = img.GetFrameCount( FrameDimension.Page );
     if ( nCount==1 )
         return img;
     for ( var i=0 ; i<nCount ; i++ )
     {
         img.SelectActiveFrame( FrameDimension.Page, i );
         if ( img.Size.Width > nLargestSize )
         {
             nLargestSize = img.Size.Width;
             nLargestIndex = i;
         }
     }
     img.SelectActiveFrame( FrameDimension.Page, nLargestIndex );
     return img;
 }
Example #28
0
		public static bool CanAnimate (Image image)
		{
			if (image == null)
				return false;

			int n = image.FrameDimensionsList.Length;
			if (n < 1)
				return false;

			for (int i = 0; i < n; i++) {
				if (image.FrameDimensionsList [i].Equals (FrameDimension.Time.Guid)) {
					return (image.GetFrameCount (FrameDimension.Time) > 1);
				}
			}
			return false;
		}
Example #29
0
	public AnimateEventArgs (Image image)
	{
		frameCount = image.GetFrameCount (FrameDimension.Time);
	}
Example #30
0
 private Image[] TrySplitImage(Image master)
 {
     var dimension = new FrameDimension(master.FrameDimensionsList[0]);
     var images = new Image[master.GetFrameCount(dimension)];
     for (var i = 0; i < images.Length; i++) {
         master.SelectActiveFrame(dimension, i);
         images[i] = new Bitmap(master);
     }
     return images;
 }