如何削减一个ImageView的一个子图像在四个指定点的范围内 [英] How to Cut a ImageView to a subimage in the range of four specified points
问题描述
我知道我们能猫的ImageView通过期运用系统的行动com.android.camera.action.CROP
I know we can cat a imageView by useing system action "com.android.camera.action.CROP"
但有些时候,我希望通过自己切的形象,如:
But some times i want to cut the image by myself like:
ImageView的A的位图是300dip * 300dip;
bitmap of imageView A is 300dip*300dip ;
子图像应该是在四点lefttop范围(0,0)leftbottom(0100)rightbottom(100100),righttop(100,0)。
sub-image should be the range in the four point lefttop(0,0) leftbottom(0,100) rightbottom(100,100),righttop(100,0).
如何创建子图像(位图)?
How to create the sub-image(bitmap)?
推荐答案
使用此静态方法:
Bitmap cropedBitmap = Bitmap.createBitmap(source, x, y, width, height);
源 - 原始位图
source - the original bitmap
中的X - 源第一像素的x坐标
x - The x coordinate of the first pixel in source
y - 将第一像素的源的y坐标
y - The y coordinate of the first pixel in source
这篇关于如何削减一个ImageView的一个子图像在四个指定点的范围内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!