vb.net - 在 vb.net 中裁剪图像
问题描述
我正在尝试裁剪图像并将裁剪的部分保存为单独的图像,但由于裁剪的图像显示空白屏幕,我没有这样做。
PFA 文件。
下面是我的代码片段:
Dim bmp As Image = pdf.SaveAsImage(pageIndex)
Dim Bmp1 As Bitmap = New Bitmap(bmp)
zoneLeft = Convert.ToInt32((ZonesItems.Item(ClickedZoneCount - 1).ZoneArea.Left * 100) / ZoomPercent)
zoneWidth = Convert.ToInt32((ZonesItems.Item(ClickedZoneCount - 1).ZoneArea.Width * 100) / ZoomPercent)
zoneTop = Convert.ToInt32((ZonesItems.Item(ClickedZoneCount - 1).ZoneArea.Top * 100) / ZoomPercent)
zoneHeight = Convert.ToInt32((ZonesItems.Item(ClickedZoneCount - 1).ZoneArea.Height * 100) / ZoomPercent)
Bmp1.Save("./Bmp1.tiff", Imaging.ImageFormat.Tiff)
bmp.Dispose()
bmp = Nothing
'X= 388, Y= 81, Width = 144, Height = 22. Dim rect As New RectangleF(X, Y, Width, Height) Dim Cropped As Bitmap = Bmp1.Clone(rect, Bmp1.PixelFormat)
Cropped.Save("./cropped.tiff", Imaging.ImageFormat.Tiff)
这就是我们计算 RECT 值的方式:
上面提到的值是在矩形函数中传递的。
任何人都可以让我知道我的代码中有什么问题吗?
解决方案
推荐阅读
- amazon-web-services - 我的 HTTP 客户端的 S3 存储桶访问被拒绝
- javascript - Vuex 存储和访问 Vue.prototype
- database - MongoDB - 从 Object 中仅返回一个匹配的数组元素
- google-cloud-platform - 在 Google Cloud Platform 中重命名组织的权限
- javascript - 如何在 npm 中正确安装包
- reactjs - 在 DOM 主机中自定义 React 渲染器的目的是什么?
- html - Pure CSS Hamburger 菜单在消失前调整视口大小时显示
- google-analytics - BigQuery + Google Analytics:计算 SKU 购买的数量。UNNEST 不工作
- typescript - 绑定到函数的 Typescript 泛型类型与绑定到泛型函数的类型
- javascript - 是否可以在不使用反应的情况下将 chrome 扩展弹出窗口注入当前网页?