1、请对原图修改,不要对已修改的修改。或者你重新定义图片控件的宽度和高度
2、背景颜色。
Dim bmpSource As Image = getimage("d:\test.jpg")
Dim w As Integer = bmpSource.Width
Dim h As Integer = bmpSource.Height
Dim angle As Double = -20
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.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
g.DrawImage(bmpSource, x, y, w, h)
bmpSrc.Save("d:\test2.jpg")
g.Dispose()
bmpSrc.Dispose