?? unit1.~cpp
字號:
//---------------------------------------------------------------------------
#include <vcl.h>
#include <jpeg.hpp>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
#include "Unit3.h"
#include "Unit4.h"
#include "Unit5.h"
#include "Unit6.h"
#include "Unit7.h"
#include "Unit8.h"
#include "Unit9.h"
#include "Unit10.h"
#include "Unit11.h"
#include "Unit12.h"
#include "Unit14.h"
#include "Unit15.h"
#include "Unit16.h"
#include "Unit19.h"
#include "backwindow.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
TForm *fActForm2;
//---------------------------------------------------------------------------
//變量
TJPEGImage *jpeg;
int iForm2PicNum=10; //圖像框的緩沖數量 //注意必須要和Form2中的iPicNum保持一致
Graphics::TBitmap* bImagetemp; //緩沖圖像
AnsiString sFileName; //新建畫板的變量
TForm2* fForm2Array[50]; //子窗口
bool bForm2Null[50]; //標志窗口是否可用
int iFormNum=50; //子窗數
int iActForm2; //當前活動子窗口
int iForm2Sum=0; //窗口總數
int iGraphStyle=0; //圖形的樣式
int iGraphThick=1; //圖形的粗細
TColor tGraphColor; //圖形顏色
TColor tBrushColor; //填充顏色
TColor tGroundColor; //背景色
bool bIsTransparence=true; //是否透明
int iNewWidth,iNewHeight; //新建畫布寬和高
TRect rnew;
extern int iPointRange; //點運算范圍
int iMASAIKE; //馬賽克顆粒大小
int iExposureColor; //曝光度
TPoint pProcessBegin,pProcessEnd; //處理圖像的開始點和終止點的坐標
float fWr,fWg,fWb; //加權平均圖像處理參數
int iReturnValue; //取值窗口返回值
int ilineB; //灰度變換參數
float flineA; //灰度變換參數
int iTemplate[4][4]; //平滑操作參數 模板
int iTNum=3; //平滑操作參數 模板維度
int iThre=10; //銳化參數 閾值
long lCopyStyle; //合并參數
int iCopyDestop; //截屏時的變量 1最小化全屏,2最小化任意取,11全屏立即拷貝,12立即任意取
bool bFullCopy; //截屏模式
int iMyCursorOrder[10]={10,11,12,13,14,15,16,17,18,19}; //光標
AnsiString helpadd;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
jpeg = new TJPEGImage();
lCopyStyle=SRCCOPY;
iMASAIKE=3;
tBrushColor=TColor(RGB(255,255,255));
helpadd=GetCurrentDir()+"\\help.chm";
Screen->Cursors[10]=LoadCursor(HInstance,"AC_PEN");
Screen->Cursors[11]=LoadCursor(HInstance,"AC_SUCK");
Screen->Cursors[12]=LoadCursor(HInstance,"AC_UPZOOM");
Screen->Cursors[13]=LoadCursor(HInstance,"AC_DOWNZOOM");
Screen->Cursors[14]=LoadCursor(HInstance,"AC_UNZOOM");
Screen->Cursors[15]=LoadCursor(HInstance,"AC_REC");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
delete bImagetemp;
delete jpeg;
}
//---------------------------------------------------------------------------
//創建打開畫板---------------------------------------------------------------
void TForm1::f_CreatePalette()
{
int i,j;
for(i=0;i<iFormNum;i++)
{
if(bForm2Null[i])
{
fForm2Array[i]=new TForm2(this);
bForm2Null[i]=false;
fForm2Array[i]->iOrder=i; //設置此畫板在畫板緩沖區中的位置
iActForm2=i; //設置當前激活的畫板序號
iForm2Sum++; //畫板數目加1
fForm2Array[i]->Caption=sFileName; //設置畫板標題
fForm2Array[i]->lPicWidth=bImagetemp->Width; //設置畫板的高和寬
fForm2Array[i]->lPicHeight=bImagetemp->Height;
fForm2Array[i]->Image1->Picture->Bitmap->Assign(bImagetemp);
for(j=0;j<fForm2Array[i]->iPicNum;j++)
fForm2Array[i]->bPicArray[j]->Assign(bImagetemp);
//設置畫板版面大小
fForm2Array[i]->Panel1->Width=bImagetemp->Width;
fForm2Array[i]->Panel1->Height=bImagetemp->Height;
//調整打開窗口在母窗的位置
if(bImagetemp->Width < this->Width)
{
fForm2Array[i]->Width=bImagetemp->Width+10;
fForm2Array[i]->Left=(this->Width - fForm2Array[i]->Width)/2;
}
else
fForm2Array[i]->Width=this->Width;
if(bImagetemp->Height < this->Height)
fForm2Array[i]->Height=bImagetemp->Height+28;
else
fForm2Array[i]->Height=this->ClientHeight;
fForm2Array[i]->Show();
break;
}
}
if(i>=50)
MessageBox(NULL,"緩沖窗口隊列已滿,無法再打開新窗口.","Warning",MB_ICONWARNING);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N3Click(TObject *Sender)
{
char cJPGNameEnd[5];
char *cpEnd;
if(OpenPictureDialog1->Execute())
{
cpEnd=StrEnd(OpenPictureDialog1->FileName.c_str());
cpEnd-=3;
StrCopy(cJPGNameEnd,cpEnd);
if(!StrComp(cJPGNameEnd,"jpg"))
{
jpeg->LoadFromFile(OpenPictureDialog1->FileName);
bImagetemp->Assign(jpeg);
}
else
bImagetemp->LoadFromFile(OpenPictureDialog1->FileName);
sFileName=OpenPictureDialog1->FileName;
f_CreatePalette();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
int i;
bImagetemp=new Graphics::TBitmap();
for(i=0;i<iFormNum;i++)
{
fForm2Array[i]=NULL;
bForm2Null[i]=true;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
iActForm2=0;
tGroundColor=(TColor)0x00FFFFFF;
tGraphColor=clBlack;
Form3 = new TForm3(this);
Form3->Show();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N10Click(TObject *Sender)
{
if(!bForm2Null[iActForm2])
fForm2Array[iActForm2]->f_imageGray1();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N11Click(TObject *Sender)
{
if(!bForm2Null[iActForm2])
fForm2Array[iActForm2]->f_imageGray2();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N12Click(TObject *Sender)
{
if(bForm2Null[iActForm2])
return;
Form4=new TForm4(this);
Form4->ShowModal();
if(iReturnValue)
fForm2Array[iActForm2]->f_imageGray3(fWr,fWg,fWb);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N41Click(TObject *Sender)
{
if(!bForm2Null[iActForm2])
fForm2Array[iActForm2]->f_imageGray4();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N31Click(TObject *Sender)
{
if(!bForm2Null[iActForm2])
fForm2Array[iActForm2]->f_imageTurnover();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N15Click(TObject *Sender)
{
if(!bForm2Null[iActForm2])
{
if(fForm2Array[iActForm2]->iPicNow==fForm2Array[iActForm2]->iPicEnd)
return;
fForm2Array[iActForm2]->iPicNow--;
fForm2Array[iActForm2]->Image1->Picture->Bitmap->Assign(fForm2Array[iActForm2]->bPicArray[fForm2Array[iActForm2]->iPicNow]);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N16Click(TObject *Sender)
{
if(!bForm2Null[iActForm2])
{
if(((fForm2Array[iActForm2]->iPicNow+1)%iForm2PicNum)==fForm2Array[iActForm2]->iPicBegin)
return;
fForm2Array[iActForm2]->iPicNow++;
fForm2Array[iActForm2]->Image1->Picture->Bitmap->Assign(fForm2Array[iActForm2]->bPicArray[fForm2Array[iActForm2]->iPicNow]);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N17Click(TObject *Sender)
{
int i;
if(bForm2Null[iActForm2])
return;
gotosave:
if(SaveDialog1->Execute())
{
if(FileExists(SaveDialog1->FileName))
{
i=MessageBox(NULL,"您所指定的文件已經存在,是否覆蓋?","Question",MB_YESNOCANCEL|MB_ICONQUESTION);
if(i==IDNO)
goto gotosave;
if(i==IDYES)
{
if(!DeleteFile(SaveDialog1->FileName))
{
MessageBox(NULL,"指定的文件正在使用,無法覆蓋","error",MB_OK|MB_ICONERROR);
goto gotosave;
}
}
else
return;
}
fForm2Array[iActForm2]->Image1->Picture->SaveToFile(SaveDialog1->FileName);
MessageBox(NULL,"保存成功","OK",MB_OK);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N21Click(TObject *Sender)
{
if(bForm2Null[iActForm2])
return;
Form5=new TForm5(this);
Form5->ShowModal();
if(iReturnValue)
fForm2Array[iActForm2]->f_imageBright(ilineB);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N14Click(TObject *Sender)
{
if(bForm2Null[iActForm2])
return;
Form6=new TForm6(this);
Form6->ShowModal();
if(iReturnValue)
fForm2Array[iActForm2]->f_imageContrast(flineA,ilineB);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -