Image Operations [message #466644] |
Thu, 12 January 2006 06:18 |
Terry Corbet Messages: 14 Registered: July 2009 |
Junior Member |
|
|
About a zillion years ago, when I taught at IBM, I would kick off a new
class
with a 'tension releaser', to wit: "We'll follow the convention that
whomever
raises his hand to ask a question, we will all know that it is not because
that
person doesn't understand something; rather one of his neighbors is
wrestling
with understanding and s/he is just asking to help the other person."
So, since I have spent the last five days and nights trying to wade through
the myriad of toolkits available for implementing as particular animation
effect that I need inside my SWT application, I finally concluded from all
the technical papers and all the snippets I could understand that I really
DO NOT need to scurry around to try to use OpenGL and I really don't
need to use SWT_AWT's frames in order to get at Java2D classes and
methods. I ought to be able to get very good performance just from
Image and its friends. At least that is the context in which the problem I
am trying to understand/solve is attempted.
Here's the basic design approach.
a. I have an Image [PGN with transparency settings that are very
important].
b. The image is, in fact, multiple images [but not a GIF file with any
attempt to have the file handle animations.] Each sub-image in
the larger file is a well-behaved square of NxN pixels; and the
set of such square bit-maps is just stack one on top of the other.
c. You would likely question why that sort of a file was created in
lieu of some number of individual files for individual images. It
is
because the animation will show transitions during which the
lower portion of 'frame 1' will be shown atop the upper portion
of 'frame 2'. Think of the wheels spinning on the slot machines
in Vegas.
So, at any given callback to the paintControl, all I want to do is
pull out of the larger image the smaller image that should be
rendered in the Canvas widget that is sized NxN -- no difficult
transformations of shape, not even any translation -- just what I
hope will be very fast copies of contiguous pixel arrays between
the proper index into the MasterImage and the ScreenImage.
So:
get a GC for the ScreenImage...
use drawImage sourcing MasterImage...
then
event.gc.drawImage (ScreenImage, 0, 0);
This fails to behave properly because the transparency ImageData
from the MasterImage and the transparency ImageData from the
ScreenImage are not the same.
Finally seeing that the failure is there, I back down to the lower level of
the ImageData object from the level of the Image object, and I
follow the nice example of the arithmetic for doing System.arraycopy()
operations, but the result is really no different. Only after I manipulate
the settings pixel-by-pixel in the ImageData.alphaData can I successfully
move parts of an Image into a double-buffer that correctly renders
inside the widget via drawImage().
So, here's the questions after all that preamble:
a. Is it really true that the paint method -- used in this manner --
has to separately concern itself with the pixel data and the
transparency data with low-level array operations?
b. If not, what did I fail to read that would have told me that?
c. What equivalent to drawImage() ought I use to successfully
copy portions of an image on top of portions of another
image and have the transparency aspect of the image carry
along as one would expect?
Thank you; I do hope my taking the time to explain the matter
in detail will make the time you will spend in replying useful to
a large audience. I don't think I'm the only one who might be
in need of some assistance.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03279 seconds