2

I'm looking for some method to draw half transparent figures within the draw2d framework. Currently I'm using setAlpha() of org.eclipse.draw2d.Graphics. The problem is that it slows down the whole UI, if I draw more than one half transparent figure.

Here was another question regarding the perfomance of it [1]. It targets SWT on Linux, I target both Linux and Windows. The windows (Win7) system has a 3D capable graphic card and a i7 q720. The Linux machine is even better equipped and has also 3D, so I think it's not a performance issue of the platform.

My question is: Is there a performant way to achieve alpha blending in draw2d?

I've tried to use OpenGL respectivly LWJGL. Since draw2d and OpenGL can't be mixed up and I must rely on draw2d, I thought I could do something like this: draw2d -> OpenGL -> draw2d here where canvas is the Canvas where the OpenGL drawing happens and c1 is the Canvas where I want to get the drawn OpenGL picture. But my attempt to copy the OpenGL drawings doesn't work it gets me just the underlying Canvas (canvas) background. Besides this I'm not sure if this would improve the "perormance" anyway...

Thanks,
atx

Community
  • 1
  • 1
atx
  • 266
  • 3
  • 15

2 Answers2

0

This issue is known but unsolved. On the mailing list of draw2d there is a thread regarding this issue: mailing list

TL;DR: A possible solution was dropped because of license issues between LWJGL and Eclipse.

atx
  • 266
  • 3
  • 15
0

Make sure all your src/dest images are of the same depth (eg. ARGB) Otherwise, expensive conversions happen during copy (src->dest)

GCs don't allow access to their underlying buffers, afaik. MemoryImageSource might be a way to go.

You can grab your OpenGL drawing images using something like:

BufferedImage capture  = new Robot().createScreenCapture(new Rectangle( canvas.getX(), canvas.getY(), canvas.getWidth(), canvas.getHeight() ) );

Kind of fiddly, but very fast.

I use it to save jpegs of my live animation frames to a folder.

VirtualDub then creates a movie from the frames. Have to play with the frame rate ;)

Great for producing youtube teasers! You can see one here!

Dominic Cerisano
  • 3,522
  • 1
  • 31
  • 44
  • Thanks for your advice! I solved my problem by implementing the half done LwjglGraphics implementation of org.eclipse.draw3d and integrating it into org.eclipse.draw2d. works like a charm. – atx Jan 10 '12 at 07:24