Dim imgback As image = getimage("d:\test.jpg")
Dim w As Integer = imgback.width
Dim h As Integer = imgback.height
Dim angle As Double = 45
Dim a As Double = angle Mod 360
Dim radian As Double = a * Math.PI / 180.0
Dim cos As Double = Math.Cos(radian)
Dim sin As Double = Math.Sin(radian)
Dim newW As Integer = Math.Max(Math.Abs(w * cos - h * sin), Math.Abs(w * cos + h * sin))
Dim newH As Integer = Math.Max(Math.Abs(w * sin - h * cos), Math.Abs(w * sin + h * cos))
Dim bmpSrc As new Bitmap(newW, newH)
Dim g = Graphics.FromImage(bmpSrc)
g.DrawImage(imgback, 0, 0, imgback.Width, imgback.Height)
'g.FillRectangle(Brushes.Red,0,0,newW,newH)
g.TranslateTransform(newW/2, newH/2)
g.RotateTransform(angle)
g.TranslateTransform(-newW/2, -newH/2)
Dim x As Integer = (newW-w)/2
Dim y As Integer = (newH-h)/2
Dim fnt As New Font("宋体",16)
Dim msg As String = "I Like Foxtable"
g.DrawString(msg,fnt,Brushes.Red,x,y)
bmpSrc.Save("d:\test2.jpg")
g.Dispose()
bmpSrc.Dispose