I have an array of record with 3 member ( bitmap path , x , y ) .
I have to after load values in record draw bitmap on Form canvas by x , y .
I tried with this code :
const
MAXX = 40 ;
type
ImgObj = record
Addrs : string;
X: Integer ;
Y: Integer ;
end;
var
All : array[1..MAXX] of ImgObj ;
procedure TForm1.btn1Click(Sender: TObject);
var
BuffBitmap :TBitmap ;
I,j,k: Integer;
begin
// set all bit maps
....
// draw 40 images
BuffBitmap := TBitmap.Create ;
for I := 1 to MAXX do
begin
BuffBitmap.LoadFromFile(All[i].Addrs);
for j := 0 to BuffBitmap.Width-1 do
for k := 0 to BuffBitmap.Height-1 do
begin
Self.Canvas.Pixels[All[i].X+j,All[i].Y+k] := BuffBitmap.Canvas.Pixels[j,k] ;
end;
end;
BuffBitmap.free;
end;
This code draw them well , but in long time about 8 sec . and I must repeat this event more in my app.
Now how I can go to fastest way for draw 40 images on canvas.
- Should I store bitmpas on memory for repeat ?
- Should I user pointer for draw images ?
- Or should I use threads for fastest draw ?
Please tell me with samples thanks.