获取 TBitmap 中BitmapInfoHeader 结构信息,试试:
function GetBmiHeader(Bitmap: TBitMap; var bmiHeader: TBitmapInfoHeader): Boolean;
var
hBmp: HBITMAP;
Image: Pointer;
Info: PBitmapInfo;
InfoSize, ImageSize: DWORD;
begin
Result := False;
if Bitmap = nil then
exit;
hBmp := Bitmap.Handle;
GetDIBSizes(hBmp, InfoSize, ImageSize);
Info := AllocMem(InfoSize);
try
Image := nil;
if GetDIB(hBmp, 0, Info^, Image^) then
begin
bmiHeader := Info^.bmiHeader;
Result := True;
end;
finally
FreeMem(Info, InfoSize);
end;
end;
要引用 Graphics 单元,返回结构信息在 bmiHeader 中。