Rotate Image


#pragma once

namespace My17 {
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 for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
///

public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
///
/// Clean up any resources being used.
///

~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ BtnShowImage;
protected:
private: System::Windows::Forms::Button^ BtnRotateImage;
private:
///
/// Required designer variable.
///

System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

void InitializeComponent(void)
{
this->BtnShowImage = (gcnew System::Windows::Forms::Button());
this->BtnRotateImage = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// BtnShowImage
//
this->BtnShowImage->Location = System::Drawing::Point(12, 386);
this->BtnShowImage->Name = L"BtnShowImage";
this->BtnShowImage->Size = System::Drawing::Size(240, 42);
this->BtnShowImage->TabIndex = 0;
this->BtnShowImage->Text = L"Show Image";
this->BtnShowImage->UseVisualStyleBackColor = true;
this->BtnShowImage->Click += gcnew System::EventHandler(this, &Form1::BtnShowImage_Click);
//
// BtnRotateImage
//
this->BtnRotateImage->Location = System::Drawing::Point(258, 386);
this->BtnRotateImage->Name = L"BtnRotateImage";
this->BtnRotateImage->Size = System::Drawing::Size(240, 42);
this->BtnRotateImage->TabIndex = 1;
this->BtnRotateImage->Text = L"RotateImage";
this->BtnRotateImage->UseVisualStyleBackColor = true;
this->BtnRotateImage->Click += gcnew System::EventHandler(this, &Form1::BtnRotateImage_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(506, 440);
this->Controls->Add(this->BtnRotateImage);
this->Controls->Add(this->BtnShowImage);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
}
#pragma endregion
//Rotate Image
Graphics^RotateImage_Graphics;
Bitmap^RotateImage_Bitmap;
void cDrawImage()
{
RotateImage_Bitmap=gcnew Bitmap("C:\\Flower.Bmp");
RotateImage_Graphics->DrawImage(RotateImage_Bitmap,100,50,300,300);
}
private: System::Void BtnShowImage_Click(System::Object^ sender, System::EventArgs^ e) {
cDrawImage();
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
RotateImage_Graphics=this->CreateGraphics();
this->Text="RotateImage";
this->MaximizeBox=false;
this->BackColor=Color::Red;
}
private: System::Void BtnRotateImage_Click(System::Object^ sender, System::EventArgs^ e) {
int cAngle;
cAngle+=5;
RotateImage_Graphics->RotateTransform(cAngle);
RotateImage_Graphics->Clear(this->BackColor);
cDrawImage();
}
};
}