Graphics2D: How to reset a BufferedImage with an Alpha chanel

Discussion in 'Java' started by charlym, May 29, 2006.

  1. charlym

    charlym Guest

    Hello newsgroup!

    I am trying to reset a specific area in a BufferedImage that has been
    set up using an Alpha chanel (TYPE_INT_ARGB). The idea is that I have
    to refresh a certain area an therefore I want to clear it before I
    redraw it. Currently I am using the following code:

    In the constructor:
    this.image = new BufferedImage(this.getWidth(),
    this.getHeight(), BufferedImage.TYPE_INT_ARGB);
    this.dirtyHack = new BufferedImage(this.getWidth(),
    this.getHeight(), BufferedImage.TYPE_INT_ARGB);

    In the paintComponent method:
    image.setData(dirtyHack.getData(bounds));

    This works, but it uses a lot of memory. Is there a cheaper way of
    doing this?

    Thanks for your help!
     
    charlym, May 29, 2006
    #1
    1. Advertising

  2. Thomas Weidenfeller, May 29, 2006
    #2
    1. Advertising

  3. charlym

    charlym Guest

    Thomas & the rest of the newsgroup,

    I tried this but it does not do what I expected. I want the rectangle
    to be totally transparent. clearRect fills the rectangle with the
    backgroundcolor :-( I also tried to change the color using a
    transparent color (new Color(0,0,0,0)) but it did not help either.

    Any other ideas?
     
    charlym, May 29, 2006
    #3
  4. charlym

    Oliver Wong Guest

    "charlym" <> wrote in message
    news:...
    > Thomas & the rest of the newsgroup,
    >
    > I tried this but it does not do what I expected. I want the rectangle
    > to be totally transparent. clearRect fills the rectangle with the
    > backgroundcolor :-( I also tried to change the color using a
    > transparent color (new Color(0,0,0,0)) but it did not help either.
    >
    > Any other ideas?


    From the javadocs:

    <quote>
    Beginning with Java 1.1, the background color of offscreen images may be
    system dependent. Applications should use setColor followed by fillRect to
    ensure that an offscreen image is cleared to a specific color.
    </quote>

    Did you try that?

    - Oliver
     
    Oliver Wong, May 29, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    2,798
    cnphoenix
    Jun 11, 2009
  2. damo

    Designer Sunglasses - Chanel Sunglasses

    damo, Aug 7, 2009, in forum: C Programming
    Replies:
    0
    Views:
    670
  3. damo
    Replies:
    0
    Views:
    468
  4. Elliot

    How to reset Graphics2D

    Elliot, Mar 23, 2010, in forum: Java
    Replies:
    5
    Views:
    1,779
    Jeff Higgins
    Apr 3, 2010
  5. mychanel m

    chanel bags

    mychanel m, Jul 6, 2010, in forum: XML
    Replies:
    0
    Views:
    1,579
    mychanel m
    Jul 6, 2010
Loading...

Share This Page