Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

letsch

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

This topic is 6595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!