vb.net 如何放大和缩小图片
展开全部
Sub 图片缩放()
Dim SngPer As Single = 1 '放大或缩小的比例 放大2倍时SngPer=2,缩小3倍时 SngPer=1/3
Dim PicOld As Image = Image.FromFile("原图片路径")
Dim PicNew As New System.Drawing.Bitmap(PicOld, PicOld.Width * SngPer, PicOld.Height * SngPer)
PicNew.Save("新图片路径", Drawing.Imaging.ImageFormat.Jpeg)
End Sub
Dim SngPer As Single = 1 '放大或缩小的比例 放大2倍时SngPer=2,缩小3倍时 SngPer=1/3
Dim PicOld As Image = Image.FromFile("原图片路径")
Dim PicNew As New System.Drawing.Bitmap(PicOld, PicOld.Width * SngPer, PicOld.Height * SngPer)
PicNew.Save("新图片路径", Drawing.Imaging.ImageFormat.Jpeg)
End Sub
2018-04-04
展开全部
这是一个非常坑的方法。会令图片失真到你看不出原图。
这个方法楼主也用得不好。
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
'x=2放大2倍
Private Sub ZoonIn_Click(sender As Object, e As EventArgs) Handles ZoonIn.Click
PictureBox.Image = imgZoon(barcodeReaderPictureBox.Image, 2)
End Sub
'x=-2 缩小2倍
Private Sub ZoonOut_Click(sender As Object, e As EventArgs) Handles ZoonOut.Click
PictureBox.Image = imgZoon(barcodeReaderPictureBox.Image, -2)
End Sub
图片在缩小后,再放大,就会失真了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |