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


C# Image.SelectActiveFrame方法代码示例

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


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

示例1: 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

示例2: 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

示例3: GetPage

 public Image GetPage(int page)
 {
     if (page < 1 || page > _pages) return null;
     img = Bitmap.FromFile(_filename);
     img.SelectActiveFrame(FrameDimension.Page, page - 1);
     Image ret = new Bitmap(img);
     img.Dispose();
     return ret;
 }
开发者ID:liorg,项目名称:DesignPatternsForXrm,代码行数:9,代码来源:PagingImage.cs

示例4: 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

示例5: 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

示例6: 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

示例7: loadImage

    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;
    }
开发者ID:DanFlannel,项目名称:Pokemon_Battle_Simulator,代码行数:29,代码来源:AnimatedGifDrawerFront.cs

示例8: GetPage

        public static Image GetPage(Image image, int i)
        {
            Guid objGuid = image.FrameDimensionsList[0];
            FrameDimension objDimension = new FrameDimension(objGuid);

            image.SelectActiveFrame(objDimension, i);

            MemoryStream ms = new MemoryStream();
            image.Save(ms, ImageFormat.Bmp);

            Image pageImage = Image.FromStream(ms);
            return pageImage;
        }
开发者ID:fizikci,项目名称:Cinar,代码行数:13,代码来源:Tiff.cs

示例9: displayFrame

        private void displayFrame()
        {
            _objImage = System.Drawing.Image.FromFile(_strFilePath);
            Guid objGuid = _objImage.FrameDimensionsList[0];
            System.Drawing.Imaging.FrameDimension objDimension = new System.Drawing.Imaging.FrameDimension(objGuid);
            _objImage.SelectActiveFrame(objDimension, _curF);
            picImage.Image = _objImage;
            //picImage.ScaleImage = Infragistics.Win.ScaleImage.OnlyWhenNeeded;
            picImage.SizeMode = PictureBoxSizeMode.StretchImage;

            _cboFrameNo.ToolValueChanged -= new Infragistics.Win.UltraWinToolbars.ToolEventHandler(_cboFrameNo_ToolValueChanged);
            _cboFrameNo.SelectedIndex = _curF;
            _cboFrameNo.ToolValueChanged += new Infragistics.Win.UltraWinToolbars.ToolEventHandler(_cboFrameNo_ToolValueChanged);
        }
开发者ID:gipasoft,项目名称:Sfera,代码行数:14,代码来源:GestioneFax.cs

示例10: LoadFrames

        /// <summary>
        /// 
        /// </summary>
        /// <param name="image"></param>
        private void LoadFrames(Image image)
        {
            int framesCount = image.GetFrameCount(FrameDimension.Time);
            if (framesCount <= 1)
            {
                throw new ArgumentException("Image not animated");
            }
            byte[] times = image.GetPropertyItem(0x5100).Value;
            int frame = 0;
            List<AnimationGifFrame> frames = new List<AnimationGifFrame>();
            while (true)
            {
                int dur = BitConverter.ToInt32(times, 4 * frame) * 10;
                frames.Add(new AnimationGifFrame(new Bitmap(image), dur));
                if (++frame >= framesCount)
                    break;

                image.SelectActiveFrame(FrameDimension.Time, frame);
            }
            this._frames = frames.ToArray();
        }
开发者ID:Ricordanza,项目名称:Ricordanza.kernel,代码行数:25,代码来源:AnimationGif.cs

示例11: byteArrayToBitMap

    /*/// <summary>
    /// This method converts the read in byte arry to a System.Drawing.Bitmap
    /// </summary>
    /// <param name="data"> the byte array to be convereted</param>
    /// <returns></returns>
    public System.Drawing.Bitmap byteArrayToBitMap(byte[] data){
       System.Drawing.Bitmap bmp;

       System.Drawing.ImageConverter ic = new System.Drawing.ImageConverter();
       bmp = (System.Drawing.Bitmap)ic.ConvertFrom(data);
       //Debug.Log("Converted byteArray to bit map");
       return bmp;

       }*/
    /*
    public void byteArrayToTexture2D(byte[] data)
    {
        int width = data[6];
        int height = data[8];
        Debug.Log("Width: " + width + " Height: " + height);
        Texture2D bmp = new Texture2D(width, height);
        bmp.LoadRawTextureData(data);
        myRawImage.texture = bmp;
    }*/
    /// <summary>
    /// This handles loading all fo the data from the given url and converts it into a readable image type and then allows the OnGUI function to draw the gif
    /// </summary>
    public void loadImage()
    {
        //Debug.Log("Called Load Image BACK");
        gifImage = ByteArrayToImage(www.bytes);

        if (gifImage == null)
            return;

        isGif = true;

        var dimension = new System.Drawing.Imaging.FrameDimension(gifImage.FrameDimensionsList[0]);
        int frameCount = gifImage.GetFrameCount(dimension);
        Debug.Log("Dimensions: Frames: " + frameCount + " Width: " + gifImage.Width + " Height: " + gifImage.Height + " Pixels: " + (gifImage.Width * gifImage.Height));
        int width = 0;
        int height = 0;

        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, Point.Empty);

            Texture2D frameTexture = new Texture2D(frame.Width, frame.Height);
            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 + x + 1, -y, new Color32(sourceColor.R, sourceColor.G, sourceColor.B, sourceColor.A)); // for some reason, x is flipped
                }
            frameTexture.Apply();
            gifFrames.Add(frameTexture);
            width = frame.Width;
            height = frame.Height;
        }
        byteArrayTextConversion(bytearrayholder);
        //Debug.Log("Starting ON GUI!");
        canOnGUI = true;
    }
开发者ID:DanFlannel,项目名称:Pokemon_Battle_Simulator,代码行数:66,代码来源:AnimatedGifDrawerBack.cs

示例12: getTiffImages

        public Image[] getTiffImages(Image sourceImage)
        {
            MemoryStream ms = null;
            int pageCount = getPageCount(sourceImage);

            Image[] returnImage = new Image[pageCount];

            try
            {
                Guid objGuid = sourceImage.FrameDimensionsList[0];
                FrameDimension objDimension = new FrameDimension(objGuid);

                for (int i = 0; i < pageCount; i++)
                {
                    ms = new MemoryStream();
                    sourceImage.SelectActiveFrame(objDimension, i);
                    sourceImage.Save(ms, ImageFormat.Tiff);
                    returnImage[i] = Image.FromStream(ms);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                ms.Close();
            }

            return returnImage;
        }
开发者ID:fizikci,项目名称:Cinar,代码行数:31,代码来源:Tiff.cs

示例13: getTiffImage

        public Image getTiffImage(Image sourceImage, int pageNumber)
        {
            MemoryStream ms = null;
            Image returnImage = null;

            try
            {
                ms = new MemoryStream();
                Guid objGuid = sourceImage.FrameDimensionsList[0];
                FrameDimension objDimension = new FrameDimension(objGuid);
                sourceImage.SelectActiveFrame(objDimension, pageNumber);
                sourceImage.Save(ms, ImageFormat.Tiff);
                returnImage = Image.FromStream(ms);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                ms.Close();
            }

            return returnImage;
        }
开发者ID:fizikci,项目名称:Cinar,代码行数:22,代码来源:Tiff.cs

示例14: saveImageExistingMultiplePage

        private static void saveImageExistingMultiplePage(Image[] bmp, Image origionalFile, int PageNumber, string location)
        {
            try
            {
                //Now load the Codecs
                ImageCodecInfo codecInfo = getCodec();

                Encoder saveEncoder;
                Encoder compressionEncoder;
                EncoderParameter saveEncodeParam;
                EncoderParameter compressionEncodeParam;
                EncoderParameters encoderParams = new EncoderParameters(2);
                Bitmap pages;
                Bitmap nextPage;

                saveEncoder = Encoder.SaveFlag;
                compressionEncoder = Encoder.Compression;

                origionalFile.SelectActiveFrame(FrameDimension.Page, 0);
                pages = new Bitmap(origionalFile);
                pages = ConvertToBitonal(pages);

                // Save the first page (frame).
                saveEncodeParam = new EncoderParameter(saveEncoder, (long)EncoderValue.MultiFrame);
                compressionEncodeParam = new EncoderParameter(compressionEncoder, (long)EncoderValue.CompressionCCITT4);
                encoderParams.Param[0] = compressionEncodeParam;
                encoderParams.Param[1] = saveEncodeParam;

                pages.Save(location, codecInfo, encoderParams);

                for (int i = 1; i < PageNumber; i++)
                {
                    saveEncodeParam = new EncoderParameter(saveEncoder, (long)EncoderValue.FrameDimensionPage);
                    compressionEncodeParam = new EncoderParameter(compressionEncoder, (long)EncoderValue.CompressionCCITT4);
                    encoderParams.Param[0] = compressionEncodeParam;
                    encoderParams.Param[1] = saveEncodeParam;

                    origionalFile.SelectActiveFrame(FrameDimension.Page, i);
                    nextPage = new Bitmap(origionalFile);
                    nextPage = ConvertToBitonal(nextPage);
                    pages.SaveAdd(nextPage, encoderParams);
                }

                for (int i = 0; i < bmp.Length; i++)
                {
                    saveEncodeParam = new EncoderParameter(saveEncoder, (long)EncoderValue.FrameDimensionPage);
                    compressionEncodeParam = new EncoderParameter(compressionEncoder, (long)EncoderValue.CompressionCCITT4);
                    encoderParams.Param[0] = compressionEncodeParam;
                    encoderParams.Param[1] = saveEncodeParam;
                    bmp[i] = (Bitmap)ConvertToBitonal((Bitmap)bmp[i]);
                    pages.SaveAdd(bmp[i], encoderParams);
                }

                saveEncodeParam = new EncoderParameter(saveEncoder, (long)EncoderValue.Flush);
                encoderParams.Param[0] = saveEncodeParam;
                pages.SaveAdd(encoderParams);
            }
            catch (System.Exception ee)
            {
                throw ee;
            }
        }
开发者ID:fizikci,项目名称:Cinar,代码行数:62,代码来源:Tiff.cs

示例15: GetGifFrames

        static Image[] GetGifFrames(Image inputImage)
        {
            var outputImages = new List<Image>();

            var frameDimension = new FrameDimension(inputImage.FrameDimensionsList[0]);

            var frameCount = inputImage.GetFrameCount(frameDimension);

            for (var i = 0; i < frameCount; i++)
            {
                inputImage.SelectActiveFrame(frameDimension, i);

                var outputImage = new Bitmap(inputImage.Width, inputImage.Height, PixelFormat.Format32bppArgb);

                var graphics = Graphics.FromImage(outputImage);

                graphics.DrawImage(inputImage, 0, 0, inputImage.Width, inputImage.Height);

                outputImages.Add(outputImage);
            }

            return outputImages.ToArray();
        }
开发者ID:jimnoble,项目名称:sprite-sheet-builder,代码行数:23,代码来源:Program.cs


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