对于裁剪图像,我使用的是 joshholtz 的 CropImageView ( https://github.com/joshdholtz/CropImageView )。但是我在返回行之前的最后一行的裁剪函数处的 CreateBitmap 函数处收到 IllegalArgumentException 异常(说:x + 宽度必须是 <= bitmap.width())。
public Bitmap crop(Context context) throws IllegalArgumentException {
// Weird padding cause image size
int weirdSidePadding = this.getWeirdSideMargin();
int weirdVerticalPadding = this.getWeirdVerticalMargin();
FrameLayout.LayoutParams params = (LayoutParams) mDaBox.getLayoutParams();
// Getting crop dimensions
float d = context.getResources().getDisplayMetrics().density;
int x = (int)((params.leftMargin - weirdSidePadding) * d);
int y = (int)((params.topMargin - weirdVerticalPadding) * d);
int width = (int)((this.getWidth() - params.leftMargin - params.rightMargin) * d);
int height = (int)((this.getHeight() - params.topMargin - params.bottomMargin) * d);
Bitmap crooopppppppppppppppeed = Bitmap.createBitmap(mBitmap, x, y, width, height);
return crooopppppppppppppppeed;
}
实际上,我查看了可能相同的问题,但不幸的是,它们与我的情况不同,以帮助我。
你能帮我克服这个障碍吗?