This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes BufferedImage.TYPE_INT_ARGB is producing a black background Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "BufferedImage.TYPE_INT_ARGB is producing a black background" Watch "BufferedImage.TYPE_INT_ARGB is producing a black background" New topic
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
    
    3

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: BufferedImage.TYPE_INT_ARGB is producing a black background
 
Similar Threads
Extracting Pixel Data From Fonts
why do my white and black pixels come out red and grey?
works on WinXP jdk 1.6 but not Linux jdk 1.5
Saving drawing on simple paint application problem
Problem with using getSubimage(x,y,w,h)