全部博文(788)
分类:
2008-11-05 09:42:18
var
vDrawDIB: THandle;
vBitmapInfoHeader: TBitmapInfoHeader;
vBits: PChar;
vBitmap: TBitmap;
vImageSize: Longword;
vInfoHeaderSize: Longword;
begin
vBitmap := Image1.Picture.Bitmap;
GetDIBSizes(vBitmap.Handle, vInfoHeaderSize, vImageSize);
vDrawDIB := DrawDibOpen;
GetMem(vBits, vImageSize);
with TControlCanvas.Create do try
GetDIB(vBitmap.Handle, vBitmap.Palette, vBitmapInfoHeader, vBits^);
Control := Panel1;
DrawDibDraw(vDrawDIB, Handle,
(Panel1.Width - vBitmap.Width) div 2,
(Panel1.Height - vBitmap.Height) div 2,
vBitmap.Width, vBitmap.Height,
@vBitmapInfoHeader,
vBits, 0, 0, vBitmap.Width, vBitmap.Height, DDF_HALFTONE or DDF_JUSTDRAWIT)
finally
Free;
FreeMem(vBits, vImageSize);
DrawDibClose(vDrawDIB);
end;
end;
谢谢