The Java conversion from PNG to JPG changes white to red

See English answers > JPEG image with wrong colors7

UploadedFile uf; //as a paremeter in function; PrimeFaces Object;
BufferedImage old = ImageIO.read(uf.getInputstream());
ByteArrayOutputStream temp = new ByteArrayOutputStream();
ImageIO.write(old,"jpg",temp);

White turns red

http://www.primefaces.org/showcase/ui/file/upload/basic.xhtml

This is the effect:

Do you know how to deal with this problem? Thank you for your help first:)

Solution

The problem is the alpha channel in the PNG file, which does not exist in the JPG file Therefore, the alpha channel is replacing a red / Green / blue channel in the output and the color is wrong

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>