draw: how to layer colors?

  • Follow


Hi there,

In Swing/Java AWT, is there any way to specify pen color parameters so
that if you draw over a an existing pixel using the same color, that
the intensity of that pixel increases?    I'm not sure that alpha
blending works to do what I want:  for instance, say pixel (100,100) is
very light gray:  I want successive calls to draw pixel (100,100) with
the same light gray color to make that pixel more and more white.

Thanks!

Isaac

PS - In case you are wondering, I'm designing a solution to render very
sparse, 100 millionx100 million matrices that contain values 0 and 1 at
various levels of zoom.   I want to set up a situation where multiple
matrix cells with value 1 that map to the same pixel will be brighter (
closer to pure white ) than pixels that map to only one 1 cell.  If the
answer to the above question is "yes", then I can draw light gray
pixels to represent each "1" with brightness proportional to how
diluted that value is,  and not have to worry about first averaging the
values of the neighbors before drawing.

0
Reply isaacyho (15) 3/10/2006 6:38:46 PM

> In Swing/Java AWT, is there any way to specify pen color parameters so
> that if you draw over a an existing pixel using the same color, that
> the intensity of that pixel increases?    I'm not sure that alpha
> blending works to do what I want:  for instance, say pixel (100,100) is
> very light gray:  I want successive calls to draw pixel (100,100) with
> the same light gray color to make that pixel more and more white.

alpha blending should work.
First time you draw background then
you set AlphaComposite on Graphics2D
and repeatedly draws your image.

-- 
Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities


0
Reply Andrey 3/10/2006 6:53:08 PM


"Andrey Kuznetsov" <spam0@imagero.com.invalid> wrote in message 
news:dushuf$l43$1@online.de...
>> In Swing/Java AWT, is there any way to specify pen color parameters so
>> that if you draw over a an existing pixel using the same color, that
>> the intensity of that pixel increases?    I'm not sure that alpha
>> blending works to do what I want:  for instance, say pixel (100,100) is
>> very light gray:  I want successive calls to draw pixel (100,100) with
>> the same light gray color to make that pixel more and more white.
>
> alpha blending should work.
> First time you draw background then
> you set AlphaComposite on Graphics2D
> and repeatedly draws your image.

    It works if you're drawing on a black background, and using a white 
translucent pen (e.g. RGBA=(255,255,255,128)).

    To do what the OP described regardless of background colour and pen 
colour, I think you'd need a HSL colour model, where the H and S values of 
the pen override the surface values, while the L value is additive (or 
something more complex) against the surface value.

    - Oliver 

0
Reply Oliver 3/10/2006 7:22:48 PM

2 Replies
209 Views

(page loaded in 0.078 seconds)

Similiar Articles:













7/24/2012 3:35:34 AM


Reply: