C#從Gif中提取圖片。本站提示廣大學習愛好者:(C#從Gif中提取圖片)文章只能為提供參考,不一定能成為您想要的結果。以下是C#從Gif中提取圖片正文
C#從Gif中提取圖片的代碼片段
private void btn_extract_Click(object sender, EventArgs e) { Image imgGif = Image.FromFile(@"test.gif", true); //Create a new FrameDimension object from this image var ImgFrmDim = new FrameDimension(imgGif.FrameDimensionsList[0]); //Determine the number of frames in the image //Note that all images contain at least 1 frame, //but an animated GIF will contain more than 1 frame. int n = imgGif.GetFrameCount(ImgFrmDim); // Save every frame into jpeg format for (int i = 0; i < n; i++) { imgGif.SelectActiveFrame(ImgFrmDim, i); imgGif.Save(string.Format(@"Frame{0}.png", i), ImageFormat.Png); } }