A1VBCode Forums

Rotating a picture or shape


http://www.a1vbcode.com/vbforums/Topic21965.aspx

By DevinM - 5/22/2007

I was wondering if it was possible to rotate or flip a picture or shape during run time.
By mikemikk - 6/1/2007

' OriginalImage must already exit

Dim clonedImage As New Bitmap(OriginalImage.Width, OriginalImage.Height, OriginalImage.PixelFormat)

dim CenterPoint as PointF = new pointF(clonedImage.size.width/2,clonedimage.size.height/2)

dim WhereToDraw as new Rectangle(0,0,clonedimage.width,clonedimage.height)

dim Degrees as Single = 90.0F

dim m as New Drawing2D.Matrix

dim m.RotateAt(Degrees, CenterPoint)

dim g as Graphics = Grahpics.FromImage(clonedImage)

g.Transform = m

g.DrawImage(clonedImage,WheretoDraw)

g.Dispose

clonedimage.dispose



That works for me.