Use timage in BCB to zoom in and out the image

Source: Internet
Author: User
The copyrect function of the TCanvas object can zoom in and out the image, that is, copy a part of the canvas to another part. The function prototype is as follows:
Void _ fastcall copyrect (const trect & DEST, TCanvas * canvas, const trect & source );
Example:
The following example shows the differences between copyrect and brushcopy. The bitmap icon is loaded into the bitmap and displayed on the canvas of form1. Brushcopy replaces the color of the brush icon on the canvas with black, when the color on the copyrect has not been separated.
Graphics: tbitmap * bitmap;
Trect myrect, myther;
Myrect = rect (10, 10, 100,100 );
Myther = rect (10,111,100,201 );
Bitmap = new graphics: tbitmap;
Bitmap-> loadfromfile (// "C: // windows // tartan.bmp //");
Form1-> canvas-> brushcopy (myrect, bitmap, myrect, clblack );
Form1-> canvas-> copyrect (myther, bitmap-> canvas, myrect );
Delete bitmap;

{
Timage * timage = new timage (this );
Timage-> picture-> loadfromfile (sfilename + tpicname );
Timage-> canvas-> copyrect (trect (3/4, Item_W-3, item_h *), timage-> canvas, timage-> canvas-> cliprect );
Timage-> picture-> Bitmap-> width = Item_W-3;
Timage-> picture-> Bitmap-> Height = item_h * 3/4;
Fitem [ttag]. controls [tidx]-> glyph = timage-> picture-> bitmap;
Delete timage;
Timage = NULL;
}

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.