如何削减一个ImageView的一个子图像在四个指定点的范围内范围内、个子、图像、ImageView

2023-09-05 04:23:43 作者:军歌铁马

我知道我们能猫的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