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;
}