【发布时间】:2019-01-18 20:36:37
【问题描述】:
试图获得裁剪的图像,但我一直得到图像的不正确部分。
我从cropper.js 得到这个,{left: 316, top: 50.5, width: 150, height: 150}
我在 vb 中将它传递给这个。
Public Shared Function CropImage(ByVal source As Image, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) As Bitmap
Dim crop As Rectangle = New Rectangle(x, y, width, height)
Dim bmp = New Bitmap(crop.Width, crop.Height)
Using gr = Graphics.FromImage(bmp)
gr.DrawImage(source, New Rectangle(0, 0, bmp.Width, bmp.Height), crop, GraphicsUnit.Pixel)
End Using
Return bmp
End Function
但我最终只得到图像的左上角或右上角?有什么我想念的吗?我把它传给了 x,从cropper 传给了 y。我已经尝试了很多可能性,但似乎没有什么能给出我真正的裁剪结果。
【问题讨论】:
-
程序(或多或少)正确。那么,1)当 X 和 Y 到达 CropImage 方法时,您是否验证了它们的值? 2) 裁剪的选区是相对于原始位图区域还是相对于在显示位图的容器内创建的选区?