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


C# Imaging.FrameDimension类代码示例

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


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

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

示例2: LoadImg

 private void LoadImg(string path)
 {
     var img = Image.FromFile(path);
     var fd = new FrameDimension(img.FrameDimensionsList[0]);
     var count = img.GetFrameCount(fd);
     var ms = new MemoryStream();
     Texture2D texture;
     TimeSpan frametime = new TimeSpan(0,0,0);
     FrameImg.Clear();
     int i;
     for(i=0;i<count;i++)
     {
         for (int j = 0; j < img.PropertyIdList.Length; j++)
         {
             if ((int)img.PropertyIdList.GetValue(j) == 0x5100)
             {
                 PropertyItem pItem = (PropertyItem)img.PropertyItems.GetValue(j);
                 byte[] delayByte = new byte[4];
                 delayByte[0] = pItem.Value[i * 4];
                 delayByte[1] = pItem.Value[1 + i * 4];
                 delayByte[2] = pItem.Value[2 + i * 4];
                 delayByte[3] = pItem.Value[3 + i * 4];
                 int delay = BitConverter.ToInt32(delayByte, 0) * 10;
                 frametime = new TimeSpan(0, 0, 0, 0, delay);
                 break;
             }
         }
         img.SelectActiveFrame(fd, i);
         img.Save(ms, ImageFormat.Png);
         texture = Texture2D.FromStream(GraphicsDevice, ms);
         FrameImg.Add(new GifFrame(texture,frametime));
         ms = new MemoryStream();
     }
     FrameTime = frametime;
 }
开发者ID:jxpxxzj,项目名称:WarshipGirl,代码行数:35,代码来源:GifPlayer.cs

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

示例4: ConvertTiffToJpeg

        internal static string[] ConvertTiffToJpeg(string fileName)
        {
            using (Image imageFile = Image.FromFile(fileName))
            {
                FrameDimension frameDimensions = new FrameDimension(imageFile.FrameDimensionsList[0]);
                int frameNum = imageFile.GetFrameCount(frameDimensions);
                string[] jpegPaths = new string[frameNum];

                for (int frame = 0; frame < frameNum; frame++)
                {
                    imageFile.SelectActiveFrame(frameDimensions, frame);
                    using (Bitmap bmp = new Bitmap(imageFile))
                    {
                        string tempFileName = Path.GetTempFileName();
                        FileInfo fileInfo = new FileInfo(tempFileName);
                        fileInfo.Attributes = FileAttributes.Temporary;
                        jpegPaths[frame] = tempFileName;
                        bmp.Save(jpegPaths[frame], ImageFormat.Jpeg);
                        bmp.Dispose();
                    }
                }

                return jpegPaths;
            }
        }
开发者ID:Bolde,项目名称:AlarmWorkflow,代码行数:25,代码来源:Helpers.cs

示例5: ConvertTiffToJpeg

        public static string[] ConvertTiffToJpeg(string fileName)
        {
            using (Image imageFile = Image.FromFile(fileName))
            {
                FrameDimension frameDimensions = new FrameDimension(
                    imageFile.FrameDimensionsList[0]);

                // Gets the number of pages from the tiff image (if multipage)
                int frameNum = imageFile.GetFrameCount(frameDimensions);
                string[] jpegPaths = new string[frameNum];

                for (int frame = 0; frame < frameNum; frame++)
                {
                    // Selects one frame at a time and save as jpeg.
                    imageFile.SelectActiveFrame(frameDimensions, frame);
                    using (Bitmap bmp = new Bitmap(imageFile))
                    {
                        jpegPaths[frame] = String.Format("{0}\\{1}{2}.jpg",
                            Path.GetDirectoryName(fileName),
                            Path.GetFileNameWithoutExtension(fileName),
                            frame);
                        bmp.Save(jpegPaths[frame], ImageFormat.Jpeg);
                    }
                }

                return jpegPaths;
            }
        }
开发者ID:Azure,项目名称:usql,代码行数:28,代码来源:ImageOps.cs

示例6: Main

        static void Main(string[] args)
        {
            for (int j = 0; j < args.Length; j++)
              {
            Console.WriteLine("Convert File of:"+args[j]);
            using(Image gif = Image.FromFile(args[j])){
              FrameDimension fd = new FrameDimension(gif.FrameDimensionsList[0]);

              int count = gif.GetFrameCount(fd);
              using(Image target= new Bitmap(count*150, 150))
              using(Graphics g = Graphics.FromImage(target)){
            g.Clear(Color.Transparent);
            for (int i = 0; i < count; i++)
            {
              gif.SelectActiveFrame(fd, i);
              g.DrawImage(gif,new Point(150/2-gif.Width/2+i*150,150/2-gif.Height/2));
              //gif.Save( Path.GetFileNameWithoutExtension(args[j])+
              //         string.Format("_{0}", i)
              //         + ".png", ImageFormat.Png);
            }
            target.Save(Path.GetFileNameWithoutExtension(args[j])+".png",ImageFormat.Png);
              }
            }
              }
              Console.WriteLine("Convert Fine. Press any key to continue... ");
              Console.ReadKey(true);
        }
开发者ID:pa001024,项目名称:Gif2Png,代码行数:27,代码来源:Gif2PngX.cs

示例7: ConvertToSinglePageTiffs

        public void ConvertToSinglePageTiffs(string fileName, string destFolder)
        {
            Image image = Image.FromFile(fileName);
            ImageCodecInfo codecInfo = GetCodecInfo(TIFF_CODEC);

            FrameDimension frameDim = new FrameDimension(image.FrameDimensionsList[0]);
            EncoderParameters encoderParams = new EncoderParameters(1);
            encoderParams.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression, ENCODING_SCHEME);
            
            for (int i = 0; i < image.GetFrameCount(frameDim); i++)
            {
                image.SelectActiveFrame(frameDim, i);

                string fileNameWOExt = Path.GetFileNameWithoutExtension(fileName);
                string newFileName = string.Concat(fileNameWOExt, "_", (i + 1).ToString(), TIFF_FILE_EXTENSION);

                string folder = Path.Combine(Path.GetDirectoryName(fileName), destFolder);
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }

                image.Save(Path.Combine(folder, newFileName), codecInfo, encoderParams);
            }
        }
开发者ID:connecticutortho,项目名称:ct-ortho-repositories4,代码行数:25,代码来源:MSUtils.cs

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

示例9: StartScreen

        public static void StartScreen()
        {
            Console.Title = "FROGGER by Serpent Fly\u2122";
            Console.CursorVisible = false;
            Image Picture = Image.FromFile(@"..\..\startscreen.png");
            //Console.SetWindowSize(140, 49);
            //Console.SetBufferSize((Picture.Width * 0x2), (Picture.Height * 0x2));
            FrameDimension Dimension = new FrameDimension(Picture.FrameDimensionsList[0x0]);
            int FrameCount = Picture.GetFrameCount(Dimension);
            int Left = Console.WindowLeft, Top = Console.WindowTop;
            char[] Chars = { '#', '#', '@', '%', '=', '+', '*', ':', '-', '.', ' ' };
            Picture.SelectActiveFrame(Dimension, 0x0);
            for (int i = 0x0; i < Picture.Height; i++)
            {
                for (int x = 0x0; x < Picture.Width; x++)
                {
                    Color Color = ((Bitmap)Picture).GetPixel(x, i);
                    int Gray = (Color.R + Color.G + Color.B) / 0x3;
                    int Index = (Gray * (Chars.Length - 0x1)) / 0xFF;
                    Console.Write(Chars[Index]);
                }
                Console.Write('\n');
            }
            Console.SetCursorPosition(Left, Top);

            //Console.Read();
        }
开发者ID:dobromiraboycheva,项目名称:C-Sharp-2-Group-Project,代码行数:27,代码来源:PictureGenerator.cs

示例10: addFrameToSpriteSheet

        public bool addFrameToSpriteSheet(String filename)
        {
            //Create Frame from filename
            Image img1 = Image.FromFile(filename);

            //
            //Trick to allow Annimated Gif importation
            //
            FrameDimension dimension = new FrameDimension(img1.FrameDimensionsList[0]);
            // Get Frame count of Image File
            int frameCount = img1.GetFrameCount(dimension);
            // Browse frame list
            for (int i = 0; i < frameCount; i++)
            {
                // Select current frame
                img1.SelectActiveFrame(dimension, i);

                // Add normaly the image to the spritesheet
                Image img = new Bitmap(img1);
                SpriteFrame newFrame = new SpriteFrame(filename, this.sheet.Frames.Count, img, sheet);
                this.sheet.Frames.Add(newFrame);

            }

            //Clean
            img1.Dispose();

            return true;
        }
开发者ID:nadar71,项目名称:Krea,代码行数:29,代码来源:SpriteSheetManagerPanel.cs

示例11: Equals

		public void Equals ()
		{
			FrameDimension fd = new FrameDimension (new Guid ("7462dc86-6180-4c7e-8e3f-ee7333a7a483"));
			// equals
			Assert.IsTrue (fd.Equals (FrameDimension.Page), "Page");
			// but ToString differs!
			Assert.AreEqual ("[FrameDimension: 7462dc86-6180-4c7e-8e3f-ee7333a7a483]", fd.ToString (), "ToString");
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:FrameDimensionTest.cs

示例12: button2_Click

        private void button2_Click(object sender, EventArgs e)
        {
            if (listBox1.Items.Count > 0)
            {
                using (SaveFileDialog dialog = new SaveFileDialog())
                {
                    dialog.Filter = "Png Image (*.png)|*.png";

                    if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        Bitmap[,] matrix = new Bitmap[200, 200];

                        int y = 0;
                        int maxFrames = 0;

                        foreach (string fileName in listBox1.Items)
                        {
                            var image = Image.FromFile(fileName);
                            var dimension = new FrameDimension(image.FrameDimensionsList[0]);

                            int frameCount = image.GetFrameCount(dimension);

                            for (int frame = 0; frame < frameCount; frame++)
                            {
                                image.SelectActiveFrame(dimension, frame);
                                matrix[y, frame] = new Bitmap(image);
                            }

                            maxFrames = Math.Max(maxFrames, frameCount);
                            y++;
                        }

                        var final = new Bitmap(maxFrames * matrix[0, 0].Width, y * matrix[0, 0].Height);

                        using (var fx = Graphics.FromImage(final))
                        {
                            for (int g = 0; g < y; g++)
                            {
                                for (int x = 0; x < 200; x++)
                                {
                                    if (matrix[g, x] != null)
                                    {
                                        MessageBox.Show((x * matrix[g, x].Width).ToString() + " " + x);
                                        fx.DrawImage((Image)matrix[g, x], new Point(x * matrix[g, x].Width, g * matrix[g, x].Height));
                                    }
                                }
                            }

                            fx.Flush();

                        }

                        final.Save(dialog.FileName, ImageFormat.Png);

                    }
                }
            }
        }
开发者ID:alongubkin,项目名称:Plutonium,代码行数:58,代码来源:MainForm.cs

示例13: GetImageInfo

        /// <summary>
        /// Returns information about the given <see cref="System.Drawing.Image"/>.
        /// </summary>
        /// <param name="image">
        /// The image to extend.
        /// </param>
        /// <param name="format">
        /// The image format.
        /// </param>
        /// <param name="fetchFrames">
        /// Whether to fetch the images frames.
        /// </param>
        /// <returns>
        /// The <see cref="ImageInfo"/>.
        /// </returns>
        public static ImageInfo GetImageInfo(this Image image, ImageFormat format, bool fetchFrames = true)
        {
            ImageInfo info = new ImageInfo
                                 {
                                     Height = image.Height,
                                     Width = image.Width,
                                     // ReSharper disable once BitwiseOperatorOnEnumWithoutFlags
                                     IsIndexed = (image.PixelFormat & PixelFormat.Indexed) != 0
                                 };

            if (image.RawFormat.Guid == ImageFormat.Gif.Guid && format.Guid == ImageFormat.Gif.Guid)
            {
                if (ImageAnimator.CanAnimate(image))
                {
                    info.IsAnimated = true;

                    if (fetchFrames)
                    {
                        FrameDimension frameDimension = new FrameDimension(image.FrameDimensionsList[0]);
                        int frameCount = image.GetFrameCount(frameDimension);
                        int last = frameCount - 1;
                        int delay = 0;
                        int index = 0;
                        List<GifFrame> gifFrames = new List<GifFrame>();

                        for (int f = 0; f < frameCount; f++)
                        {
                            int thisDelay = BitConverter.ToInt32(image.GetPropertyItem(20736).Value, index);
                            int toAddDelay = thisDelay * 10 < 20 ? 20 : thisDelay * 10; // Minimum delay is 20 ms

                            // Find the frame
                            image.SelectActiveFrame(frameDimension, f);

                            // TODO: Get positions.
                            gifFrames.Add(new GifFrame { Delay = toAddDelay, Image = (Image)image.Clone() });

                            // Reset the position.
                            if (f == last)
                            {
                                image.SelectActiveFrame(frameDimension, 0);
                            }

                            delay += toAddDelay;
                            index += 4;
                        }

                        info.GifFrames = gifFrames;
                        info.AnimationLength = delay;

                        // Loop info is stored at byte 20737.
                        info.LoopCount = BitConverter.ToInt16(image.GetPropertyItem(20737).Value, 0);
                        info.IsLooped = info.LoopCount != 1;
                    }
                }
            }

            return info;
        }
开发者ID:Eg-Virus,项目名称:ImageProcessor,代码行数:73,代码来源:ImageExtensions.cs

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

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


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