var
ABmpInfo: BITMAPINFO;
DestBytes: PByte;
i, AByteWidth, Row: Integer;
begin
if (Assigned(PImage)) then
begin
// initialize the size of the image
SetSize(FBmpInfoHeader.biWidth, FBmpInfoHeader.biHeight);
// only use the raster when the calculated ByteWidth is different
if (FGS_Raster <> FByteWidth) then
begin
// get the PixelFormat from the BITMAPINFOHEADER
PixelFormat := GetPixelFormatFromBMIH;
// we have to use the raster to get the correct length of a line
AByteWidth := FGS_Raster;
for i := 0 to FBmpInfoHeader.biHeight - 1 do
begin
// get the pointer to the image data of the bitmap line
DestBytes := Scanline[i];
// In Windows we will paint the image bottom first, so we need to start
// at the last row and end at the first row
Row := FBmpInfoHeader.biHeight - 1 - i;
// copy the image memory to the bitmap memory
CopyMemory(DestBytes, PImage + AByteWidth * Row, AByteWidth);
// convert if needed
//TODO: implement convert functions
end;
end else
begin
ABmpInfo.bmiHeader := FBmpInfoHeader;
FGS_ImageDataLoaded := (SetDIBits(0,
Handle, 0, Abs(FBmpInfoHeader.biHeight),
PImage, ABmpInfo, DIB_RGB_COLORS)) > 0;
end;
end;
end;