| | |
Gif image Extraction
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
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 angle array asp.net bitmap box broadcast c# capturing check checkbox client combobox control conversion csharp database databasesearch datagrid datagridview dataset datetime dbconnection degrees delegate design development disappear draganddrop drawing encryption enum eventhandlers excel file firefox form format forms function gdi+ grantorrevokepermissionthroughc#.net image input install interface java libraries list loop marshalbyrefobject math monodevelop mouseclick movingimage msword mysql operator path pause photoshop php picturebox pixelinversion platform post programming radians regex remoting richtextbox server sleep socket sql statistics string study system.servicemodel table tcpclientchannel text textbox thread time timer update usb usercontrol validation virtualization visualbasic visualstudio webbrowser winforms wpf wpfc# xml





