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

📄 unit1.cpp

📁 毕业设计图像处理软件及源代码对毕业生会有所帮助
💻 CPP
📖 第 1 页 / 共 2 页
字号:
//---------------------------------------------------------------------------

#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;

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;
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++;
                        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);
}
//---------------------------------------------------------------------------
void TForm1::setcur(int iCurOrder)
{
        if(!bForm2Null[iActForm2])
                fForm2Array[iActForm2]->Image1->Cursor=iCurOrder;
}
void TForm1::f_Form2DoHistroy(int iSpace)
{
        if(!bForm2Null[iActForm2])
        {
                fForm2Array[iActForm2]->iPicNow=(fForm2Array[iActForm2]->iPicEnd+iSpace)%iForm2PicNum;
                fForm2Array[iActForm2]->Image1->Picture->Bitmap->Assign(fForm2Array[iActForm2]->bPicArray[fForm2Array[iActForm2]->iPicNow]);
                fForm2Array[iActForm2]->SetForm3List();
        }
}
void __fastcall TForm1::N9Click(TObject *Sender)
{
        Form7=new TForm7(this);
        Form7->ShowModal();
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N5Click(TObject *Sender)
{
        Form1->Close();        
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N20Click(TObject *Sender)
{
        if(bForm2Null[iActForm2])
                return;
        Form8=new TForm8(this);
        Form8->ShowModal();
        if(iReturnValue)
                fForm2Array[iActForm2]->f_imageSmoothProcess(1);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N22Click(TObject *Sender)
{
        if(bForm2Null[iActForm2])
                return;
        iTNum=3;
        iTemplate[0][0]=0;
        iTemplate[0][1]=1;
        iTemplate[0][2]=0;
        iTemplate[1][0]=1;
        iTemplate[1][1]=-4;
        iTemplate[1][2]=1;
        iTemplate[2][0]=0;
        iTemplate[2][1]=1;
        iTemplate[2][2]=0;
        fForm2Array[iActForm2]->f_imageSmoothProcess(2);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N24Click(TObject *Sender)
{
        if(bForm2Null[iActForm2])
                return;
        Form9=new TForm9(this);
        Form9->ShowModal();
        if(iReturnValue)
                fForm2Array[iActForm2]->f_imageSharpProcess(1);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N25Click(TObject *Sender)
{
        if(bForm2Null[iActForm2])
                return;
        Form10=new TForm10(this);
        Form10->ShowModal();
        if(iReturnValue)
                fForm2Array[iActForm2]->f_imageSmoothProcess(3);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N27Click(TObject *Sender)
{
        if(bForm2Null[iActForm2])
                return;
        fForm2Array[iActForm2]->f_imageColorProcess(1);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N28Click(TObject *Sender)
{
        if(bForm2Null[iActForm2])
                return;
        fForm2Array[iActForm2]->f_imageColorProcess(2);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N29Click(TObject *Sender)
{
        if(bForm2Null[iActForm2])
                return;
        fForm2Array[iActForm2]->f_imageColorProcess(3);        
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N30Click(TObject *Sender)
{
        if(bForm2Null[iActForm2])
                return;
        fForm2Array[iActForm2]->f_imageColorProcess(4);        
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N33Click(TObject *Sender)
{
        if(bForm2Null[iActForm2])
                return;
        fForm2Array[iActForm2]->f_imageColorProcess(5);        
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N32Click(TObject *Sender)
{
        if(bForm2Null[iActForm2])
                return;
        fForm2Array[iActForm2]->f_imageColorProcess(6);
}
//---------------------------------------------------------------------------


void __fastcall TForm1::N34Click(TObject *Sender)
{
        if(bForm2Null[iActForm2])
                return;
        fForm2Array[iActForm2]->f_imageColorProcess(7);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N36Click(TObject *Sender)
{
        if(bForm2Null[iActForm2])
                return;
        fForm2Array[iActForm2]->f_imageSharpProcess(2);
}
//---------------------------------------------------------------------------

void __fastcall TForm1::N37Click(TObject *Sender)

⌨️ 快捷键说明

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