📄 form1.h
字号:
this->lblMode->Location = System::Drawing::Point(30, 60);
this->lblMode->Name = L"lblMode";
this->lblMode->Size = System::Drawing::Size(66, 17);
this->lblMode->TabIndex = 2;
this->lblMode->Text = L"Mode = ";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label2->Location = System::Drawing::Point(92, 19);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(52, 17);
this->label2->TabIndex = 1;
this->label2->Text = L"label2";
this->label2->Click += gcnew System::EventHandler(this, &Form1::label2_Click);
//
// lblMean
//
this->lblMean->AutoSize = true;
this->lblMean->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 10, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->lblMean->Location = System::Drawing::Point(30, 19);
this->lblMean->Name = L"lblMean";
this->lblMean->Size = System::Drawing::Size(66, 17);
this->lblMean->TabIndex = 0;
this->lblMean->Text = L"Mean = ";
//
// pnlBottom
//
this->pnlBottom->BackColor = System::Drawing::SystemColors::GradientActiveCaption;
this->pnlBottom->Location = System::Drawing::Point(13, 401);
this->pnlBottom->Name = L"pnlBottom";
this->pnlBottom->Size = System::Drawing::Size(537, 134);
this->pnlBottom->TabIndex = 8;
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::SystemColors::ActiveCaption;
this->ClientSize = System::Drawing::Size(727, 547);
this->Controls->Add(this->pnlFilter);
this->Controls->Add(this->pnlBottom);
this->Controls->Add(this->panel3);
this->Controls->Add(this->panel4);
this->Controls->Add(this->pnlMain);
this->Controls->Add(this->panel1);
this->Controls->Add(this->menuStrip1);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::Fixed3D;
this->MainMenuStrip = this->menuStrip1;
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->menuStrip1->ResumeLayout(false);
this->menuStrip1->PerformLayout();
this->panel1->ResumeLayout(false);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->EndInit();
this->pnlStat->ResumeLayout(false);
this->pnlStat->PerformLayout();
this->pnlFilter->ResumeLayout(false);
this->pnlMain->ResumeLayout(false);
this->panel4->ResumeLayout(false);
this->panel4->PerformLayout();
this->panel3->ResumeLayout(false);
this->panel3->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void fileToolStripMenuItem1_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void openToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
//openFileDialog1->Filter = "Bitmap Image|*.bmp|All Files|*.*";
if(openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK)
{
System::IO::StreamReader ^ sr = gcnew
System::IO::StreamReader(openFileDialog1->FileName);
/*MessageBox::Show(sr->ReadToEnd());
sr->Close();*/
filename = openFileDialog1->FileName;
pictureBox1->Image = Bitmap::FromFile(filename);
btnStat->Enabled = true;
}
}
//################################################################################
private: System::Void menuStrip1_ItemClicked(System::Object^ sender, System::Windows::Forms::ToolStripItemClickedEventArgs^ e) {
}
private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) {
char* filename1 = (char*)(void*)Marshal::StringToHGlobalAnsi(filename);
CImage ci(filename1);
//Enable the labels
lblMean->Visible = true;
lblMedian->Visible = true;
lblMode->Visible = true;
lblStdv->Visible = true;
//Assign Values to the label.
label2->Text = ci.mean().ToString();
label6->Text = ci.median().ToString();
label4->Text = ci.mode().ToString ();
label8->Text = ci.stdv().ToString();
lblHeight->Text = ci.Img_Height().ToString ();
label11->Visible = true;
lblWidth->Text = ci.Img_Width ().ToString ();
pnlStat->Visible = true;
pnlBottom->Visible = false;
}
private: System::Void fileToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void label2_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button1_Click_2(System::Object^ sender, System::EventArgs^ e) {
pnlStat->Visible = false;
pnlBottom->Visible = true;
}
private: System::Void btnHistogram_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void btnFilter_Click(System::Object^ sender, System::EventArgs^ e) {
pnlFilter->Visible = true;
pnlBottom->Visible = true;
}
private: System::Void btnFilMain_Click(System::Object^ sender, System::EventArgs^ e) {
pnlFilter->Visible = false;
pnlStat->Visible = false;
pnlMain->Visible = true;
}
private: System::Void btnMean_Click(System::Object^ sender, System::EventArgs^ e) {
///////////////////////////////////////////////////
CPen penRed(PS_SOLID,1,RGB(250,0,0));
CPen *pOldPen = NULL;
/////////////////////////////////////////////////////
}
};
}
/*
class CImage
{
public:
//CImage(const char* filename);
//################################################
CImage(const char* filename)
{
std::ifstream m_pInFile (filename, std::ios::in|std::ios::binary);
m_pInFile.read ((char*)&headfirst.type, sizeof(headfirst.type));
m_pInFile.read ((char*)&headfirst.size, sizeof(headfirst.size));
m_pInFile.read ((char*)&headfirst.reserved1, sizeof(headfirst.reserved1) );
m_pInFile.read ((char*)&headfirst.reserved2, sizeof(headfirst.reserved2) );
m_pInFile.read ((char*)&headfirst.offset, sizeof(headfirst.offset));
std::cout<<"\n########################################################";
std::cout<<"\nTYPE : "<<headfirst.type;
std::cout<<"\nSIZE : "<<headfirst.size;
std::cout<<"\nOFFSET : "<<headfirst.offset;
std::cout<<"\n########################################################";
OFFSET = headfirst.offset;
m_pInFile.read ((char*)&headsecond.size, sizeof(headsecond.size));
m_pInFile.read ((char*)&headsecond.width, sizeof(headsecond.width));
m_pInFile.read ((char*)&headsecond.height, sizeof(headsecond.height));
m_pInFile.read ((char*)&headsecond.planes, sizeof(headsecond.planes));
m_pInFile.read ((char*)&headsecond.bits, sizeof(headsecond.bits));
m_pInFile.read ((char*)&headsecond.compression, sizeof(headsecond.compression));
m_pInFile.read ((char*)&headsecond.imagesize, sizeof(headsecond.imagesize));
m_pInFile.read ((char*)&headsecond.xresolution, sizeof(headsecond.xresolution));
m_pInFile.read ((char*)&headsecond.yresolution, sizeof(headsecond.yresolution));
m_pInFile.read ((char*)&headsecond.ncolors, sizeof(headsecond.ncolors));
m_pInFile.read ((char*)&headsecond.importantcolors, sizeof(headsecond.importantcolors));
std::cout<<"\n########################################################";
std::cout<<"\nSIZE : "<<headsecond.size;
std::cout<<"\nWIDTH: "<<headsecond.width;
std::cout<<"\nHEIGHT : "<<headsecond.height;
std::cout<<"\nCOLORS: "<<headsecond.ncolors;
std::cout<<"\nIMAGE SIZE: "<<headsecond.imagesize;
std::cout<<"\nbits SIZE: "<<headsecond.bits;
std::cout<<"\n########################################################";
HEIGHT = headsecond.height;
WIDTH = headsecond.width;
ISIZE = headsecond.imagesize;
/////////////////////////////////////////////////
//printf("\n sizeof2 %d",sizeof(headsecond));
///////////////////////////////////////////////////
m_pInFile.close();
m_cHeaderData = new unsigned char [OFFSET];
m_cImageData = new unsigned char* [HEIGHT];
m_cFilteredData = new unsigned char* [HEIGHT];
for( int i = 0; i < HEIGHT; i++)
{
m_cImageData[i] = new unsigned char [ISIZE/HEIGHT];
m_cFilteredData[i] = new unsigned char [ISIZE/HEIGHT];
}
m_pInFile1 = new std::ifstream;
m_pInFile1->open(filename, std::ios::in | std::ios::binary);
m_pInFile1->seekg(0, std::ios::beg);
m_pInFile1->read(reinterpret_cast<char*>(m_cHeaderData),OFFSET);
//cout<<"\nData -> "<<m_cHeaderData;
std::cout<<"\nvalue of HEIGHT : "<<HEIGHT;
std::cout<<"\nvalue of WIDTH : "<<WIDTH;
std::cout<<"\nSIZE OF F-HEADER : "<<sizeof(headfirst);
std::cout<<"\nSIZE OF I-HEADER : "<<sizeof(headsecond);
for( int i = 0; i < HEIGHT; i++)
{
m_pInFile1->read(reinterpret_cast<char *>(m_cImageData[i]), ISIZE/HEIGHT);
}
m_pInFile1->close();
// define the filter for the image
char m_cFilter[3][3] = {
{1, 1, 1},
{1, 2, 1},
{1, 1, 1}
};
}//Constructor Closing
////#############################################
//~CImage();
//void write(const char* filename);
//double mean();
//##############################################
double CImage::mean()
{
double total = 0;
for(int i = 0; i < HEIGHT; i++)
{
for(int j = 0; j < WIDTH; j++)
{
total += m_cImageData[i][j];
}
}
return (total / (HEIGHT * WIDTH));
}
//###############################################
//double stdv();
//double mode();
//double median();
//void filter();
private:
std::ifstream* m_pInFile;
std::ifstream* m_pInFile1;
std::ofstream* m_pOutFile;
unsigned char* m_cHeaderData;
unsigned char** m_cImageData;
unsigned char m_cFilter[3][3];
unsigned char** m_cFilteredData;
};*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -