⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainform.cpp

📁 C++ BUILDER精彩编程实例集锦(源码)2 第三部分 文件操作 第四部分 图像处理
💻 CPP
字号:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "MainForm.h"
#include "Clipbrd.hpp"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{

}
//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{//new
   this->Image1->Canvas->Pen->Color=clRed;
   this->Image1->Canvas->Pen->Width=5;
   this->Image1->Canvas->Brush->Color=clBlue;
   this->Image1->Canvas->Brush->Style=0;
   this->Image1->Canvas->Ellipse(20,20,400,200);
   
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn2Click(TObject *Sender)
{//open
   if(this->OpenPictureDialog1->Execute())
   {
     this->Image1->Picture->LoadFromFile(this->OpenPictureDialog1->FileName);
   }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn3Click(TObject *Sender)
{//save
  if(this->SavePictureDialog1->Execute())
  {
    this->Image1->Picture->SaveToFile(this->SavePictureDialog1->FileName+".bmp");
  }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn4Click(TObject *Sender)
{//Copy
   Clipboard()->Assign(this->Image1->Picture);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn5Click(TObject *Sender)
{//cut
   Clipboard()->Assign(this->Image1->Picture);
   TRect ARect;
   this->Image1->Canvas->CopyMode=cmWhiteness;
   ARect=Rect(0,0,Image1->Width,Image1->Height);
   this->Image1->Canvas->CopyRect(ARect,Image1->Canvas,ARect);
   this->Image1->Canvas->CopyMode=cmSrcCopy;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::BitBtn6Click(TObject *Sender)
{//Paste
  if(Clipboard()->HasFormat(CF_BITMAP))
  {
     Graphics::TBitmap *Bitmap;
     Bitmap=new Graphics::TBitmap();
     try
     {
       Bitmap->Assign(Clipboard());
       this->Image1->Canvas->Draw(0,0,Bitmap);
       delete Bitmap;
     }
     catch(...)
     {
       delete Bitmap;
     }
  }
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -