Unit1.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:7k
源码类别:
Delphi/CppBuilder
开发平台:
C++ Builder
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Unit1.h"
- HDC hDC1;
- HDC hDC2;
- int k;
- int i,j;
- //定义两个全局变量用于控制循环
- int w,h;
- //用于存储图像控件的高度和宽度
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::OpenFileClick(TObject *Sender)
- {
- AnsiString filename;
- if(PictureDialog->Execute())
- //显示对话框
- {
- filename=PictureDialog->FileName;
- Image1->Picture->Bitmap->LoadFromFile(filename);
- //显示文件
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FeiRuClick(TObject *Sender)
- {
- PaintBox1->Refresh();
- hDC2=PaintBox1->Canvas->Handle;
- hDC1=Image1->Canvas->Handle;
- for(i=0;i<w;i++)
- {
- BitBlt(hDC2,0,0,i,h,hDC1,w-i,0,SRCCOPY);
- Sleep(10);
- //从左面飞入
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- w=Image1->Width;
- h=Image1->Height;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::KuoSanClick(TObject *Sender)
- {
- PaintBox1->Refresh();
- hDC2=PaintBox1->Canvas->Handle;
- hDC1=Image1->Canvas->Handle;
- i=w/2;
- j=h/2;
- while(i>0)
- {
- BitBlt(hDC2,i,j,w-2*i,h-2*j,hDC1,i,j,SRCCOPY);
- //从中间扩散
- i=i-2;
- j=j-2;
- Sleep(10);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::JiaoChaClick(TObject *Sender)
- {
- PaintBox1->Refresh();
- hDC2=PaintBox1->Canvas->Handle;
- hDC1=Image1->Canvas->Handle;
- for(i=0;i<w;i++)
- {
- for(j=0;j<1;j++)
- {
- BitBlt(hDC2,0,0,i,h/4,hDC1,w-i,0,SRCCOPY);
- BitBlt(hDC2,w-i-2,h/4,i,h/4,hDC1,0,h/4,SRCCOPY);
- BitBlt(hDC2,0,h/2,i,h/4,hDC1,w-i,h/2,SRCCOPY);
- BitBlt(hDC2,w-i-2,3*h/4,i,h/4,hDC1,0,3*h/4,SRCCOPY);
- }
- }
- //交叉飞入效果
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::LiangBianClick(TObject *Sender)
- {
- PaintBox1->Refresh();
- hDC2=PaintBox1->Canvas->Handle;
- hDC1=Image1->Canvas->Handle;
- for(i=0;i<(w/2+1);i++)
- {
- BitBlt(hDC2,i,0,1,h,hDC1,i,0,SRCCOPY);
- BitBlt(hDC2,w-i,0,w,h,hDC1,w-i,0,SRCCOPY);
- //从两面向中间显示
- Sleep(10);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::LaShengClick(TObject *Sender)
- {
- k=0;
- PaintBox1->Refresh();
- hDC2=PaintBox1->Canvas->Handle;
- hDC1=Image1->Canvas->Handle;
- while(k<101)
- {
- for(i=w;i>0;i--)
- {
- BitBlt(hDC2,(i*k)/100,0,1,h,hDC1,i,0,SRCCOPY);
- //从左边向右边拉伸
- }
- k=k+1;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::QingChuClick(TObject *Sender)
- {
- PaintBox1->Refresh();
- hDC2=PaintBox1->Canvas->Handle;
- hDC1=Image1->Canvas->Handle;
- for(i=0;i<w;i++)
- {
- BitBlt(hDC2,w-i,0,i,h,hDC1,w-i,0,SRCCOPY);
- //从右面清除
- Sleep(10);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FanZhuanClick(TObject *Sender)
- {
- PaintBox1->Refresh();
- hDC2=PaintBox1->Canvas->Handle;
- hDC1=Image1->Canvas->Handle;
- BitBlt(hDC2,0,0,w,h,hDC1,0,0,NOTSRCCOPY);
- //颜色反转
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::NongWuClick(TObject *Sender)
- {
- PaintBox1->Refresh();
- hDC2=PaintBox1->Canvas->Handle;
- hDC1=Image1->Canvas->Handle;
- BitBlt(hDC2,0,0,w,h,hDC1,0,0,SRCPAINT);
- //浓雾效果
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::TouMingClick(TObject *Sender)
- {
- PaintBox1->Refresh();
- hDC2=PaintBox1->Canvas->Handle;
- hDC1=Image1->Canvas->Handle;
- BitBlt(hDC2,0,0,w,h,hDC1,0,0,SRCAND);
- //透明效果
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::SMBFClick(TObject *Sender)
- {
- PaintBox1->Refresh();
- hDC2=PaintBox1->Canvas->Handle;
- hDC1=Image1->Canvas->Handle;
- for(i=0;i<w/3;i++)
- {
- for(j=0;j<1;j++)
- {
- BitBlt(hDC2,0,0,i,i,hDC1,w/3-i,h/3-i,SRCCOPY);
- BitBlt(hDC2,w/3,0,w/3,i,hDC1,w/3,h/3-i,SRCCOPY);
- BitBlt(hDC2,w-i,0,i,i,hDC1,2*w/3,h/3-i,SRCCOPY);
- BitBlt(hDC2,0,h/3,i,h/3,hDC1,w/3-i,h/3,SRCCOPY);
- BitBlt(hDC2,w-i,h/3,i,h/3,hDC1,2*w/3,h/3,SRCCOPY);
- BitBlt(hDC2,0,h-i,i,h/3,hDC1,w/3-i,2*h/3,SRCCOPY);
- BitBlt(hDC2,w/3,h-i,w/3,h-i,hDC1,w/3,2*h/3,SRCCOPY);
- BitBlt(hDC2,w-i,h-i,i,i,hDC1,2*w/3,2*h/3,SRCCOPY);
- BitBlt(hDC2,w/2-i/2,h/2-i/2,i,i,hDC1,w/2-i/2,h/2-i/2,SRCCOPY);
- Sleep(10);
- }
- }
- //四面八方效果
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::MenLianClick(TObject *Sender)
- {
- PaintBox1->Refresh();
- int k;
- hDC2=PaintBox1->Canvas->Handle;
- hDC1=Image1->Canvas->Handle;
- for(i=0;i<w/10;i++)
- {
- for(k=0;k<10;k++)
- {
- BitBlt(hDC2,k*w/10,0,i+2,h,hDC1,k*w/10,0,SRCCOPY);
- Sleep(10);
- }
- }
- //门帘效果
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::GongZiClick(TObject *Sender)
- {
- PaintBox1->Refresh();
- hDC2=PaintBox1->Canvas->Handle;
- hDC1=Image1->Canvas->Handle;
- for(i=0;i<3*w/2;i++)
- {
- BitBlt(hDC2,w/3-i/3,h/3-i/3,w/2+2*i/3,i/3,hDC1,w/3-i/3,h/3-i/3,SRCCOPY);
- BitBlt(hDC2,w/3-i/3,2*h/3-1,w/2+2*i/3,i/3,hDC1,w/3-i/3,2*h/3,SRCCOPY);
- BitBlt(hDC2,w/2-i/3,h/3,2*i/3,h/3,hDC1,w/2-i/3,h/3,SRCCOPY);
- Sleep(10);
- }
- //工字效果
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::CloseFileClick(TObject *Sender)
- {
- Image1->Picture->Assign(NULL);
- //取消文件的显示
- }
- //---------------------------------------------------------------------------