While converting image using
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 colors are changed into red..
Here's the effect:
Do you know how to handle this problem?
Thanks for your help in advance :)
解决方案
The problem is the alpha channel in the PNG file, which doesn't exist in the JPG file. Therefore, the alpha channel is replacing one of the red/green/blue channels in the output, and the colors are wrong.
You can find an example of how to do it properly here: http://www.mkyong.com/java/convert-png-to-jpeg-image-file-in-java/