[java] Image.getGraphics and Component.createImage(width,height)

Started by
1 comment, last by letsch 23 years, 4 months ago
Ack! I feel a bit dumb again... Why? I have an Image problem... I am creating an Applet. I need Images where I can getGraphics(). As I cannot use BufferedImage I have to use Component.creatImage(width,height). As far as I know that is the only way to create an Image where I am able to get the Graphics (is there another way?). The problem is (a) I hate the fact that the Component has to be visible (but that is not really the problem) (b) the Image I get has the background color of the Component and the alpha channel is set to NOT transparent at all (c) I don''t know how to create an Image or convert the one from Component.createImage(width,height) to one that is FULLY transparent, because drawImage(...) cannot make it more transparent (sounds logical) and I don''t know how to SET a pixel (d) I need an Image that is FULLY transparent. Any suggestions? Yours, Leonhard BTW, to explain what I really want to do: I want to convert an Image I download to one where I can get the Graphics - and I also need the transparency. So I tried to create a new Image with Component.createImage(...) and draw my (fully) downloaded Image onto that Image... But this way I lose transparancy and have a background color instead.
Advertisement
You have several options here. First off you can also get an Image refrence from Toolkit.getDefaultToolkit().createImage(...); I''m not sure if they will return anything diffrent from what component does, but it''s worth a try.

Another option you have is to create a new Image producer style memory image with a SPECIFIC color model that includes alpha bits.

Hope this starts you in the right direction.
Thank you, but I think both options don''t work. I can only getGraphics() from an Image created with Component.createImage(), not from one that is downloaded or created with an ImageProducer. Toolkit.getDefaultToolkit().createImage(...) also uses an ImageProducer. That means I still don''t know how to create the Image I need. Thank you for your answer, Leonhard

This topic is closed to new replies.

Advertisement