| Author |
BufferedImage.TYPE_INT_ARGB is producing a black background
|
chaitanya karthikk
Ranch Hand
Joined: Sep 15, 2009
Posts: 779
|
|
Hi everybody, I am trying to create a jpeg file and then write text on to it. When I try to create a jpeg file with BufferedImage.TYPE_INT_ARGB it is producing a black background instead on white, they said BufferedImage.TYPE_INT_RGB will produce black and BufferedImage.TYPE_INT_ARGB will produce white backgrounds, but its not happening in this case, please tell me what I have done wrong and please tell me the difference between those both.
Thank you all in advance, have a good day.
|
Love all, trust a few, do wrong to none.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Who is "they" that said the background would be black/white?
If you need the background to be white, just paint the entire image white before you do anything else:
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12921
|
|
I'm not sure why that happens; it might be because the program that you are using to display the JPEG does not show what parts of the image are transparent. If you use TYPE_INT_ARGB, there will be four channels in the image: red, green, blue and alpha; the latter determines the transparency of each pixel.
Before writing the text on the BufferedImage, it's better to fill the whole image with a certain color, by drawing a rectangle that fills the whole image. For example (note, untested code):
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
chaitanya karthikk
Ranch Hand
Joined: Sep 15, 2009
Posts: 779
|
|
Hi @Jesper @Rob Prime
the problem has been solved, actually in the image it is showing black background, when I try to read the image and display it I am unable to see any background, when I tried the same with TYPE_INT_RGB I am able to see the background.
|
 |
 |
|
|
subject: BufferedImage.TYPE_INT_ARGB is producing a black background
|
|
|