PDA

View Full Version : DXDRAW - images and shapes



shep
26-06-2004, 12:21 PM
I have a problem with mixing images (from DXImagelist) with shapes (rectangles, ellipses).
Drawing a shape prevents images being drawn
ie if the processing sequence is image1, rectangle, ellipse, image2 then image1 is drawn OK as are the rectangle and ellipse but image2 is not drawn. If I process all the images first in a separate loop followed by a loop for shapes then all images and shapes are drawn OK. However this means that where overlaps occur images are always obscured by shapes. I need the user to determine the sequence of drawing and thus to control which objects are drawn on top.

The code I have used is:
DXDraw1.Surface.Fill( clGreen );
with DXDraw1.Surface.Canvas do
begin
for obj_ptr:=0 to obj_count - 1 do
begin
dxdraw1.surface.canvas.Brush.color:=my_objects_col or[obj_ptr];
dxdraw1.surface.canvas.brush.style:=bssolid;
case my_objects[obj_ptr] of
1: rectangle(my_objects_x1[obj_ptr],my_objects_y1[obj_ptr],
my_objects_x1[obj_ptr] + my_objects_x2[obj_ptr],
my_objects_y1[obj_ptr] + my_objects_y2[obj_ptr]);
2: ellipse(my_objects_x1[obj_ptr],my_objects_y1[obj_ptr],
my_objects_x1[obj_ptr] + my_objects_x2[obj_ptr],
my_objects_y1[obj_ptr] + my_objects_y2[obj_ptr]);
4: dximagelist1.Items[my_objects_image[obj_ptr]].draw(DXDraw1.Surface,
my_objects_x1[obj_ptr],my_objects_y1[obj_ptr],0);
end; // end case
end; // end loop thru objects
dxdraw1.surface.canvas.Release;
end; // end with canvas

DXdraw1.Flip;

I hope that I have explained the problem adequately and that someone can suggest a solution to the problem (the object of the program is garden design and I anticipate a maximum of 200 objects to be drawn). I'm using Windows98, Delphi Personal 6 and DelphiX 2000.07.17.

[Edit by Useless Hacker - added pascal tags]

Paulius
26-06-2004, 04:04 PM
I don't use DelphiX, but I'm sure Release should be called after using canvas functions on a surface before you can draw to it normally.

shep
28-06-2004, 10:57 AM
Yes That has fixed it. I had misunderstood the purpose of'release' as in all the examples I had seen it was only issued once at the end of all drawing - which is Ok unless images are added to the surface. Thanks