How can I convert a BufferedImage object to a BMP file?

Sandip Chitale

The BufferedImage allows you to get at the raw data associated with the image using the

BufferedImage bi = //....;
int rgb[] = bi.getRGB(int startX,
                    int startY,
                    int w,
                    int h,
                    int[] rgbArray,
                    int offset,
                    int scansize);
// The returned int array is in the format -
// pixel   = rgbArray[offset + (y-startY)*scansize + (x-startX)];
// Now convert this data into the .bmp format

The information about .bmp file format can be found here -
0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.