4

I know that I should use the compress method for saving a bitmap file.

FileOutputStream fos = new FileOutputStream(imagefile);

bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.flush();
fos.close();

but I want to save my image as bmp format while "Bitmap.CompressFormat" only supports PNG and JPEG. How can I save my image file as BMP format?

Thanks,

Bob
  • 22,810
  • 38
  • 143
  • 225

1 Answers1

0

you can use copyPixelsToBuffer

to store the bitmap pixel into a buffer and, than wrote your buffer into the sd.

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
  • I did it but I did not get result: `FileOutputStream fos = new FileOutputStream(imagefile); ByteBuffer bf = ByteBuffer.allocate(width * height * 4); bitmap.copyPixelsToBuffer(bf); fos.write(bf.array()); fos.flush(); fos.close(); return true;` – Bob Oct 02 '11 at 13:29
  • sorry I just misunderstood documentation. sorry – Blackbelt Oct 02 '11 at 13:36