是否可以绘制 2 个矩形并摘录第一个矩形?
编辑:-->嘿伙计们! <--
我正在开发一个“基于图像的应用程序”! 我想做的是:
- 拍照(完成)
- 预览带有叠加层的照片!
- 裁剪照片
所以问题是叠加!我有一个 SurfaceView,里面有拍摄的照片,现在我想看到一个像窗口一样的正方形(矩形 2),周围有一个 alpha 覆盖层(矩形 1 是某种黑色,透明度为 50%)。 是否可以绘制 2 个矩形,一个是全尺寸的(矩形 1),一个是较小尺寸的(矩形 2),然后从第一个矩形中切出较小的矩形?
______________
|Rect1 |
| ______ |
| |Rect2 | |
| | | |
| |______| |
|____________|
我使用的是安卓2.1。我知道2.3.3中有一个BitmapRegionDecoder!这件事几乎完成了我想做的事情。 目前,我画了 4 个矩形,并在中间留了一个小洞作为窗口,但移动这个正方形并调整它的大小就像我的 A** 中的一个痛苦。
编辑:我想做的就像在 Facebook 中一样,如果您将图片上传为个人资料图片,则当您发布某些内容时,您必须移动图片上的一个正方形并调整其大小,以获得左侧的“头像”图片......
所以我希望一切都清楚了,你可以帮助我!
谢谢
EDIT: --> HEY GUYS! <--
i am working on an "Image based App"!
What i want to do is:
- Take a photo (done)
- preview the Photo with an Overlay!
- Crop the Photo
So the problem is the Overlay! I have an SurfaceView with the taken Photo inside and now i want to see a square like a window (rect2) and around an alpha overlay (rect1 some kind of black with alpha 50%).
Is it possible to draw 2 Rect, one in full size (rect1) and one in a smaller size (rect2) and then cut the smaller out of the first Rect??
______________
|Rect1 |
| ______ |
| |Rect2 | |
| | | |
| |______| |
|____________|
I am using Android 2.1. I know in 2.3.3 there is an BitmapRegionDecoder! this thing does almost what i want to do.
At the moment i draw 4 Rect and leave a smal hole in the middle for the window but it is like an pain in my A** to move this sqare and resizing it.
EDIT: What i want to do is like in Facebook, if you upload a picture as Profileimage you have to move and resize a square on your image for the "avatar"-image on the left when you post something...
So i hope everything is clear and you can help me!
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 FrameLayout(如容器)来定位 SurfaceView(您的矩形)。
使用removeView,您可以通过使用findviewbyid 捕获来删除所需的矩形。
我希望这对你有帮助。再见
You can use a FrameLayout, like container, and for positioning your SurfaceView (your rect).
And with a removeView you can delete the rect you want, by capturing with a findviewbyid.
I hope this help you. bye
则
如果您只想为图像视图创建边框,
之前的答案适合我想建议以下内容:
}
previous answer suitable if you just want to create a border for your imageview
I would like to propose the following: