[JAVA2D] magic magnifying glass in java?
I'm a vision researcher at Indiana University trying to understand how
fingerprint experts match fingerprints (it's not as cool as it appears
on CSI- they have to work really hard to do matches). Because these
experts are all over the country, I'm using java to do vision
experiments over the web. It has worked really well, and now I'm
working on a very demanding application.
I'd like to present two fingerprints on the screen for them to match,
but make them very blurry (I can blur them myself). However, a region
near where the mouse is located should appear clear, sort of like a
magic magnifying glass that they can move around the screen and reveal
features that are not apparent in the blurry version. By tracking the
mouse location over time I can figure out what information or parts of
the fingerprints the experts are using when making comparisons. I can
load both the blurry and clear images into separate offscreen buffers.
What I'd like to do is show the blurry images and then overlay a
portion of the clear images onto the blurry images, but only in a small
circle around where the mouse is.
I also don't like hard edges in my display, so I'd like to use
transparency to soften the edges of the clear image so that it fades to
the blurry image at the edges.
The key here is that it has to go very fast, because I don't want
delays that might affect how the experts process the images. So I guess
I have two questions. First, do you know of a good approach or some
sample code that will do my overlay? And second, is there a way to use
hardware acceleration to make the loop as fast as possible?
I asked Chet Haase this question, and he very kindly sent the following
suggestion, but then suggested I post to this list. I'll append his
response below to have a starting point for the discussion. I'd
appreciate any hints folks have about going as fast as possible.
If you'd like to try your hand at matching fingerprints, send me email
and I'll send you the link and a password.
Thanks so much,
Associate Professor, Department of Psychology and Program in Cognitive
Chet Haase wrote:
I don't have any particular tips on how to implement
what you want; the basics you've listed sound doable.
I would envision something like:
- set your clip to not render into the circle
- copy the blurry image to the back buffer
- set your clip to the inverse (draw only into
- copy the non-blurry image
The translucent border is problematic, especially from
the perspective of hardware acceleration. You might play around
with having your non-blurry image be a translucent image, where
the perimiter went from alpha=0 to alpha=1. To get hw acceleration
for this (only on Windows), use the -Dsun.java2d.translaccel=true
and -Dsun.java2d.ddforcevram=true and possibly
(these flags tell us to use d3d for acceleration of
translucent images, not to punt the back buffer when we detect
translucent operations on the back buffer, and to accelerate
copies from images on the first attempt (not to wait for some
But it's not clear that we will be able to accelerate
this stuff well enough if you have to manipulate the pixels
on every frame. I'd try it out and see how it goes...
To unsubscribe, send email to firstname.lastname@example.org and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
email@example.com and include in the body of the message "help".