It's really pitiful to use CF1. You want to use bitmap. save () saves bitmap as a GIF format, but also uses its own encoding. Fortunately, a new discovery has recently found a good GIF encoding on the Internet, decodes C # encapsulation class library, which consists of four files: animatedgifencoder. CS gifdecoder. CS lzwencoder. CS neuquant. CS composition.
Add it to the project and use it like below. If you are interested, try it.
Example:
/* Synthesize GIF */
String [] imagefilepaths = new string [] {"D: // frame0.jpg", "d: // frame1.jpg", "d: // frame2.jpg "};
String outputfilepath = "C: // test.gif ";
Animatedgifencoder E = new animatedgifencoder ();
E. Start (outputfilepath );
// Image conversion time
E. setdelay (50 );
// 1 indicates only one operation, 0 indicates a loop, and N indicates a loop N times
E. setrepeat (0 );
For (INT I = 0, Count = imagefilepaths. length; I <count; I ++)
{
E. addframe (image. fromfile (imagefilepaths [I]);
// Or E. addframe (Bitmap object );
}
E. Finish ();
/* Break down GIF */
String outputpath = "C ://";
Gifdecoder = new gifdecoder ();
Gifdecoder. Read ("C: // test.gif ");
For (INT I = 0, Count = gifdecoder. getframecount (); I <count; I ++)
{
Image Frame = gifdecoder. getframe (I); // frame I
Frame. Save ("... // image.png", imageformat. PNG );
}