Android:将图像裁剪为特定尺寸
我的目的是让用户从图库中选择一张图像,然后进行裁剪活动。但是,我需要将定义裁剪蒙版的矩形锁定到某个尺寸,然后用户只需重新定位它即可显示图像的一部分。
关于如何做到这一点有什么想法吗?
谢谢
-T
My intention is to have the user pick an image from the gallery, then have a cropping activity come up. However, I need the rectangle that defines the cropping mask to be locked to a certain dimension and then the user simply repositions it to display a portion of an image.
Any ideas on how this would be done?
Thanks
-T
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要创建一个自定义的
ImageView
类来实现图像的缩放和平移,并且可以在该图像上叠加一个固定的矩形image(transparent)
。并可以创建该位图的子位图。并将其保存在文件中。该方法用于创建子位图。
http://blog.sephiroth.it/2011/04 /04/imageview-zoom-and-scroll/
实现缩放和平移后,我不确定
createBitmap
是否可以从可见创建子位图图像的一部分(即缩放时图像的一部分在屏幕上不可见),因此尝试从imageView
获取drawingCache()
并为其创建子位图相同。You need to create a custom
ImageView
class to achieve zooming and panning of an image and can have a fixed rectangleimage(transparent)
overlaying on this image. And can create sub-bitmap of that bitmap. and save it in a file.This method is used to create a sub-bitmap.
http://blog.sephiroth.it/2011/04/04/imageview-zoom-and-scroll/
After achieving zooming and panning, I am not sure if
createBitmap
can create sub-bitmap from the visible portion of the image(i.e. part of image wont be visible on the screen when it is zoomed), So try getting thedrawingCache()
fromimageView
and create sub-bitmap for the same.