ARTICLE

Image Editing Tool in VB.Net (Part5- Rotations of image)

Posted by Hirendra Sisodiya Articles | GDI+ in VB.NET March 17, 2011
This article describes us that how to rotate image, this is the next article of 'Image Editing Tool in VB.Net' article series.
Download Files:
 
Reader Level:

Part1: Open an image

Part2: Resizing image

Part3: Cropping image

Part 4: brightness of image

This article is the next part of how to make image editor in vb.net. inthis article we will discuss that how to rotate and flip of an image and save.

Form Designer:

Put four button on form like this:

10.jpg

Code:

We are using here RotateFlip() method for rotaing images, RotateFlip method accept RotateFlipType enumeration that has these members(Ref: MDSN):

Rotate90FlipNone

Specifies a 90-degree clockwise rotation without flipping.

Rotate180FlipNone

Specifies a 180-degree clockwise rotation without flipping.

Rotate270FlipNone

Specifies a 270-degree clockwise rotation without flipping.

RotateNoneFlipX

Specifies no clockwise rotation followed by a horizontal flip.

Rotate90FlipX

Specifies a 90-degree clockwise rotation followed by a horizontal flip.

Rotate180FlipX

Specifies a 180-degree clockwise rotation followed by a horizontal flip.

Rotate270FlipX

Specifies a 270-degree clockwise rotation followed by a horizontal flip.

RotateNoneFlipY

Specifies no clockwise rotation followed by a vertical flip.

Rotate90FlipY

Specifies a 90-degree clockwise rotation followed by a vertical flip.

Rotate180FlipY

Specifies a 180-degree clockwise rotation followed by a vertical flip.

Rotate270FlipY

Specifies a 270-degree clockwise rotation followed by a vertical flip.

RotateNoneFlipXY

Specifies no clockwise rotation followed by a horizontal and vertical flip.

Rotate90FlipXY

Specifies a 90-degree clockwise rotation followed by a horizontal and vertical flip.

Rotate180FlipXY

Specifies a 180-degree clockwise rotation followed by a horizontal and vertical flip.

Rotate270FlipXY

Specifies a 270-degree clockwise rotation followed by a horizontal and vertical flip.


Generate click event of all four button, and try to apply these code snippt

    Private Sub btnRotateLeft_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRotateLeft.Click

        PictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone)

        PictureBox1.Refresh()

    End Sub

 

    Private Sub btnRotateRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRotateRight.Click

        PictureBox1.Image.RotateFlip(RotateFlipType.Rotate270FlipNone)

        PictureBox1.Refresh()

    End Sub

 

    Private Sub btnRotateHorizantal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRotateHorizantal.Click

        PictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipX)

        PictureBox1.Refresh()

    End Sub

 

    Private Sub btnRotatevertical_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRotatevertical.Click

        PictureBox1.Image.RotateFlip(RotateFlipType.RotateNoneFlipY)

        PictureBox1.Refresh()

    End Sub

if you click on 'horizantal Rotate' button result will bw like this:

11.jpg

You can download source code for description.

One more thing that RotateFlip method rotates the image clockwise.

Login to add your contents and source code to this article
share this article :
post comment
 

I really need an example of an image editor so I can use it as a guide.. but it seems that your system is not yet completed? is it? please can you send me the complete source code? thank you

Posted by jp romero Mar 05, 2012

hello Amit, i am working on that.when it will compleate, i will mail you.... thanks

Posted by Hirendra Sisodiya Jul 08, 2011

hi...the text tab of the souce file is not working properly.can you please help

Posted by amit rathee Jul 08, 2011
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Nevron Diagram
Become a Sponsor