我想创建一个像Instagram这样的应用程序。 我的用户可以从存储中选择自己的图像,进行裁剪并将其发送到服务器。 我有一个片段,顶部是CropperImageView ,底部是RecyclerView 。 我使用该库进行图像裁剪。 当用户单击RecyclerView的图像时,我将该图像作为位图加载并为CropperImageView设置该位图,如下所示
Glide.with(getContext()).asBitmap().load(imageFilePath).into(new SimpleTarget() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition super Bitmap> transition) {
cropperView.setImageBitmap(resource);
}
});
因为用户可以多次单击Recyclerview图像项目。 我从Glide获得OutOfMemory异常。 以下是logcat中的Glide日志。
W/Glide: Load failed for /storage/4BC8-1B11/DCIM/Camera/20180520_210400.jpg with size [-2147483648x-2147483648]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
There was 1 cause:
java.lang.OutOfMemoryError(Failed to allocate a 51121164 byte allocation with 16701336 free bytes and