Unit1.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:3k
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- TRect rc;
- rc.Left=0;
- rc.Right=Image1->Width;
- rc.Top=0;
- rc.Bottom=Image1->Height;
- Image1->Canvas->CopyMode=cmSrcPaint;
- Image1->Canvas->CopyRect(rc,Image2->Canvas,rc);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button2Click(TObject *Sender)
- {
- TRect rc;
- Image3->Width=Image1->Width;
- Image3->Height=Image1->Height;
- rc.Left=0;
- rc.Right=Image1->Width;
- rc.Top=0;
- rc.Bottom=Image1->Height;
- Image3->Canvas->CopyMode=cmSrcCopy;
- Image3->Canvas->CopyRect(rc,Image1->Canvas,rc);
- Image1->Canvas->Brush->Color=clWhite;
- Image1->Canvas->FillRect(rc);
- ID=0;
- Timer1->Enabled=True;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::PaintBlocks(int xbg,int ybg)
- {
- TRect rc;
- int CurX,CurY,xnn,ynn;
- xnn=Image1->Width/10+1;
- ynn=Image1->Height/10+1;
- for(CurX=xbg;CurX<xnn;CurX+=2)
- for(CurY=ybg;CurY<ynn;CurY+=2)
- {
- rc.Left=CurX*10;
- rc.Right=rc.Left+10;
- rc.Top=CurY*10;
- rc.Bottom=rc.Top+10;
- Image1->Canvas->CopyMode=cmSrcCopy;
- Image1->Canvas->CopyRect(rc,Image3->Canvas,rc);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Timer1Timer(TObject *Sender)
- {
- if(ID==0)
- {
- PaintBlocks(0,0);
- }
- else if(ID==1)
- {
- PaintBlocks(1,1);
- }
- else if(ID==2)
- {
- PaintBlocks(1,0);
- }
- else
- {
- PaintBlocks(0,1);
- Timer1->Enabled=False;
- }
- ID++;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Button3Click(TObject *Sender)
- {
- TRect rc;
- rc.Left=0;
- rc.Right=Image1->Width;
- rc.Top=0;
- rc.Bottom=Image1->Height;
- Image1->Canvas->CopyMode=cmSrcPaint;
- Image1->Canvas->CopyRect(rc,Image2->Canvas,rc);
- Image4->Canvas->CopyMode=cmMergePaint;
- Image4->Canvas->CopyRect(rc,Image2->Canvas,rc);
- Image1->Canvas->CopyMode=cmSrcAnd;
- Image1->Canvas->CopyRect(rc,Image4->Canvas,rc);
- }
- //---------------------------------------------------------------------------