Unit1.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:7k
源码类别:

Delphi/CppBuilder

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.h"
  5.   HDC hDC1;
  6.   HDC hDC2;
  7.   int k;
  8.   int i,j;
  9.   //定义两个全局变量用于控制循环
  10.   int w,h;
  11.   //用于存储图像控件的高度和宽度
  12. //---------------------------------------------------------------------------
  13. #pragma package(smart_init)
  14. #pragma resource "*.dfm"
  15. TForm1 *Form1;
  16. //---------------------------------------------------------------------------
  17. __fastcall TForm1::TForm1(TComponent* Owner)
  18.         : TForm(Owner)
  19. {
  20. }
  21. //---------------------------------------------------------------------------
  22. void __fastcall TForm1::OpenFileClick(TObject *Sender)
  23. {
  24.     AnsiString filename;
  25.     if(PictureDialog->Execute())
  26.     //显示对话框
  27.     {
  28.         filename=PictureDialog->FileName;
  29.         Image1->Picture->Bitmap->LoadFromFile(filename);
  30.         //显示文件
  31.     }
  32. }
  33. //---------------------------------------------------------------------------
  34. void __fastcall TForm1::FeiRuClick(TObject *Sender)
  35. {
  36.     PaintBox1->Refresh();
  37.     hDC2=PaintBox1->Canvas->Handle;
  38.     hDC1=Image1->Canvas->Handle;
  39.     for(i=0;i<w;i++)
  40.     {
  41.         BitBlt(hDC2,0,0,i,h,hDC1,w-i,0,SRCCOPY);
  42.         Sleep(10);
  43.         //从左面飞入
  44.     }
  45.         
  46. }
  47. //---------------------------------------------------------------------------
  48. void __fastcall TForm1::FormCreate(TObject *Sender)
  49. {
  50.     w=Image1->Width;
  51.     h=Image1->Height;
  52.         
  53. }
  54. //---------------------------------------------------------------------------
  55. void __fastcall TForm1::KuoSanClick(TObject *Sender)
  56. {
  57.     PaintBox1->Refresh();
  58.     hDC2=PaintBox1->Canvas->Handle;
  59.     hDC1=Image1->Canvas->Handle;
  60.     i=w/2;
  61.     j=h/2;
  62.     while(i>0)
  63.     {
  64.         BitBlt(hDC2,i,j,w-2*i,h-2*j,hDC1,i,j,SRCCOPY);
  65.         //从中间扩散
  66.         i=i-2;
  67.         j=j-2;
  68.         Sleep(10);
  69.     }
  70.         
  71. }
  72. //---------------------------------------------------------------------------
  73. void __fastcall TForm1::JiaoChaClick(TObject *Sender)
  74. {
  75.     PaintBox1->Refresh();
  76.     hDC2=PaintBox1->Canvas->Handle;
  77.     hDC1=Image1->Canvas->Handle;
  78.     for(i=0;i<w;i++)
  79.     {
  80.         for(j=0;j<1;j++)
  81.         {
  82.             BitBlt(hDC2,0,0,i,h/4,hDC1,w-i,0,SRCCOPY);
  83.             BitBlt(hDC2,w-i-2,h/4,i,h/4,hDC1,0,h/4,SRCCOPY);
  84.             BitBlt(hDC2,0,h/2,i,h/4,hDC1,w-i,h/2,SRCCOPY);
  85.             BitBlt(hDC2,w-i-2,3*h/4,i,h/4,hDC1,0,3*h/4,SRCCOPY);
  86.         }
  87.     }
  88.     //交叉飞入效果
  89.         
  90. }
  91. //---------------------------------------------------------------------------
  92. void __fastcall TForm1::LiangBianClick(TObject *Sender)
  93. {
  94.     PaintBox1->Refresh();
  95.     hDC2=PaintBox1->Canvas->Handle;
  96.     hDC1=Image1->Canvas->Handle;
  97.     for(i=0;i<(w/2+1);i++)
  98.     {
  99.         BitBlt(hDC2,i,0,1,h,hDC1,i,0,SRCCOPY);
  100.         BitBlt(hDC2,w-i,0,w,h,hDC1,w-i,0,SRCCOPY);
  101.         //从两面向中间显示
  102.         Sleep(10);
  103.     }
  104.         
  105. }
  106. //---------------------------------------------------------------------------
  107. void __fastcall TForm1::LaShengClick(TObject *Sender)
  108. {
  109.     k=0;
  110.     PaintBox1->Refresh();
  111.     hDC2=PaintBox1->Canvas->Handle;
  112.     hDC1=Image1->Canvas->Handle;
  113.     while(k<101)
  114.     {
  115.         for(i=w;i>0;i--)
  116.         {
  117.             BitBlt(hDC2,(i*k)/100,0,1,h,hDC1,i,0,SRCCOPY);
  118.             //从左边向右边拉伸
  119.         }
  120.     k=k+1;
  121.     }
  122.         
  123. }
  124. //---------------------------------------------------------------------------
  125. void __fastcall TForm1::QingChuClick(TObject *Sender)
  126. {
  127.     PaintBox1->Refresh();
  128.     hDC2=PaintBox1->Canvas->Handle;
  129.     hDC1=Image1->Canvas->Handle;
  130.     for(i=0;i<w;i++)
  131.     {
  132.         BitBlt(hDC2,w-i,0,i,h,hDC1,w-i,0,SRCCOPY);
  133.         //从右面清除
  134.         Sleep(10);
  135.     }
  136.         
  137. }
  138. //---------------------------------------------------------------------------
  139. void __fastcall TForm1::FanZhuanClick(TObject *Sender)
  140. {
  141.     PaintBox1->Refresh();
  142.     hDC2=PaintBox1->Canvas->Handle;
  143.     hDC1=Image1->Canvas->Handle;
  144.     BitBlt(hDC2,0,0,w,h,hDC1,0,0,NOTSRCCOPY);
  145.     //颜色反转
  146.         
  147. }
  148. //---------------------------------------------------------------------------
  149. void __fastcall TForm1::NongWuClick(TObject *Sender)
  150. {
  151.     PaintBox1->Refresh();
  152.     hDC2=PaintBox1->Canvas->Handle;
  153.     hDC1=Image1->Canvas->Handle;
  154.     BitBlt(hDC2,0,0,w,h,hDC1,0,0,SRCPAINT);
  155.     //浓雾效果
  156.         
  157. }
  158. //---------------------------------------------------------------------------
  159. void __fastcall TForm1::TouMingClick(TObject *Sender)
  160. {
  161.     PaintBox1->Refresh();
  162.     hDC2=PaintBox1->Canvas->Handle;
  163.     hDC1=Image1->Canvas->Handle;
  164.     BitBlt(hDC2,0,0,w,h,hDC1,0,0,SRCAND);
  165.     //透明效果
  166.         
  167. }
  168. //---------------------------------------------------------------------------
  169. void __fastcall TForm1::SMBFClick(TObject *Sender)
  170. {
  171.     PaintBox1->Refresh();
  172.     hDC2=PaintBox1->Canvas->Handle;
  173.     hDC1=Image1->Canvas->Handle;
  174.     for(i=0;i<w/3;i++)
  175.     {
  176.         for(j=0;j<1;j++)
  177.         {
  178.             BitBlt(hDC2,0,0,i,i,hDC1,w/3-i,h/3-i,SRCCOPY);
  179.             BitBlt(hDC2,w/3,0,w/3,i,hDC1,w/3,h/3-i,SRCCOPY);
  180.             BitBlt(hDC2,w-i,0,i,i,hDC1,2*w/3,h/3-i,SRCCOPY);
  181.             BitBlt(hDC2,0,h/3,i,h/3,hDC1,w/3-i,h/3,SRCCOPY);
  182.             BitBlt(hDC2,w-i,h/3,i,h/3,hDC1,2*w/3,h/3,SRCCOPY);
  183.             BitBlt(hDC2,0,h-i,i,h/3,hDC1,w/3-i,2*h/3,SRCCOPY);
  184.             BitBlt(hDC2,w/3,h-i,w/3,h-i,hDC1,w/3,2*h/3,SRCCOPY);
  185.             BitBlt(hDC2,w-i,h-i,i,i,hDC1,2*w/3,2*h/3,SRCCOPY);
  186.             BitBlt(hDC2,w/2-i/2,h/2-i/2,i,i,hDC1,w/2-i/2,h/2-i/2,SRCCOPY);
  187.             Sleep(10);
  188.         }
  189.     }
  190.     //四面八方效果
  191.         
  192. }
  193. //---------------------------------------------------------------------------
  194. void __fastcall TForm1::MenLianClick(TObject *Sender)
  195. {
  196.     PaintBox1->Refresh();
  197.     int k;
  198.     hDC2=PaintBox1->Canvas->Handle;
  199.     hDC1=Image1->Canvas->Handle;
  200.     for(i=0;i<w/10;i++)
  201.     {
  202.         for(k=0;k<10;k++)
  203.         {
  204.             BitBlt(hDC2,k*w/10,0,i+2,h,hDC1,k*w/10,0,SRCCOPY);
  205.             Sleep(10);
  206.         }
  207.     }
  208.     //门帘效果
  209.         
  210. }
  211. //---------------------------------------------------------------------------
  212. void __fastcall TForm1::GongZiClick(TObject *Sender)
  213. {
  214.     PaintBox1->Refresh();
  215.     hDC2=PaintBox1->Canvas->Handle;
  216.     hDC1=Image1->Canvas->Handle;
  217.     for(i=0;i<3*w/2;i++)
  218.         {
  219.             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);
  220.             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);
  221.             BitBlt(hDC2,w/2-i/3,h/3,2*i/3,h/3,hDC1,w/2-i/3,h/3,SRCCOPY);
  222.             Sleep(10);
  223.         }
  224.     //工字效果
  225.         
  226. }
  227. //---------------------------------------------------------------------------
  228. void __fastcall TForm1::CloseFileClick(TObject *Sender)
  229. {
  230.     Image1->Picture->Assign(NULL);
  231.     //取消文件的显示   
  232.         
  233. }
  234. //---------------------------------------------------------------------------