ChrisV
ChrisV

Reputation: 143

Load BufferedImage from ARGB bitmap

I created a 32-bit ARGB image in Gimp. When I load the bitmap to a BufferedImage using the common way (BufferedImage img = ImageIO.read( imagePath); ), the image is loaded, but the alpha channel is just visualized in black. When I debug my application, I can see that the BufferedImage is assigned the TYPE_INT_RGB type, instead of the expected TYPE_INT_ARGB type. How can I load my bmp file to a BufferedImage of this type?

Upvotes: 2

Views: 1098

Answers (1)

prunge
prunge

Reputation: 23248

I'm assuming you are saving as a Windows Bitmap (BMP) file.

First thing to check, as Durandal suggests, is that you are selecting a BMP format that supports alpha. Under Advanced Options in the Save as BMP dialog, ensure you select the A8 R8 G8 B8 format.

If that does not work, try saving as PNG instead of BMP. BMP files have many subformats, and the Java Imaging API might not support all of them.

Upvotes: 2

Related Questions