Image.RotateFlip(RotateFlipType.Rotate180FlipY) : Image « System.Drawing « C# / C Sharp by API

Home
C# / C Sharp by API
1.Microsoft.Win32
2.System
3.System.Collections
4.System.Collections.Generic
5.System.Collections.Specialized
6.System.ComponentModel
7.System.Configuration
8.System.Data
9.System.Data.Common
10.System.Data.Linq
11.System.Data.Odbc
12.System.Data.OleDb
13.System.Data.Sql
14.System.Data.SqlClient
15.System.Diagnostics
16.System.DirectoryServices
17.System.Drawing
18.System.Drawing.Drawing2D
19.System.Drawing.Imaging
20.System.Drawing.Printing
21.System.Drawing.Text
22.System.EnterpriseServices
23.System.Globalization
24.System.IO
25.System.IO.Compression
26.System.IO.IsolatedStorage
27.System.IO.Ports
28.System.Linq
29.System.Management
30.System.Media
31.System.Messaging
32.System.Net
33.System.Net.Mail
34.System.Net.NetworkInformation
35.System.Net.Sockets
36.System.Reflection
37.System.Resources
38.System.Runtime
39.System.Runtime.CompilerServices
40.System.Runtime.InteropServices
41.System.Runtime.Remoting
42.System.Runtime.Remoting.Channels
43.System.Runtime.Remoting.Channels.Http
44.System.Runtime.Remoting.Messaging
45.System.Runtime.Serialization
46.System.Runtime.Serialization.Formatters.Binary
47.System.Runtime.Serialization.Formatters.Soap
48.System.Security
49.System.Security.AccessControl
50.System.Security.Cryptography
51.System.Security.Cryptography.X509Certificates
52.System.Security.Permissions
53.System.Security.Policy
54.System.Security.Principal
55.System.ServiceProcess
56.System.Text
57.System.Text.RegularExpressions
58.System.Threading
59.System.Timers
60.System.Web.Security
61.System.Web.Services
62.System.Windows.Controls
63.System.Windows.Forms
64.System.Xml
65.System.Xml.Linq
66.System.Xml.Schema
67.System.Xml.Serialization
68.System.Xml.XPath
69.System.Xml.Xsl
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp by API » System.Drawing » Image 
Image.RotateFlip(RotateFlipType.Rotate180FlipY)
  

/*
Professional Windows GUI Programming Using C#
by Jay Glynn, Csaba Torok, Richard Conway, Wahid Choudhury, 
   Zach Greenvoss, Shripad Kulkarni, Neil Whitlow

Publisher: Peer Information
ISBN: 1861007663
*/
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace ImageFlip
{
    /// <summary>
    /// Summary description for ImageFlip.
    /// </summary>
    public class ImageFlip : System.Windows.Forms.Form
    {
        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.CheckBox checkBox1;
        private System.Windows.Forms.RadioButton radioButton1;

        Image im = null;
        Image im2 = null;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.RadioButton radioButton2;
        private System.Windows.Forms.RadioButton radioButton3;

        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public ImageFlip()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.Text = "Flipping and Rotating";
            this.radioButton1.Checked = false;
            this.label1.Text = "";
            this.groupBox1.Text = "RotateFlipType";
            this.checkBox1.Text = "Paint";
            this.radioButton1.Text = "Rotate180FlipY";
            this.radioButton2.Text = "Rotate180FlipX";
            this.radioButton3.Text = "Rotate180FlipNone";

            this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButtons_CheckedChanged);
            this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButtons_CheckedChanged);
            this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButtons_CheckedChanged);

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Disposebool disposing )
        {
            ifdisposing )
            {
                if (components != null
                {
                    components.Dispose();
                }
            }
            base.Disposedisposing );
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.radioButton1 = new System.Windows.Forms.RadioButton();
            this.checkBox1 = new System.Windows.Forms.CheckBox();
            this.label1 = new System.Windows.Forms.Label();
            this.radioButton2 = new System.Windows.Forms.RadioButton();
            this.radioButton3 = new System.Windows.Forms.RadioButton();
            this.groupBox1.SuspendLayout();
            this.SuspendLayout();
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                                    this.radioButton3,
                                                                                    this.radioButton2,
                                                                                    this.radioButton1,
                                                                                    this.checkBox1});
            this.groupBox1.Location = new System.Drawing.Point(31264);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(24880);
            this.groupBox1.TabIndex = 1;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "groupBox1";
            // 
            // radioButton1
            // 
            this.radioButton1.Location = new System.Drawing.Point(12016);
            this.radioButton1.Name = "radioButton1";
            this.radioButton1.Size = new System.Drawing.Size(11224);
            this.radioButton1.TabIndex = 1;
            this.radioButton1.Text = "radioButton1";
            // 
            // checkBox1
            // 
            this.checkBox1.Location = new System.Drawing.Point(1616);
            this.checkBox1.Name = "checkBox1";
            this.checkBox1.TabIndex = 0;
            this.checkBox1.Text = "checkBox1";
            this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
            // 
            // label1
            // 
            this.label1.Location = new System.Drawing.Point(88);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(304200);
            this.label1.TabIndex = 2;
            this.label1.Text = "label1";
            // 
            // radioButton2
            // 
            this.radioButton2.Location = new System.Drawing.Point(1648);
            this.radioButton2.Name = "radioButton2";
            this.radioButton2.TabIndex = 2;
            this.radioButton2.Text = "radioButton2";
            // 
            // radioButton3
            // 
            this.radioButton3.Location = new System.Drawing.Point(12048);
            this.radioButton3.Name = "radioButton3";
            this.radioButton3.Size = new System.Drawing.Size(12024);
            this.radioButton3.TabIndex = 3;
            this.radioButton3.Text = "radioButton3";
            // 
            // ImageFlip
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(513);
            this.ClientSize = new System.Drawing.Size(560214);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this.label1,
                                                                          this.groupBox1});
            this.Name = "ImageFlip";
            this.Text = "ImageFlip";
            this.groupBox1.ResumeLayout(false);
            this.ResumeLayout(false);
        }
        #endregion

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main() 
        {
            Application.Run(new ImageFlip());
        }
        protected override void OnPaint(PaintEventArgs e)
        {   RotateFlip();   }
        private void label1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {   RotateFlip();   }
        private void checkBox1_CheckedChanged(object sender, System.EventArgs e)
        {   RotateFlip();   }
        private void radioButtons_CheckedChanged(object sender, System.EventArgs e)
        {   RotateFlip();   }
        protected void RotateFlip()
        {
            Graphics g = Graphics.FromHwnd(this.label1.Handle);
            Brush b = new SolidBrush(this.label1.BackColor);
    
            if (this.checkBox1.Checked
            {
                if (im == nullReadImage();

                Graphics g2 = Graphics.FromImage(im);  // For text "Himalaya"
                FontFamily ff = new FontFamily("Times New Roman");
                Font f = new Font(ff, 25, FontStyle.Bold);
                g2.DrawString("HIMALAYA", f, new SolidBrush(Color.Yellow)170210);
                g2.Dispose();               

                im2 = (Image)im.Clone();
            
                int w2 = label1.Width/2, h2 = label1.Height/2;
                g.DrawImage(im, 00, w2, h2);
        
                if(this.radioButton1.Checked)  // Rotate180FlipY
                {
                    im2.RotateFlip(RotateFlipType.Rotate180FlipY);
                    g.DrawImage(im2, w2, 0, w2, h2);
                }
                else g.FillRectangle(b, w2, 0, w2, h2);  // Clear old

                if(this.radioButton2.Checked)  // Rotate180FlipX
                {
                    im2.RotateFlip(RotateFlipType.Rotate180FlipX);
                    g.DrawImage(im2, 0, h2, w2, h2);
                }
                else g.FillRectangle(b, 0, h2, w2, h2);  // Clear old
        
                if(this.radioButton3.Checked)  // Rotate180FlipNone
                {
                    im2.RotateFlip(RotateFlipType.Rotate180FlipNone);
                    g.DrawImage(im2, w2, h2, w2, h2);  // Clear old
                }
                else g.FillRectangle(b, w2, h2, w2, h2);

                im2.Dispose();
            }
            else Clear(g);
    
            b.Dispose();    g.Dispose();
        }
        protected void ReadImage()
        {
            string path = @"Himalaya.bmp";
            im = Image.FromFile(path);
            this.radioButton1.Enabled = true;
            this.radioButton2.Enabled = true;
            this.radioButton3.Enabled = true;
        }
        protected void Clear(Graphics g)
        {
            g.Clear(this.BackColor);
            g.Dispose();        
            im = null;
            im2 = null;
            this.radioButton1.Checked = false;
            this.radioButton2.Checked = false;
            this.radioButton3.Checked = false;
            this.radioButton1.Enabled = false;
            this.radioButton2.Enabled = false;
            this.radioButton3.Enabled = false;
        }
    }
}

   
    
  
Related examples in the same category
1.Image.FromFile(String path)
2.Image.FromStream
3.Image.GetThumbnailImage
4.Image.Height
5.Image.VerticalResolution
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.