Skip to main content

[JAVA2D] Soft blending between two images

1 reply [Last post]
Anonymous

I'm creating an application that presents users with a blurred image
and a clear circle that they move around with the mouse. Below is a
screenshot. I do this by maintaining two versions of the image, one
blurred and one clear. I draw the blurred image to the screen and then
create a clipping path and draw the clear image to the screen within
the clipping path. By moving the clipping path around I can move the
clear part around. Java is very fast and very smooth.

The problem is that this creates a hard edge between the two pictures,
and I need a softer transition. Is there a way to do a softer clipping
path, or define a transparency mask that would blend the blurred and
clear image at various proportions at the edges to create a smooth
transition? The kicker is that I need it to be very fast, on the order
of 20 fps or faster.

Thanks,

Tom

Thomas Busey, PhD
Associate Professor
Department of Psychology and Program in Cognitive Science
Indiana University, Bloomington
1101 E. 10th St
Bloomington, IN, 47405
(812) 855-4261
busey@indiana.edu
www.indiana.edu/~busey
AIM / IChat AV: tombusey@mac.com (video feed)

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Jim Graham

We don't support "soft edged clipping" currently since our antialiasing
approach is currently done on a per-operation basis, rather than a global
technique like "Full Screen Antialiasing". This means that repeated AA
operations over the same area will accumulate the coverages on the edges
and if you re-render the same thing many times eventually it just looks
ugly, not antialiased.

Since clipping would reuse the same coverage information for everything
rendered through it, it would end up with this same problem with
over-accumulation on the edges so we don't support it. It wouldn't
necessarily cause a problem with the way you would be using it, but it
wouldn't work (i.e. look good) in general so all clipping is currently
hard-edged.

An alternative could be the following:

Create a temp buffer about the size of your circle including its "fuzzy
edges". Use either a VolatileImage with Transclucency support or a
BufferedImage of type INT_ARGB or INT_ARGB_PRE. Clear it to 0 alpha, fill
it with an antialiased circle of the appropriate size, render your
non-fuzzy image into it with AlphaComposite mode "SrcIn", render that to
the screen. Once you've filled it with the AA circle, you can probably skip
that step (and the Clear) since the "SrcIn" preserves the alphas from use
to use. Try the 3 different image formats I suggested and compare the
performance since this involves multiple operations and performance will
depend on how well each piece is supported and/or accelerated.

Hope that helps...

...jim

--On Monday, February 07, 2005 3:34 PM -0500 Thomas Busey
wrote:

> I'm creating an application that presents users with a blurred image
> and a clear circle that they move around with the mouse. Below is a
> screenshot. I do this by maintaining two versions of the image, one
> blurred and one clear. I draw the blurred image to the screen and then
> create a clipping path and draw the clear image to the screen within
> the clipping path. By moving the clipping path around I can move the
> clear part around. Java is very fast and very smooth.
>
> The problem is that this creates a hard edge between the two pictures,
> and I need a softer transition. Is there a way to do a softer clipping
> path, or define a transparency mask that would blend the blurred and
> clear image at various proportions at the edges to create a smooth
> transition? The kicker is that I need it to be very fast, on the order
> of 20 fps or faster.
>
> Thanks,
>
> Tom
>
>
>
>
> Thomas Busey, PhD
> Associate Professor
> Department of Psychology and Program in Cognitive Science
> Indiana University, Bloomington
> 1101 E. 10th St
> Bloomington, IN, 47405
> (812) 855-4261
> busey@indiana.edu
> www.indiana.edu/~busey
> AIM / IChat AV: tombusey@mac.com (video feed)
>
> =========================================================================
> ==
> To unsubscribe, send email to listserv@java.sun.com and include in the
> body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".