Mirror Images using Transformation

In the following program we plan to draw a mirror image of an existing image

namespace immageprocessing
{


using System ;
using System.Drawing ;
using System.Drawing.Text ;
using System.Drawing.Drawing2D ;
using System.Collections ;
using System.ComponentModel ;
using System.WinForms ;
using System.Data ;

public class Form1 : System.WinForms.Form
{


private System.ComponentModel.Container components ;
public Form1 ( )
{

InitializeComponent ( ) ;

}

public override void Dispose ( )
{

base.Dispose ( ) ;
components.Dispose ( ) ;

}

private void InitializeComponent ( )
{

this.components = new
System.ComponentModel.Container ( ) ;
this.Text = "Form1" ;
this.AutoScaleBaseSize = new System.Drawing.Size ( 5,13 ) ;
this.ClientSize = new System.Drawing.Size ( 792, 549 ) ;
this.Paint += new System.WinForms.PaintEventHandler ( this.Form1_Paint ) ;
}

protected void Form1_Paint ( object sender, System.WinForms.PaintEventArgs e )
{

Graphics g = e.Graphics ;
Image myimg = Image.FromFile ( @"C:\fcode.jpg" ) ;
Matrix mymat = new Matrix ( ) ;
mymat.Translate ( 50, 50 ) ;
mymat.Scale ( -1.0f, 1 ) ;
mymat.Translate ( -450, -50 ) ;
g.Transform = mymat ;
g.DrawImage ( myimg, 50, 50 ) ;
g.ResetTransform ( ) ;

}

public static void Main(string[] args)
{

Application.Run(new Form1());

}

}

}

Posted bySumedh at 9:31 PM  

0 comments:

Post a Comment