Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] SWT drawing operations too slow

Hello,

I wrote something like this in the newsgroup but I didn't get a answer here
so I trying here again.

For a hobby projects I need an angle depend gradient fill for polygons. As
SWT does supporting no angle depend gradient I had to write an own routine.
The method creating the gradient returns a object of type ImageData and
works more or less well.
The next problem was to bring this gradient fill onto a GC but note that
only pixels inside a polygon should be setted.
For this purpose I create a two color image with the same dimensions of the
image and draw a single filled color polygon onto this. Then I extract the
pixels of the two color image (color 0 means transparent and color 1 not)
using this information to set the alpha data of the orginal ImageData. So
finally only the pixel which are inside the polygon are drawn when a Image
(created from this ImageData) is drawn.
The problem is that this all is very slow. Most time is spend on
GC.drawImage() and in the called drawImageAlpha() method.
Is there a better known way to speed up the operation? Can the operations
inside SWT be optimized? When looking through the SWT source I see lot of
conversion which is probably the main time eater.
I also tried to build a Image with only a bitmask attached (rather than the
use of alphachannel). This speed up the drawing operation but operation to
build the mask takes about the same time (there is no way to set the mask of
an ImageData object from outside)

Thanks in advance,
Sebastian




Back to the top