• Post Reply Bookmark Topic Watch Topic
  • New Topic

BufferedImage.TYPE_INT_ARGB is producing a black background  RSS feed

 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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):

 
chaitanya karthikk
Ranch Hand
Posts: 806
Java MySQL Database Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!