Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:1k
源码类别:

VC书籍

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma resource "*.dfm"
  8. TForm1 *Form1;
  9. //---------------------------------------------------------------------------
  10. __fastcall TForm1::TForm1(TComponent* Owner)
  11.         : TForm(Owner)
  12. {
  13. }
  14. //---------------------------------------------------------------------------
  15. void __fastcall TForm1::Button1Click(TObject *Sender)
  16. {
  17.   int x,y;
  18.   TRect src,drc;
  19.   x=Image1->Width;
  20.   y=Image1->Height;
  21.   Image2->Width=x;
  22.   Image2->Height=y;
  23.   src=Rect(0,0,x,y);
  24.   drc=Rect(x,0,0,y);
  25.   Image2->Canvas->CopyMode=cmSrcCopy;
  26.   Image2->Canvas->CopyRect(drc,Image1->Canvas,src);
  27. }
  28. //---------------------------------------------------------------------------
  29. void __fastcall TForm1::Button2Click(TObject *Sender)
  30. {
  31.   int x,y;
  32.   TRect src,drc;
  33.   x=Image1->Width;
  34.   y=Image1->Height;
  35.   Image2->Width=x;
  36.   Image2->Height=y;
  37.   src=Rect(0,0,x,y);
  38.   drc=Rect(0,y,x,0);
  39.   Image2->Canvas->CopyMode=cmSrcCopy;
  40.   Image2->Canvas->CopyRect(drc,Image1->Canvas,src);
  41. }
  42. //---------------------------------------------------------------------------