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!

Source: Internet
Author: User
Tags bmp image
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.