如何将一个BMP图片画在TPanel的中间(也就是让图片居中)用这个API(DrawDibDraw)画图片?谢谢! Delphi / Windows SDK/APIhttp://www.delphi2007.net/DelphiMultimedia/html/delphi_20061026162537198.html
如何将一个BMP图片画在TPanel的中间(也就是让图片居中)用这个API(DrawDibDraw)画图片?谢谢!
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;
谢谢