How can I draw a BMP image in the middle of a tpanel (that is, to center the image) using this API (drawdibdraw? Thank you! Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiMultimedia/html/delphi_20061026162537198.html
How can I draw a BMP image in the middle of a tpanel (that is, to center the image) using this API (drawdibdraw? Thank you!
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;
Thank you.