BCB中使用TImage對圖象的放大與縮小

來源:互聯網
上載者:User
TCanvas對象的CopyRect函數可以實現圖象的放大與縮小;即把畫布上的一部分拷貝到另一部分。函數原型如下:
void __fastcall CopyRect(const TRect &Dest, TCanvas* Canvas, const TRect &Source);
Example:
下列的密碼舉例說明 CopyRect 和 BrushCopy 之間的不同。 位元影像表徵圖被載入位元影像而且在 Form1 的帆布上被顯示。 BrushCopy 代替在帆布上刷子表徵圖的顏色為黑色, 當 CopyRect 上的顏色尚未脫離的時候。
Graphics::TBitmap *Bitmap;
TRect   MyRect, MyOther;
MyRect = Rect(10,10,100,100);
MyOther = 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(MyOther, Bitmap->Canvas, MyRect);
delete Bitmap;

{
TImage *tImage = new TImage(this);
tImage->Picture->LoadFromFile(sFileName+tPicName);
tImage->Canvas->CopyRect(TRect(0,0,Item_W-3,Item_H*3/4),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;
} 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.