我想裁剪图像的一部分,为此我使用以下代码:
int x=20;
int y=50;
int [] rgbdata=new int[(0+width-x+height-y)* (image.getWidth())];
image.getARGB(rgbdata, 0, image.getWidth(), x, y, width, height);
cropedImage=new Bitmap(image.getWidth(),image.getWidth());
cropedImage.setARGB(rgbdata, 0,image.getWidth(), 80,80, width, height);
x 和 y 是以矩形形式进行裁剪的位置。
但它不起作用。
您可以使用图形来做到这一点:
public Bitmap cropImage(Bitmap image, int x, int y, int width, int height) {
Bitmap result = new Bitmap(width, height);
Graphics g = new Graphics(result);
g.drawBitmap(0, 0, width, height, image, x, y);
return result;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)