java - Removing transparency in PNG BufferedImage -
i'm reading png image next code:
bufferedimage img = imageio.read(new url(url));
upon displaying it, there black background, know caused png transparency. effort fixing setting each pixel alpha value not equal 255, color.white
. did not solve problem.
i found answers question, suggesting utilize of bufferedimage.type_int_rgb
, unsure of how apply given code above. help appreciated.
create sec bufferedimage
of type type_int_rgb
...
bufferedimage re-create = new bufferedimage(img.getwidth(), img.getheight(), bufferedimage.type_int_rgb);
paint original copy...
graphics2d g2d = copy.creategraphics(); g2d.setcolor(color.white); // or ever fill color want... g2d.fillrect(0, 0, copy.getwidth(), copy.getheight()); g2d.drawimage(img, 0, 0, null); g2d.dispose();
you have non transparent version of image...
to save image, take @ writing/saving image
java png bufferedimage
No comments:
Post a Comment