Results 1 to 4 of 4
  1. #1
    mafyou is offline Member
    Join Date
    Feb 2012
    Posts
    10
    Rep Power
    0

    Default Changing the alpha level on an Image

    Hi guys,

    I was just wondering if there was any way of changing the alpha levels of an AWT Image (NOT a BufferedImage)? I've had a look online and most of what I've found relates to BufferedImage. Reason why I'm not using a BufferedImage in the first place is I'm working with pre-existing code.

    Would prefer to avoid casting tricks if at all possible though... if it's unavoidable let me know.

    Cheers.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default Re: Changing the alpha level on an Image

    Depends what you mean by 'changing'

    Have you gone through the 2D tutorial trail? Make yourself familiar with Compositing Graphics (The Java™ Tutorials > 2D Graphics > Advanced Topics in Java2D)

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    mafyou is offline Member
    Join Date
    Feb 2012
    Posts
    10
    Rep Power
    0

    Default Re: Changing the alpha level on an Image

    I mean I have an image in my program which I need to make lighter/translucent. I've had a look at the methods associated with Image, but I couldn't find anything helpful. Am I able

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

    Default Re: Changing the alpha level on an Image

    You have to learn to be specific. Once again, it depends on what you mean by 'make lighter/translucent'
    -- draw the image to your GUI with partial transparency? The tutorial I linked will tell you how to do that
    -- introduce transparency and save the image in a format that supports transparency? Draw the image to a new BufferedImage using the technique in the tutorial, and save the BufferedImage using ImageIO and an appropriate format.

    I've had a look at the methods associated with Image
    You could have saved yourself some time by going through that tutorial instead.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. changing image of a label
    By Coold0wn in forum New To Java
    Replies: 4
    Last Post: 09-06-2011, 06:46 AM
  2. Changing Image color
    By Frecow in forum Java 2D
    Replies: 0
    Last Post: 04-04-2011, 10:16 AM
  3. changing JButton image upon clicking
    By Logical in forum AWT / Swing
    Replies: 2
    Last Post: 12-21-2010, 02:53 AM
  4. [SOLVED] Class-level vs Object-level method()
    By mfaizan24 in forum New To Java
    Replies: 7
    Last Post: 06-23-2009, 09:18 AM
  5. Changing colors of an image in real time
    By chale in forum CLDC and MIDP
    Replies: 0
    Last Post: 05-06-2009, 03:04 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
  •