| | |
Gif image Extraction
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2008
Posts: 1
Reputation:
Solved Threads: 0
Below is my code . Actually i want to know in which frame number image resides
and also i want to know number of frames in b/n each image
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Bitmap bmp;
public Image Img;
public System.Collections.ArrayList colFrame;
private int _FrameCount;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Img = Image.FromFile("c:\\triple\\diniout.gif");
colFrame = new System.Collections.ArrayList();
System.Drawing.Imaging.FrameDimension fdl = new System.Drawing.Imaging.FrameDimension(Img.FrameDimensionsList[0]);
_FrameCount = Img.GetFrameCount(fdl) ;
// ExtractImageFrames();
if(ImageAnimator.CanAnimate(Img))
{
ImageAnimator.Animate(Img, new EventHandler(this.onFrameChanged));
}
}
private void onFrameChanged(object sender, EventArgs e)
{
// MessageBox.Show(bAnimationEnd.ToString());
if (bAnimationEnd<0)
{
ImageAnimator.StopAnimate(Img, this.onFrameChanged);
Img.Dispose();
return;
}
// ExtractImageFrames();
// ImageAnimator.UpdateFrames(Img);
this.Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
////Bitmap tmpBmp = new Bitmap(Img.Width, Img.Height);
////Graphics g = Graphics.FromImage(tmpBmp);
//ExtractImageFrames();
e.Graphics.DrawImage(this.Img, new Point(0, 0));
////g.DrawImage(Img, 0, 0);
////g.Save();
e.Graphics.Save();
ExtractImageFrames();
////string tmpName = "img";
////tmpName = tmpName + _FrameCount.ToString() + ".bmp";
////tmpBmp.Save("c:\\" + tmpName);
////colFrame.Add(tmpBmp);
ImageAnimator.UpdateFrames(Img);
}
public void ExtractImageFrames()
{
Bitmap tmpBmp = new Bitmap(Img.Width, Img.Height);
Graphics g = Graphics.FromImage(tmpBmp);
//Graphics g = System.Drawing.Image.FromFile("c:\\image011.gif");
g.DrawImage(Img, 0, 0);
g.Save();
string tmpName = "imgArtdiniout";
tmpName = tmpName + _FrameCount.ToString() + ".bmp";
tmpBmp.Save("c:\\triple\\" + tmpName);
colFrame.Add(tmpBmp);
}
public int FrameCount
{
get
{
_FrameCount = _FrameCount - 1;
return _FrameCount;
}
}
public int bAnimationEnd
{
get{
return FrameCount;
}
}
}
}
and also i want to know number of frames in b/n each image
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Bitmap bmp;
public Image Img;
public System.Collections.ArrayList colFrame;
private int _FrameCount;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Img = Image.FromFile("c:\\triple\\diniout.gif");
colFrame = new System.Collections.ArrayList();
System.Drawing.Imaging.FrameDimension fdl = new System.Drawing.Imaging.FrameDimension(Img.FrameDimensionsList[0]);
_FrameCount = Img.GetFrameCount(fdl) ;
// ExtractImageFrames();
if(ImageAnimator.CanAnimate(Img))
{
ImageAnimator.Animate(Img, new EventHandler(this.onFrameChanged));
}
}
private void onFrameChanged(object sender, EventArgs e)
{
// MessageBox.Show(bAnimationEnd.ToString());
if (bAnimationEnd<0)
{
ImageAnimator.StopAnimate(Img, this.onFrameChanged);
Img.Dispose();
return;
}
// ExtractImageFrames();
// ImageAnimator.UpdateFrames(Img);
this.Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
////Bitmap tmpBmp = new Bitmap(Img.Width, Img.Height);
////Graphics g = Graphics.FromImage(tmpBmp);
//ExtractImageFrames();
e.Graphics.DrawImage(this.Img, new Point(0, 0));
////g.DrawImage(Img, 0, 0);
////g.Save();
e.Graphics.Save();
ExtractImageFrames();
////string tmpName = "img";
////tmpName = tmpName + _FrameCount.ToString() + ".bmp";
////tmpBmp.Save("c:\\" + tmpName);
////colFrame.Add(tmpBmp);
ImageAnimator.UpdateFrames(Img);
}
public void ExtractImageFrames()
{
Bitmap tmpBmp = new Bitmap(Img.Width, Img.Height);
Graphics g = Graphics.FromImage(tmpBmp);
//Graphics g = System.Drawing.Image.FromFile("c:\\image011.gif");
g.DrawImage(Img, 0, 0);
g.Save();
string tmpName = "imgArtdiniout";
tmpName = tmpName + _FrameCount.ToString() + ".bmp";
tmpBmp.Save("c:\\triple\\" + tmpName);
colFrame.Add(tmpBmp);
}
public int FrameCount
{
get
{
_FrameCount = _FrameCount - 1;
return _FrameCount;
}
}
public int bAnimationEnd
{
get{
return FrameCount;
}
}
}
}
![]() |
Similar Threads
- Cannot find server or DNS Error - please help! (Viruses, Spyware and other Nasties)
- Soft for webmasters! (Windows Software)
Other Threads in the C# Forum
- Previous Thread: Overloading method
- Next Thread: how to create autostart programme using c#?
| Thread Tools | Search this Thread |
.net access algorithm array asp.net barchart bitmap box broadcast c# check checkbox client combobox control conversion csharp custom database databaseconnection datagrid datagridview dataset datetime dbconnection degrees design development draganddrop drawing encryption enum event eventhandlers excel file firefox form format forms function gdi+ grantorrevokepermissionthroughc#.net httpwebrequest image index input install java label libraries list listbox loop mandelbrot marshalbyrefobject math mouseclick movingimage mysql mysql.data.client operator path photoshop php picturebox pixelinversion post programming radians regex remoting resourcefile richtextbox server sleep socket sql statistics stream string study system.servicemodel table tcpclientchannel text textbox thread time timer update usercontrol validation visualstudio webbrowser windows winforms wpf wpfc# xml





