mirror of
https://github.com/wasabeef/glide-transformations.git
synced 2025-06-08 15:34:04 +08:00
Merge pull request #3 from yqritc/fix/bitmap-recycling
remove original bitmap resource recycling
This commit is contained in:
commit
883c131ad6
@ -24,8 +24,6 @@ import com.bumptech.glide.load.resource.bitmap.BitmapResource;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.support.v8.renderscript.Allocation;
|
import android.support.v8.renderscript.Allocation;
|
||||||
import android.support.v8.renderscript.RenderScript;
|
import android.support.v8.renderscript.RenderScript;
|
||||||
import android.support.v8.renderscript.ScriptIntrinsicBlur;
|
import android.support.v8.renderscript.ScriptIntrinsicBlur;
|
||||||
@ -74,7 +72,6 @@ public class BlurTransformation implements Transformation<Bitmap> {
|
|||||||
blur.forEach(overlayAlloc);
|
blur.forEach(overlayAlloc);
|
||||||
overlayAlloc.copyTo(bitmap);
|
overlayAlloc.copyTo(bitmap);
|
||||||
|
|
||||||
source.recycle();
|
|
||||||
rs.destroy();
|
rs.destroy();
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
|
@ -58,8 +58,6 @@ public class ColorFilterTransformation implements Transformation<Bitmap> {
|
|||||||
paint.setColorFilter(new PorterDuffColorFilter(mColor, PorterDuff.Mode.SRC_ATOP));
|
paint.setColorFilter(new PorterDuffColorFilter(mColor, PorterDuff.Mode.SRC_ATOP));
|
||||||
canvas.drawBitmap(source, 0, 0, paint);
|
canvas.drawBitmap(source, 0, 0, paint);
|
||||||
|
|
||||||
source.recycle();
|
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,8 +63,6 @@ public class CropCircleTransformation implements Transformation<Bitmap> {
|
|||||||
float r = size / 2f;
|
float r = size / 2f;
|
||||||
canvas.drawCircle(r, r, r, paint);
|
canvas.drawCircle(r, r, r, paint);
|
||||||
|
|
||||||
source.recycle();
|
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,10 +48,6 @@ public class CropSquareTransformation implements Transformation<Bitmap> {
|
|||||||
bitmap = Bitmap.createBitmap(source, mWidth, mHeight, size, size);
|
bitmap = Bitmap.createBitmap(source, mWidth, mHeight, size, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bitmap != source) {
|
|
||||||
source.recycle();
|
|
||||||
}
|
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,8 +71,6 @@ public class CropTransformation implements Transformation<Bitmap> {
|
|||||||
Canvas canvas = new Canvas(bitmap);
|
Canvas canvas = new Canvas(bitmap);
|
||||||
canvas.drawBitmap(source, null, targetRect, null);
|
canvas.drawBitmap(source, null, targetRect, null);
|
||||||
|
|
||||||
source.recycle();
|
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,8 +56,6 @@ public class GrayscaleTransformation implements Transformation<Bitmap> {
|
|||||||
paint.setColorFilter(new ColorMatrixColorFilter(saturation));
|
paint.setColorFilter(new ColorMatrixColorFilter(saturation));
|
||||||
canvas.drawBitmap(source, 0, 0, paint);
|
canvas.drawBitmap(source, 0, 0, paint);
|
||||||
|
|
||||||
source.recycle();
|
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,8 +62,6 @@ public class RoundedCornersTransformation implements Transformation<Bitmap> {
|
|||||||
canvas.drawRoundRect(new RectF(margin, margin, width - margin, height - margin),
|
canvas.drawRoundRect(new RectF(margin, margin, width - margin, height - margin),
|
||||||
radius, radius, paint);
|
radius, radius, paint);
|
||||||
|
|
||||||
source.recycle();
|
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user