当前位置: 首页>>代码示例>>C#>>正文


C# Image.GetFrameCount方法代码示例

本文整理汇总了C#中System.Drawing.Image.GetFrameCount方法的典型用法代码示例。如果您正苦于以下问题:C# Image.GetFrameCount方法的具体用法?C# Image.GetFrameCount怎么用?C# Image.GetFrameCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Image的用法示例。


在下文中一共展示了Image.GetFrameCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ImageAnimation

        //-------------------------------------------------------------------------------
        //
        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失敗");
            }
        }
开发者ID:tomfuru,项目名称:StarlitTwit,代码行数:27,代码来源:ImageAnimation.cs

示例2: AnimatedImage

 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);
 }
开发者ID:data-avail,项目名称:DataAvail.WinForms,代码行数:7,代码来源:AnimatedImage.cs

示例3: PagingImage

 public PagingImage(string filename)
 {
     _filename = filename;
     img = Bitmap.FromFile(filename);
     _pages = img.GetFrameCount(FrameDimension.Page);
     img.Dispose();
 }
开发者ID:liorg,项目名称:DesignPatternsForXrm,代码行数:7,代码来源:PagingImage.cs

示例4: GifReader

        /// <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
        }
开发者ID:Dason1986,项目名称:Lib,代码行数:11,代码来源:GifImage.cs

示例5: ImageInfo

            /// <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];
                }
            }                                               
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:31,代码来源:ImageInfo.cs

示例6: GifImage

 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);
 }
开发者ID:lolibot,项目名称:LolibotGui-Code,代码行数:9,代码来源:GifImage.cs

示例7: GifHandler

		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;
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:10,代码来源:GifHandler.cs

示例8: GifBox

        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;
            }
        }
开发者ID:xuzhisme,项目名称:test,代码行数:11,代码来源:FormMain.cs

示例9: AnimateImage

        /// <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);
                }
            }
        }
开发者ID:s7loves,项目名称:mypowerscgl,代码行数:16,代码来源:GMapMarkerGif.cs

示例10: GifImage

        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
        }
开发者ID:SpoinkyNL,项目名称:Artemis,代码行数:12,代码来源:GifImage.cs

示例11: GifDecoder

        /// <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;
                }
            }
        }
开发者ID:AlexSkarbo,项目名称:ImageProcessor,代码行数:58,代码来源:GifDecoder.cs

示例12: IsGIFAnimation

 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;
 }
开发者ID:hbulzy,项目名称:SYS,代码行数:14,代码来源:ImageProcessor.cs

示例13: GetStackImage

        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());
        }
开发者ID:Ikkish,项目名称:Tibialyzer,代码行数:15,代码来源:LootDropForm.cs

示例14: GifDecoder

        /// <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;
            }
        }
开发者ID:CastleSoft,项目名称:ImageProcessor,代码行数:27,代码来源:GifDecoder.cs

示例15: ImageAnimation

        //-------------------------------------------------------------------------------
        //
        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);
        }
开发者ID:tomfuru,项目名称:StarlitTwit,代码行数:21,代码来源:ImageAnimation.cs


注:本文中的System.Drawing.Image.GetFrameCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。