CreateDIBitmap试试
另外附上一个
function BitmapToDIBHandle(Bitmap: TBitmap): THandle;
var
MS: TMemoryStream;
DIBHandle: THandle;
p: Pointer;
begin
MS := TMemoryStream.Create;
try
Bitmap.SaveToStream(MS);
DIBHandle := GlobalAlloc(GHND, MS.Size - SizeOf(TBitmapFileHeader));
if DIBHandle = 0 then Raise Exception.Create('Cannot Get Memory');
try
p := GlobalLock(DIBHandle);
try
System.Move((PChar(MS.Memory) + SizeOf(TBitmapFileHeader))^,
p^,
MS.Size - SizeOf(TBitmapFileHeader));
finally
GlobalUnlock(DIBHandle);
end;
Result := DIBHandle;
except
GlobalFree(DIBHandle);
raise;
end;
finally
MS.Free;
end;
end;