Have you not heard of the .Net
Matrix Class?
It has a
rotate method that allows you to matrix transforms.
This thread has some matrix transforms examples in it.
(of course I know you'll want to cruise through the
MSDN "
Matrix Representation of Transformations" page just for fun also..)
(Note: You can
clip a graphic into a graphics path and
transform rotate it that way
or
use a texturebrush as a transform rotated brush image fill).
Another way is to
rotate an image in VB .NET using DrawImage,
but performance-wise if you have do it hundreds of times second for animation purposes,
DrawImage can be somewhat "velocity challenged" on older computers.
This page has a picture spin animation test for DrawImage speed testing.
For comparison purposes you try passel's texturebrush car sprite rotation example
(attached to
this post).
Lastly,
DrawImage also works with Graphics.RotateTransform and you can substitute
the
DrawImageUnscaled method for DrawImage (some claim it is slightly faster),
as in the "Function RotateImg" code from the bottom of
this page:
Code:
Public Function RotateImg(ByVal bmpimage As Bitmap, ByVal angle As Single) As Bitmap
Dim w As Integer = bmpimage.Width
Dim h As Integer = bmpimage.Height
Dim pf As PixelFormat = Nothing
pf = bmpimage.PixelFormat
Dim tempImg As New Bitmap(w, h, pf)
Dim g As Graphics = Graphics.FromImage(tempImg)
g.DrawImageUnscaled(bmpimage, 1, 1)
g.Dispose()
Dim path As New GraphicsPath()
path.AddRectangle(New RectangleF(0.0F, 0.0F, w, h))
Dim mtrx As New Matrix()
'Using System.Drawing.Drawing2D.Matrix class
mtrx.Rotate(angle)
Dim rct As RectangleF = path.GetBounds(mtrx)
Dim newImg As New Bitmap(Convert.ToInt32(rct.Width), Convert.ToInt32(rct.Height), pf)
g = Graphics.FromImage(newImg)
g.TranslateTransform(-rct.X, -rct.Y)
g.RotateTransform(angle)
g.InterpolationMode = InterpolationMode.HighQualityBilinear
g.DrawImageUnscaled(tempImg, 0, 0)
g.Dispose()
tempImg.Dispose()
Return newImg
End Function