我想从另一个位置创建一个位图,但是每次尝试都会崩溃,这是错误消息
java.lang.IllegalArgumentException: y + height 必须 <= bitmap.height() at android.graphics.Bitmap.createBitmap(Bitmap.java:557) at android.graphics.Bitmap.createBitmap(Bitmap.java:522) saveBitmap(手势活动.java:166)
这是我尝试创作的地方:
public void saveBitmap(){
Bitmap bitmapToSave = Bitmap.createBitmap(view.getWidth(),view.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmapToSave);
view.draw(canvas);
int width = bitmapToSave.getWidth();
int height = bitmapToSave.getHeight();
System.out.println("view : "+view.getWidth());
System.out.println("view : "+view.getHeight());
System.out.println("btmp Width : "+width);
System.out.println("btmp Height : "+height);
Bitmap result = Bitmap.createBitmap(bitmapToSave, 0, view.getTop(), view.getWidth(), view.getWidth());
SaveImage(result);
}
感谢您的帮助:D
这是我的日志:
> System.out﹕ view : 480
System.out﹕ view : 480
System.out﹕ btmp Width : 480
System.out﹕ btmp Height : 480