Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Graphics2D: How to reset a BufferedImage with an Alpha chanel

Reply
Thread Tools

Graphics2D: How to reset a BufferedImage with an Alpha chanel

 
 
charlym
Guest
Posts: n/a
 
      05-29-2006
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!

 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      05-29-2006
charlym wrote:
> I am trying to reset a specific area in a BufferedImage

[...]

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


image.getGraphics().clearRect(...);

Check the API doc for details.

/Thomas
--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/...g/java/gui/faq
http://www.uni-giessen.de/faq/archiv....java.gui.faq/
 
Reply With Quote
 
 
 
 
charlym
Guest
Posts: n/a
 
      05-29-2006
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?

 
Reply With Quote
 
Oliver Wong
Guest
Posts: n/a
 
      05-29-2006
"charlym" <> wrote in message
news: oups.com...
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Chanel Wallet Red C1509 Collection bagsbags31@gmail.com C Programming 1 06-11-2009 03:38 AM
Chanel Cambon Line Tote Black/White CC's GM 9005 Collection bagsbags143@gmail.com Computer Support 7 02-13-2009 02:53 PM
Chanel 6 Key Holder Black 300905 Collection bagsbags130@gmail.com Digital Photography 0 02-12-2009 09:16 AM
where do i fingd the chanel number geepeetee Wireless Networking 3 03-26-2006 10:43 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57