In recent days, I have been working on the GIF file format. I found one on the Internet and I am analyzing it. It can be said that GIF images are relatively complicated in several image formats. To put it bluntly, we should first implement a method to export images from GIF Animation:
The effect is as follows:
Original GIF animated images:
Imported image:
Code : 1 Public Void Exportfromgif ( String Giffile, String Outputdir)
2 {
3 Bitmap BMP = New Bitmap (giffile );
4 If (BMP. rawformat. guid ! = Imageformat. gif. guid)
5 {
6Throw NewException ("The file is not in GIF format. The format is incorrect!");
7}
8 // Obtain the dimensions.
9 Foreach (Guid In BMP. framedimensionslist)
10 {
11 Framedimension = New Framedimension (guid );
12 // Get the number of GIF animation shards
13 Int Framecount = BMP. getframecount (framedimension );
14 // Used to store exported images
15 For ( Int I = 0 ; I < Framecount; I ++ )
16 {
17 // Select a region
18 Int Selectresult = BMP. selectactiveframe (framedimension, I );
19 If (Selectresult = 0 )
20 {
21 Image img = Image. fromhbitmap (BMP. gethbitmap ());
22 String Savepath = Outputdir + Guid. newguid (). tostring () + " . Jpg " ;
23 IMG. Save (savepath );
24 IMG. Dispose ();
25 }
26 }
27 }
28 }
29 }
It was originally intended to be as black and white as JPEG images after selectactiveframe, but after selectactiveframe is executed, the last modification became invalid and depressing. The saveadd method cannot be used in GIF format. The system only provides the GIF decoder, but does not improve the encoder. Fainted.
I found one from the Internet and is learning