Hi everyone!
I have been doing some testing using images created with DirectGraphics-methods and found out the following:
1. The transparency of images created with DirectGraphics is lost when drawing through an ordinary Graphics-object. Drawing through a DirectGraphics-object fixes the problem.
Ok, this i can live with, BUT:
2. Clipping does not work when drawing an image through DirectGraphics into a mutable image. Instead of a clipped image the whole image is drawn. The clipping only seems to work when drawing directly to the screen in the paint-method.
For example (in FullCanvas paint-method):
a)
g.setClip(0, 0, 60, 60);
DirectGraphics dg = DirectUtils.getDirectGraphics(g);
dg.drawImage(directGraphicsImage, 0, 0, Graphics.LEFT|Graphics.TOP, 0);
b)
// earlier I've initialized an image background and gotten
// the Graphics-object for it via getGraphics
backgroundGraphics.setClip(0, 0, 60, 60);
DirectGraphics dg = DirectUtils.getDirectGraphics(backgroundGraphics);
dg.drawImage(directGraphicsImage, 0, 0, Graphics.LEFT|Graphics.TOP, 0);
g.drawImage(background, 0, 0, Graphics.LEFT|Graphics.TOP);
So of these two examples a) clips properly into a 60x60 rectangle and b) does not (but draws the entire image).
Clipping has been a very convenient way to draw animated sprites until now, but it seems I cannot do it any more with DirectGraphics-images? The alternative would be to create a separate image for each of the sprite's frames which would cause a lot of unnecessary memoryloss.
Is there any workaround for this problem? Am I doing something wrong? I already tried creating the background-image using DirectGraphics createImage-method - did not help.
Johan

Reply With Quote



