Foxtable(狐表)用户栏目专家坐堂 → 绘制图片,文字怎么旋转90度


  共有2418人关注过本帖树形打印复制链接

主题:绘制图片,文字怎么旋转90度

帅哥哟,离线,有人找我吗?
mamuaiqing
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:四尾狐 帖子:824 积分:6294 威望:0 精华:0 注册:2012/3/1 3:17:00
绘制图片,文字怎么旋转90度  发帖心情 Post By:2018/6/16 22:34:00 [只看该作者]

Dim imgback As image = getimage("C:\图片.jpg")
Dim bmp As new bitmap(imgback.width, imgback.height) 

Dim g = graphics.fromimage(bmp)
g.DrawImage(imgback, 0, 0, imgback.Width, imgback.Height)
Dim fnt As New Font("宋体",12,FontStyle.Bold)
Dim msg As String = "Foxtable"
g.DrawString(msg,fnt,Brushes.Gray,100,347)
bmp.Save("f:\新图片.jpg")
bmp.dispose
如题:怎么将写入图片中的的文字"Foxtable"旋转90度,请教老师,谢谢


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/6/17 15:25:00 [只看该作者]

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

 

 

 

 


 回到顶部