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

📄 form1.h

📁 我的新光盘里的"如何绘制汽车速度计的设计"有点用吧
💻 H
字号:
#pragma once


namespace Example
{
	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary> 
	/// Form1 摘要
	///
	/// 警告: 如果您更改该类的名称,则需要更改 
	///          与该类所依赖的所有 .resx 文件关联的托管资源编译器工具的 
	///          “资源文件名”属性。  否则,
	///          设计器将不能与此窗体关联的
	///          本地化资源正确交互。
	/// </summary>
	public __gc class Form1 : public System::Windows::Forms::Form
	{	
	public:
		Form1(void)
		{
			InitializeComponent();
		}
  
	protected:
		void Dispose(Boolean disposing)
		{
			if (disposing && components)
			{
				components->Dispose();
			}
			__super::Dispose(disposing);
		}
	private: System::Windows::Forms::PictureBox *  pictureBox1;
	private: System::Windows::Forms::Button *  button1;
	private: System::Windows::Forms::Button *  button2;
	private: System::Windows::Forms::OpenFileDialog *  openFileDialog1;
	private: System::Windows::Forms::Button *  button3;
	private: System::Windows::Forms::Button *  button4;


	private:
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		System::ComponentModel::Container * components;

		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		void InitializeComponent(void)
		{
			System::Resources::ResourceManager *  resources = new System::Resources::ResourceManager(__typeof(Example::Form1));
			this->pictureBox1 = new System::Windows::Forms::PictureBox();
			this->button1 = new System::Windows::Forms::Button();
			this->button2 = new System::Windows::Forms::Button();
			this->openFileDialog1 = new System::Windows::Forms::OpenFileDialog();
			this->button3 = new System::Windows::Forms::Button();
			this->button4 = new System::Windows::Forms::Button();
			this->SuspendLayout();
			// 
			// pictureBox1
			// 
			this->pictureBox1->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
			this->pictureBox1->Image = (__try_cast<System::Drawing::Image *  >(resources->GetObject(S"pictureBox1.Image")));
			this->pictureBox1->Location = System::Drawing::Point(0, 0);
			this->pictureBox1->Name = S"pictureBox1";
			this->pictureBox1->Size = System::Drawing::Size(352, 192);
			this->pictureBox1->TabIndex = 0;
			this->pictureBox1->TabStop = false;
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(0, 200);
			this->button1->Name = S"button1";
			this->button1->Size = System::Drawing::Size(80, 23);
			this->button1->TabIndex = 1;
			this->button1->Text = S"浏览图像";
			this->button1->Click += new System::EventHandler(this, button1_Click);
			// 
			// button2
			// 
			this->button2->Location = System::Drawing::Point(80, 200);
			this->button2->Name = S"button2";
			this->button2->Size = System::Drawing::Size(88, 23);
			this->button2->TabIndex = 2;
			this->button2->Text = S"红蓝色旋转";
			this->button2->Click += new System::EventHandler(this, button2_Click);
			// 
			// openFileDialog1
			// 
			this->openFileDialog1->Filter = S"Image files (JPeg, Gif, Bmp, etc.)|*.jpg;*.jpeg;*.gif;*.bmp;*.tif; *.tiff; *.png|" 
				S" JPeg files (*.jpg;*.jpeg)|*.jpg;*.jpeg |GIF files (*.gif)|*.gif |BMP files (*.b" 
				S"mp)|*.bmp|Tiff files (*.tif;*.tiff)|*.tif;*.tiff|Png files (*.png)| *.png |All f" 
				S"iles (*.*)|*.*";
			// 
			// button3
			// 
			this->button3->Location = System::Drawing::Point(168, 200);
			this->button3->Name = S"button3";
			this->button3->Size = System::Drawing::Size(88, 23);
			this->button3->TabIndex = 3;
			this->button3->Text = S"绿红色旋转";
			this->button3->Click += new System::EventHandler(this, button3_Click);
			// 
			// button4
			// 
			this->button4->Location = System::Drawing::Point(256, 200);
			this->button4->Name = S"button4";
			this->button4->Size = System::Drawing::Size(96, 23);
			this->button4->TabIndex = 4;
			this->button4->Text = S"蓝红色旋转\t";
			this->button4->Click += new System::EventHandler(this, button4_Click);
			// 
			// Form1
			// 
			this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
			this->ClientSize = System::Drawing::Size(352, 230);
			this->Controls->Add(this->button4);
			this->Controls->Add(this->button3);
			this->Controls->Add(this->button2);
			this->Controls->Add(this->button1);
			this->Controls->Add(this->pictureBox1);
			this->MaximizeBox = false;
			this->Name = S"Form1";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
			this->Text = S"演示旋转图片颜色";
			this->ResumeLayout(false);

		}	

	private: System::Void button1_Click(System::Object *  sender, System::EventArgs *  e)
			 {//浏览图像
				if(this->openFileDialog1->ShowDialog()==DialogResult::OK)
				{

					Image* MyImage=System::Drawing::Image::FromFile(this->openFileDialog1->FileName);
					this->pictureBox1->Image=MyImage;
				}
			 }
	private: System::Void button2_Click(System::Object *  sender, System::EventArgs *  e)
			 {//红色绕着蓝色旋转	
				 Graphics* g=this->pictureBox1->CreateGraphics();
				 g->Clear(Color::White);
				 Bitmap* MyImage=(Bitmap*)this->pictureBox1->Image;
				 //得到图片尺寸
				 int MyWidth=MyImage->get_Width();
				 int MyHeight=MyImage->get_Height();
			 	 float MyDegrees = 90;
				 //从角度到弧度
				 double MyRadian = MyDegrees * Math.PI/ 180.0f;  		
				 System::Drawing::Imaging::ImageAttributes* MyAttributes=new System::Drawing::Imaging::ImageAttributes();
				 System::Drawing::Imaging::ColorMatrix* MyColorMatrix=new System::Drawing::Imaging::ColorMatrix();
				//红色绕着蓝色旋转			
				//{
				//{(float)Math.Cos(r),  (float)Math.Sin(r), 0.0f, 0.0f, 0.0f},
				//{-(float)Math.Sin(r), (float)Math.Cos(r), 0.0f, 0.0f, 0.0f},
				//{0.0f,    0.0f,   1.0f, 0.0f, 0.0f},
				//{0.0f,    0.0f,   0.0f, 1.0f, 0.0f},
				//{0.0f,    0.0f,   0.0f, 0.0f, 1.0f}
				//};
				MyColorMatrix->set_Matrix00(0.0f);					
				MyColorMatrix->set_Matrix01(0.0f);	
				MyColorMatrix->set_Matrix02(0.0f);	
				MyColorMatrix->set_Matrix03(0.0f);	
				MyColorMatrix->set_Matrix04(0.0f);	
				MyColorMatrix->set_Matrix10(0.0f);	
				MyColorMatrix->set_Matrix11(0.0f);	
				MyColorMatrix->set_Matrix12(0.0f);	
				MyColorMatrix->set_Matrix13(0.0f);	
				MyColorMatrix->set_Matrix14(0.0f);	
				MyColorMatrix->set_Matrix20(0.0f);	
				MyColorMatrix->set_Matrix21(0.0f);	
				MyColorMatrix->set_Matrix22(0.0f);	
				MyColorMatrix->set_Matrix23(0.0f);	
				MyColorMatrix->set_Matrix24(0.0f);	
				MyColorMatrix->set_Matrix30(0.0f);	
				MyColorMatrix->set_Matrix31(0.0f);	
				MyColorMatrix->set_Matrix32(0.0f);	
				MyColorMatrix->set_Matrix33(0.0f);	
				MyColorMatrix->set_Matrix34(0.0f);	
				MyColorMatrix->set_Matrix40(0.0f);	
				MyColorMatrix->set_Matrix41(0.0f);	
				MyColorMatrix->set_Matrix42(0.0f);	
				MyColorMatrix->set_Matrix43(0.0f);	
				MyColorMatrix->set_Matrix44(0.0f);
				MyColorMatrix->set_Matrix00((float)Math::Cos(MyRadian));
				MyColorMatrix->set_Matrix01((float)Math::Sin(MyRadian));				
				MyColorMatrix->set_Matrix10(-(float)Math::Sin(MyRadian));
				MyColorMatrix->set_Matrix11((float)Math::Cos(MyRadian));
				MyColorMatrix->set_Matrix21(1.0f);
				MyColorMatrix->set_Matrix33(1.0f);
				MyColorMatrix->set_Matrix44(1.0f);				
				//使用色彩变换矩阵输出图片
				MyAttributes->SetColorMatrix(MyColorMatrix, 
				System::Drawing::Imaging::ColorMatrixFlag::Default,
				System::Drawing::Imaging::ColorAdjustType::Bitmap);
				g->DrawImage(MyImage, Rectangle(0, 0, MyWidth, MyHeight),
					0, 0,MyWidth, MyHeight,GraphicsUnit::Pixel,MyAttributes);
			 }	
	private: System::Void button3_Click(System::Object *  sender, System::EventArgs *  e)
			 {//绿色绕着红色旋转	
				 Graphics* g=this->pictureBox1->CreateGraphics();
				 g->Clear(Color::White);
				 Bitmap* MyImage=(Bitmap*)this->pictureBox1->Image;
				 //得到图片尺寸
				 int MyWidth=MyImage->get_Width();
				 int MyHeight=MyImage->get_Height();
			 	 float  MyDegrees = 90;
				 //从角度到弧度
				 double MyRadian=MyDegrees* Math.PI/ 180.0f;  		
				 System::Drawing::Imaging::ImageAttributes* MyAttributes=new System::Drawing::Imaging::ImageAttributes();
				 System::Drawing::Imaging::ColorMatrix* MyColorMatrix=new System::Drawing::Imaging::ColorMatrix();
				//绿色绕着红色旋转			
				//{{1,  0, 0.0f, 0.0f, 0.0f},
				//{0, (float)Math.Cos(r), (float)Math.Sin(r), 0.0f, 0.0f},
				//{0.0f, -(float)Math.Sin(r), (float)Math.Cos(r), 0.0f, 0.0f},
				//{0.0f,    0.0f,   0.0f, 1.0f, 0.0f},
				//{0.0f,    0.0f,   0.0f, 0.0f, 1.0f}};
				MyColorMatrix->set_Matrix00(0.0f);					
				MyColorMatrix->set_Matrix01(0.0f);	
				MyColorMatrix->set_Matrix02(0.0f);	
				MyColorMatrix->set_Matrix03(0.0f);	
				MyColorMatrix->set_Matrix04(0.0f);	
				MyColorMatrix->set_Matrix10(0.0f);	
				MyColorMatrix->set_Matrix11(0.0f);	
				MyColorMatrix->set_Matrix12(0.0f);	
				MyColorMatrix->set_Matrix13(0.0f);	
				MyColorMatrix->set_Matrix14(0.0f);	
				MyColorMatrix->set_Matrix20(0.0f);	
				MyColorMatrix->set_Matrix21(0.0f);	
				MyColorMatrix->set_Matrix22(0.0f);	
				MyColorMatrix->set_Matrix23(0.0f);	
				MyColorMatrix->set_Matrix24(0.0f);	
				MyColorMatrix->set_Matrix30(0.0f);	
				MyColorMatrix->set_Matrix31(0.0f);	
				MyColorMatrix->set_Matrix32(0.0f);	
				MyColorMatrix->set_Matrix33(0.0f);	
				MyColorMatrix->set_Matrix34(0.0f);	
				MyColorMatrix->set_Matrix40(0.0f);	
				MyColorMatrix->set_Matrix41(0.0f);	
				MyColorMatrix->set_Matrix42(0.0f);	
				MyColorMatrix->set_Matrix43(0.0f);	
				MyColorMatrix->set_Matrix44(0.0f);
				MyColorMatrix->set_Matrix00(1.0f);
				MyColorMatrix->set_Matrix11((float)Math::Cos(MyRadian));				
				MyColorMatrix->set_Matrix12((float)Math::Sin(MyRadian));
				MyColorMatrix->set_Matrix21(-(float)Math::Sin(MyRadian));
				MyColorMatrix->set_Matrix22((float)Math::Cos(MyRadian));
				MyColorMatrix->set_Matrix33(1.0f);
				MyColorMatrix->set_Matrix44(1.0f);				
				//使用色彩变换矩阵输出图片
				MyAttributes->SetColorMatrix(MyColorMatrix, 
				System::Drawing::Imaging::ColorMatrixFlag::Default,
				System::Drawing::Imaging::ColorAdjustType::Bitmap);
				g->DrawImage(MyImage, Rectangle(0, 0, MyWidth, MyHeight),
					0, 0,MyWidth, MyHeight,GraphicsUnit::Pixel,MyAttributes);	 
			 }

private: System::Void button4_Click(System::Object *  sender, System::EventArgs *  e)
		 {//蓝色绕着红色旋转	
				 Graphics* g=this->pictureBox1->CreateGraphics();
				 g->Clear(Color::White);
				 Bitmap* MyImage=(Bitmap*)this->pictureBox1->Image;
				 //得到图片尺寸
				 int MyWidth=MyImage->get_Width();
				 int MyHeight=MyImage->get_Height();
			 	 float  MyDegrees = 90;
				 //从角度到弧度
				 double MyRadian=MyDegrees* Math.PI/ 180.0f;  
		
				 System::Drawing::Imaging::ImageAttributes* MyAttributes=new System::Drawing::Imaging::ImageAttributes();
				 System::Drawing::Imaging::ColorMatrix* MyColorMatrix=new System::Drawing::Imaging::ColorMatrix();
				//蓝色绕着红色旋转			
				//{{(float)Math.Cos(r),  0, -(float)Math.Sin(r), 0.0f, 0.0f},
				//{0, 1, 0.0f, 0.0f, 0.0f},
				//{(float)Math.Sin(r), 0, (float)Math.Cos(r), 0.0f, 0.0f},
				//{0.0f,    0.0f,   0.0f, 1.0f, 0.0f},
				//{0.0f,    0.0f,   0.0f, 0.0f, 1.0f}};
				MyColorMatrix->set_Matrix00(0.0f);					
				MyColorMatrix->set_Matrix01(0.0f);	
				MyColorMatrix->set_Matrix02(0.0f);	
				MyColorMatrix->set_Matrix03(0.0f);	
				MyColorMatrix->set_Matrix04(0.0f);	
				MyColorMatrix->set_Matrix10(0.0f);	
				MyColorMatrix->set_Matrix11(0.0f);	
				MyColorMatrix->set_Matrix12(0.0f);	
				MyColorMatrix->set_Matrix13(0.0f);	
				MyColorMatrix->set_Matrix14(0.0f);	
				MyColorMatrix->set_Matrix20(0.0f);	
				MyColorMatrix->set_Matrix21(0.0f);	
				MyColorMatrix->set_Matrix22(0.0f);	
				MyColorMatrix->set_Matrix23(0.0f);	
				MyColorMatrix->set_Matrix24(0.0f);	
				MyColorMatrix->set_Matrix30(0.0f);	
				MyColorMatrix->set_Matrix31(0.0f);	
				MyColorMatrix->set_Matrix32(0.0f);	
				MyColorMatrix->set_Matrix33(0.0f);	
				MyColorMatrix->set_Matrix34(0.0f);	
				MyColorMatrix->set_Matrix40(0.0f);	
				MyColorMatrix->set_Matrix41(0.0f);	
				MyColorMatrix->set_Matrix42(0.0f);	
				MyColorMatrix->set_Matrix43(0.0f);	
				MyColorMatrix->set_Matrix44(0.0f);
				MyColorMatrix->set_Matrix00((float)Math::Cos(MyRadian));
				MyColorMatrix->set_Matrix02( -(float)Math::Sin(MyRadian));				
				MyColorMatrix->set_Matrix11(1.0f);
				MyColorMatrix->set_Matrix20((float)Math::Sin(MyRadian));
				MyColorMatrix->set_Matrix22((float)Math::Cos(MyRadian));
				MyColorMatrix->set_Matrix33(1.0f);
				MyColorMatrix->set_Matrix44(1.0f);				
				//使用色彩变换矩阵输出图片
				MyAttributes->SetColorMatrix(MyColorMatrix, 
				System::Drawing::Imaging::ColorMatrixFlag::Default,
				System::Drawing::Imaging::ColorAdjustType::Bitmap);
				g->DrawImage(MyImage, Rectangle(0, 0, MyWidth, MyHeight),
					0, 0,MyWidth, MyHeight,GraphicsUnit::Pixel,MyAttributes);	 				 			
		 }

};
}


⌨️ 快捷键说明

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