I am working with Delphi. I am using bmp.ScanLine[]
in my code. My code is as follows :
bmp := TBitmap.Create;
bmp.Height := imgMain.Height;
bmp.Width := imgMain.Width;
for i := 0 to imgMain.Height - 1 do begin
prgb := bmp.ScanLine[i];
p1 := imgMain.ScanLine[i];
for j := 0 to imgMain.Width - 1 do begin
//Some code
end;
end;
Here, imgMain is of TBitmap type. My problem is when I execute this code, it takes too much time on the lines
prgb := bmp.ScanLine[i];
p1 := imgMain.ScanLine[i];
Please, tell me where I am wrong?
Hmm, something can be gained (introducing rowpitch, see below) but that is not too much. Probably changing the for loop to a while loop that does pointer increment and compares with a pointer value of the last pixel
See also rotating bitmaps. In code for a routine that does things like this to rotate an image fast.
Allocating bmps all the time can be expensive too, specially if they are large, use pools to avoid repeated allocation.