以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 请教:窗口查看PDF文件时,如何实现左转或右转(旋转)? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=91470) |
-- 作者:y2287958 -- 发布时间:2016/10/11 16:15:00 -- 请教:窗口查看PDF文件时,如何实现左转或右转(旋转)? 如题。 谢谢!
|
-- 作者:有点蓝 -- 发布时间:2016/10/11 16:38:00 -- Dim pic As WinForm.PictureBox = e.Form.Controls("PictureBox1") Dim img As Image = pic.Image Dim degree = 90 Dim ImgTarget As Bitmap Dim alpha As Double = (degree / 180) * math.PI Dim iWidth As Integer = img.Width * Math.Cos(alpha) + img.Height * Math.Sin(alpha) Dim iHeight As Integer = img.Width * Math.Sin(alpha) + img.Height * Math.Cos(alpha) ImgTarget = New Bitmap(iWidth, iHeight, Drawing.Imaging.PixelFormat.Format24bppRgb) Dim g As Graphics g = Graphics.FromImage(ImgTarget) g.TranslateTransform(img.Height * Math.Sin(alpha), 0) g.RotateTransform(degree) \'ImgTarget.MakeTransparent(ImgTarget.GetPixel(1, 1)) g.DrawImage(img, New Rectangle(0, 0, img.Width, img.Height)) pic.Image = ImgTarget
|
-- 作者:y2287958 -- 发布时间:2016/10/11 22:18:00 -- 顺便写一下左转的代码吧,我搞了半天没成功。再次谢谢您!
|
-- 作者:有点蓝 -- 发布时间:2016/10/11 22:28:00 -- Dim pic As WinForm.PictureBox = e.Form.Controls("PictureBox1") Dim img As Image = pic.Image Dim degree = 270 Dim ImgTarget As Bitmap Dim alpha As Double = ((degree - 180) / 180) * math.PI Dim iWidth As Integer = img.Width * Math.Cos(alpha) + img.Height * Math.Sin(alpha) Dim iHeight As Integer = img.Width * Math.Sin(alpha) + img.Height * Math.Cos(alpha) ImgTarget = New Bitmap(iWidth, iHeight, Drawing.Imaging.PixelFormat.Format24bppRgb) Dim g As Graphics g = Graphics.FromImage(ImgTarget) g.TranslateTransform(img.Width * Math.Cos(alpha), iHeight) g.RotateTransform(degree) \'ImgTarget.MakeTransparent(ImgTarget.GetPixel(1, 1)) g.DrawImage(img, New Rectangle(0, 0, img.Width, img.Height)) pic.Image = ImgTarget
|
-- 作者:y2287958 -- 发布时间:2016/10/11 22:41:00 -- |