When using the TBitmap wrapper for a GDI bitmap from the unit Graphics I noticed it will always clear out the bitmap (using a PatBlt call) when setting up a bitmap with SetSize( w, h ). When I copy in the bits later on (see routine below) it seems ScanLine is the fastest possibility and not SetDIBits.
function ToBitmap: TBitmap;
var
i, N, x: Integer;
S, D: PAnsiChar;
begin
Result := TBitmap.Create();
Result.PixelFormat := pf32bit;
Result.SetSize( width, height );
S := Src;
D := Result.ScanLine[ 0 ];
x := Integer( Result.ScanLine[ 1 ] ) - Integer( D );
N := width * sizeof( longword );
for i := 0 to height - 1 do begin
Move( S^, D^, N );
Inc( S, N );
Inc( D, x );
end;
end;
The bitmaps I need to work with are quite large (150MB of RGB memory). With these iomages it takes 150ms to simply create an empty bitmap and a further 140ms to overwrite it's contents.
Is there a way of initializing a TBitmap with the correct size WITHOUT initializing the pixels itself and leaving the memory of the pixels uninitialized (eg dirty)? Or is there another way to do such a thing. I know we could work on the pixels in place but this still leaves the 150ms of unnessesary initializtion of the pixels.