vb.net 如何放大和缩小图片

3780阅读 0评论2018-04-04 plumlee
分类:WINDOWS

放缩很常见的吧,保存一下。vb.net的代码


以下代码,只要输入放缩系数x就可以实现放缩了(X>0就放大,X<0就缩小)。这是一个很大坑。图片缩小后,再放大就不清了。

点击(此处)折叠或打开

点击(此处)折叠或打开

  1. Function imgZoon(img As Image, x As Integer) As Image

  2.         If x > 0 Then

  3.             img = New System.Drawing.Bitmap(img, img.Width * x, img.Height * x)

  4.         Else

  5.             x = Math.Abs(x)

  6.             img = New System.Drawing.Bitmap(img, CInt(img.Width / x), CInt(img.Height / x))

  7.         End If

  8.         imgZoon = img

  9.     End Function

  10.     Private Sub ZoonIn_Click(sender As Object, e As EventArgs) Handles ZoonIn.Click

  11.         PictureBox.Image = imgZoon(barcodeReaderPictureBox.Image, 2)

  12.     End Sub

  13.     Private Sub ZoonOut_Click(sender As Object, e As EventArgs) Handles ZoonOut.Click

  14.         PictureBox.Image = imgZoon(barcodeReaderPictureBox.Image, -2)

  15.     End Sub





上一篇:十多年的老司机,为什么还只是在做技术?
下一篇:华为Matebook14与苹果macbook air(2013款)的使用比较测评