gif显示

public void gifplay(string path,ref Panel panel)
{
try{
Bitmap animatedGif = new Bitmap(path );
Graphics g = panel.CreateGraphics();
int PropertyTagFrameDelay = 0x5100;
PropertyItem propItem = animatedGif.GetPropertyItem(PropertyTagFrameDelay);
byte[] bytes = propItem.Value;
FrameDimension frameDimension = new FrameDimension(animatedGif.FrameDimensionsList[]);
int frameCount = animatedGif.GetFrameCount(FrameDimension.Time);
int[] delays = new int[frameCount + ];
int i = ;
for (i = ; i <= frameCount - ; i++)
{delays[i] = BitConverter.ToInt32(bytes, i * );}
while (true)
{for (i = ; i <= animatedGif.GetFrameCount(frameDimension) - ; i++){
animatedGif.SelectActiveFrame(frameDimension, i);
g.DrawImage(animatedGif, new Point(, ));
Application.DoEvents();
Thread.Sleep(delays[i] * );}
}}
catch {return;}
}
上一篇:java泛型基础


下一篇:【转】使用STM32F4的CCM内存