Results 1 to 5 of 5
  1. #1
    gib65 is offline Member
    Join Date
    Jun 2010
    Posts
    86
    Rep Power
    0

    Default how do I set the alpha value on Images?

    I'm looking at the Graphics.drawImage() methods and I don't see anything for setting the alpha value of the image. What I mean is, I want to draw an image that is half transparent, but I don't see a way to do that. I've also looked into the Image, ImageObserver, and Graphics2D classes to no avail.

    Does anyone have any suggestions?

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    I'm a bit confused by this. "I don't see anything for setting the alpha value of the image" vs "I want to draw an image that is half transparent". So is the image half transparent or are you trying to set the transparency? Which?

    Perhaps a small, runnable example together with a description of actual and intended behaviour would help.

    Assuming the image is transparent (so that setting the alpha doesn't arise), then drawImage() will cause it to be rendered. The exact colouration of the resulting pixels will depend on the current value of the composite.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,239
    Rep Power
    19

    Default

    Tutorial on how to use composites here:
    Lesson: Advanced Topics in Java2D (The Java™ Tutorials > 2D Graphics)

    But you'd probably be better off going through the entire 2D Graphics trail.
    Trail: 2D Graphics (The Java™ Tutorials)

    db

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,239
    Rep Power
    19

    Default

    Spammer ruster55 reported.

    db

  5. #5
    gib65 is offline Member
    Join Date
    Jun 2010
    Posts
    86
    Rep Power
    0

    Default

    Thanks both,

    I ended up using the AlphaComposite class.

    And my goal was to take an opaque image and render it half transparent by manipulating the alpha value.

    Thanks.

Similar Threads

  1. Collaba 7.1 Alpha 1
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 05-01-2008, 04:50 PM
  2. tinyTiM 1.5.0 alpha
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 04-26-2008, 08:25 PM
  3. SableCC 4-alpha.4
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 03-10-2008, 01:57 PM
  4. RabbitMQ 1.1.0-alpha
    By levent in forum Java Software
    Replies: 0
    Last Post: 08-02-2007, 05:51 PM
  5. SableCC 4-alpha.3
    By levent in forum Java Software
    Replies: 0
    Last Post: 07-26-2007, 07:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •