views:

215

answers:

1
  public function bmdToStr(bmd:BitmapData,width:int,height:int):String {
   var encoder:JPEGEncoder = new JPEGEncoder();
   var encBytes:ByteArray = encoder.encode(bmd);
   return ImageSnapshot.encodeImageAsBase64(new ImageSnapshot(width,height,encBytes,"image/jpeg")); 
  }

As of now, I am creating JPEG image from bitmapdata as above.
I can use PNGEncoder for creating png images as well.
How do I create .bmp or .gif files?

A: 

why would you create BMP? and for the same matter, why would you create a GIF?

the only interesting thing about GIF is, it supports animation. apart from that it's simply deprecated. if you want lossless compresion use PNG, if size is more important, use JPG. if it is really animation you want, I suggest you have a look at GIF Animation Encoder.

and BMP is totally not worth any consideration. it's just huge for 24 bit images (32 with transparency). an image 800x600 will result in 1.4 MB. BMP offers no advantages except the fact that it doesn't require decompression for display, but nowadays this makes virtually no difference, especially for the web.

if you really think, you need it, then you should simply lookup bmp specs. it's really straight forward.

greetz

back2dos

back2dos