Is it possible to rotate a graphic image

I suppose this could be a very simple task, that i simply do not have the understanding of - but is it possible to (or does anyone know how to) rotate an image. (e.g. a jpeg) through a set number of degrees (not necessarily 90, 180, 270 though, but an arbitary amount)

Any help would be very much appreciated, as I am complete stumped.

Thanks
   Steve...
LVL 1
swtileyAsked:
Who is Participating?
 
Erick37Connect With a Mentor Commented:
Forgot this...

Using:

Imports System.drawing
Imports System.drawing.imaging
0
 
Bob LearnedCommented:
0
 
Erick37Commented:
Simple example of how to rotate a picture and display it in a picturebox:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        'Load up an image from disk
        Dim imgOrig As Image = Image.FromFile("c:\image.jpg")
        'Make a copy
        Dim imgClone As Image = imgOrig.Clone

        'Angle of rotation in degrees
        Dim angle As Single
        angle = 33

        'Create the graphics object to draw onto
        Dim g As Graphics = Graphics.FromImage(imgOrig)
        'Clear the picture and give us a black background
        g.Clear(Color.Black)

        'Translate to the center of the image
        g.TranslateTransform(imgClone.Width / 2, imgClone.Height / 2)
        'Rotate about center of image
        g.RotateTransform(angle)
        'Translate back
        g.TranslateTransform(-imgClone.Width / 2, -imgClone.Height / 2)

        'Draw the image
        g.DrawImage(imgClone, New Point(0, 0))
        'Display the results in a PictureBox
        PictureBox1.Image = imgOrig.Clone

        'clean up
        imgClone.Dispose()
        imgOrig.Dispose()
        g.Dispose()
       
    End Sub
0
 
swtileyAuthor Commented:
Thanks Erick - fantastic answer

Cheers
   Steve
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.