Gif image Extraction

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2008
Posts: 1
Reputation: pradeepachari is an unknown quantity at this point 
Solved Threads: 0
pradeepachari pradeepachari is offline Offline
Newbie Poster

Gif image Extraction

 
0
  #1
Aug 6th, 2008
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;


}
}


}
}
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC