Reputation: 558
I have an image with text and white background. I want to retain the text, i want to create a png image with that text and a transparent background. Could anyone guide me. Thank u.
Upvotes: 2
Views: 436
Reputation: 25156
I hope this will guide you to what you want. You need to do something similar to following steps:
Read the image,
extract RGB values,
create another image with ARGB
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
And apply the operation similar to Image Thresholding to check the white background on image bi
, If current pixel is white -> make that pixel transparant. Otherwise(for text image of other color) copy the pixel as it is.
And finally save bi
as PNG image using
ImageIO.write(bi, "PNG", new File("C:\yourImageName.PNG"));
Do some research.
Upvotes: 3