Quote Originally Posted by Jonne
Hello. How im able to draw pictures with different rgb's?
Hi Jonne,

You have numerous options available to you. The first and simplest way is to use the pixels property of the TDXDraw surface, like this:-

[pascal]
dxdraw1.surface.pixels[x,y]:=aColor;

[/pascal]

You can also fill an area of the surface, like this:-

[pascal]
var
dst : TRect;
begin
dst.top:=10;
dst.bottom:=30;
dst.left:=10;
dst.right:=30;

dxdraw1.surface.fillRect(dst,aColor);
end;

[/pascal]

In both examples, aColor is a colour value. I'm not sure whether they operate exactly like Delphi's standard TColor, where you specify the colour value in hex like this:- $bbggrr where bb, gg and rr are the values for Blue, Green and Red respectively. I think they may flip the Blue and Red around to the more traditional $rrggbb notation.

You also have another option for drawing on the TDXDraw surface. You can use a TDXImageList, that you load with images (this can be done at design time or dynamically at runtime). To get started, put the images into the TDXImageList at design time as its easier. Then, you can do this:-

[pascal]
dxImageList1.items[0].draw(dxdraw1.surface,xPos,yPos,pattern);

[/pascal]

I use a pattern value of 0 as I have no idea what it does yet. This will draw the image in the image list at position 0 to the surface with its top left corner at xPos,Ypos on the surface. There are lots of different variations on this method that allow you to incorporate alpha blending and other effects.

And last but not least, the TDXDraw surface also has a fairly standard TCanvas property allowing you to plot lines, text, arcs. etc.

[pascal]
with dXDraw1.Surface.Canvas do
begin
Brush.Style := bsClear;
Font.Color := clWhite;
Font.Size := 8;
Font.style:=[fsBold];
Font.name:='Courier New';

TextOut(0,0,'Hello World');

Release;
end;

[/pascal]

You must remember to release the canvas when you've finished using it.

So, bringing this all together, you might have something like this in a TDXTimer onTimer event:-

[pascal]
if dxdraw1.canDraw then
begin
dxdraw1.surface.fill(0); // Clear the draw area

dximagelist1.items[0].draw(dxdraw1.surface,0,0,0);
dximagelist1.items[1].draw(dxdraw1.surface,100,100,0);

with dxdraw1.surface.canvas do
begin
// Use the canvas here
release;
end;

dxdraw1.flip; // You must have doFlip in the options to use this
end;

[/pascal]

You don't have to use flip, but using it makes for a smoother display since the user only sees the new screen when you've finished drawing it. But you must have the doFlip option set in the TDXDraw options. If you are using unDelphiX, to enable hardware acceleration, you should have the following options set to true:- do3D, doDirectX7Mode and doHardware.

You may also want to check out all the examples that come with unDelphiX. They are quite useful.

I hope this helps.