Quote Originally Posted by deathshadow View Post
Probably why NOBODY uses 24 bit bitmap formats -- I'd REALLY recommend upping to RGBA/32 bit format even if you aren't going to use the alpha channel, just for the speed boost, lesser code, etc, etc... Just not having pixels end up breaking qword boundaries would be a huge speedup.
Also, 24-bit pixel format is not supported on any of the today's video cards. It's only useful for storage because you save some 1/4th of disk space. I wouldn't worry about the speed implications of the multiplication, on the modern CPUs (including Intel Atom) it's pretty fast; you'll be more limited by memory bandwidth anyway.

Mind you, the above works in FPC, no clue if delphi allows for that type of pointer math.
The same code for Delphi would be:
Code:
// 24-bit version
procedure SetScanLinePixel24(x, y: Integer; c: Cardinal; Image: TBitmap);
var
 DestPtr: Pointer;
begin
 DestPtr:= Pointer(NativeInt(Image.Scanline[y]) + x * 3);
 // you can replace Move() with two lines of code moving a word and then a byte manually.
 Move(c, DestPtr^, 3);
end;

// 32-bit version
procedure SetScanLinePixel32(x, y: Integer; c: Cardinal; Image: TBitmap);
begin
 // for FPC, replace "NativeInt" with "PtrInt".
 PLongWord(NativeInt(Image.Scanline[y]) + x * 4)^:= c;
end;