放缩很常见的吧,保存一下。vb.net的代码
以下代码,只要输入放缩系数x就可以实现放缩了(X>0就放大,X<0就缩小)。这是一个很大坑。图片缩小后,再放大就不清了。
点击(此处)折叠或打开
点击(此处)折叠或打开
-
Function imgZoon(img As Image, x As Integer) As Image
-
-
If x > 0 Then
-
-
img = New System.Drawing.Bitmap(img, img.Width * x, img.Height * x)
-
-
Else
-
-
x = Math.Abs(x)
-
-
img = New System.Drawing.Bitmap(img, CInt(img.Width / x), CInt(img.Height / x))
-
-
End If
-
-
imgZoon = img
-
-
End Function
-
-
Private Sub ZoonIn_Click(sender As Object, e As EventArgs) Handles ZoonIn.Click
-
-
PictureBox.Image = imgZoon(barcodeReaderPictureBox.Image, 2)
-
-
End Sub
-
-
Private Sub ZoonOut_Click(sender As Object, e As EventArgs) Handles ZoonOut.Click
-
-
PictureBox.Image = imgZoon(barcodeReaderPictureBox.Image, -2)
-
- End Sub