How to save image file in BMP format?

the following code is compressing my image or is it not a BMP file:

FileOutputStream fos = new FileOutputStream(imagefile);

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

      

How to save image in BMP format?

+3


source to share


2 answers


There is no built-in encoder for BMP as per this link. BMP is not an overly complex format, it probably won't be rocket science to write / find a Java implementation.



+1


source


Hey just give the name .bmp

Do it:



ByteArrayOutputStream bytes = new ByteArrayOutputStream();
_bitmapScaled.compress(Bitmap.CompressFormat.PNG, 40, bytes);

//you can create a new file name "test.BMP" in sdcard folder.
File f = new File(Environment.getExternalStorageDirectory()
                        + File.separator + "**test.bmp**")

      

will sound like IM JUST FOOLING AROUND, but try it as soon as it is saved in bmp format. Smiles

-2


source







All Articles