Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Image Operations
Image Operations [message #466644] Thu, 12 January 2006 06:18 Go to next message
Terry Corbet is currently offline Terry CorbetFriend
Messages: 14
Registered: July 2009
Junior Member
About a zillion years ago, when I taught at IBM, I would kick off a new
with a 'tension releaser', to wit: "We'll follow the convention that
raises his hand to ask a question, we will all know that it is not because
person doesn't understand something; rather one of his neighbors is
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
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
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.

get a GC for the ScreenImage...
use drawImage sourcing MasterImage...
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.
Re: Image Operations [message #467089 is a reply to message #466644] Tue, 24 January 2006 16:50 Go to previous message
Silenio Quarti is currently offline Silenio QuartiFriend
Messages: 31
Registered: July 2009
Have you tried just drawing a part of the image (each frame) directly the
screen instead of having a temporary image. Something like:

final Image largeImage = ...;
Canvas canvas = ...;

canvas.addPaintListener(new PaintListener() {
int currentFrame;
static int FRAME_HEIGHT = XXX;
public void paintControl(PaintEvent event) {
GC gc = event.gc;
Rectangle rect = largeImage.getBounds();
gc.drawImage(largeImage, 0, currentFrame * FRAME_HEIGHT,
rect.width, FRAME_HEIGHT, 0, 0, rect.width, FRAME_HEIGHT);
Previous Topic:re-using a composite
Next Topic:Can I Use Same Java/SWT App on Windows, Linux & PocketPC
Goto Forum:

Current Time: Tue Oct 15 04:41:18 GMT 2019

Powered by FUDForum. Page generated in 0.02640 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top