How to export a GIF Image

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.