I have a PNG file with transparency that is loaded and stored in a BufferedImage
. I need this BufferedImage
to be of TYPE_INT_ARGB
. However, when I use getType()
the returned value is 0 (TYPE_CUSTOM
) instead of 2 (TYPE_INT_ARGB
).
This is how I load the .png
:
public File img = new File("imagen.png");
public BufferedImage buffImg =
new BufferedImage(240, 240, BufferedImage.TYPE_INT_ARGB);
try {
buffImg = ImageIO.read(img );
}
catch (IOException e) { }
System.out.Println(buffImg.getType()); //Prints 0 instead of 2
How can I load the .png, save in the BufferedImage
and make it TYPE_INT_ARGB
?
Example output for my image file:
You can run System.out.println(object); on just about any object and get some information about it.
Create a BufferedImage from file and make it TYPE_INT_RGB
This paints a big blue streak across the top.
If you want it ARGB, do it like this:
Open up MyFile.png, it has a red streak across the top.