1
0
mirror of https://github.com/wasabeef/glide-transformations.git synced 2025-07-04 15:39:55 +08:00
This commit is contained in:
wasabeef 2015-01-14 01:05:26 +09:00
parent e943a944ab
commit bf2eaadf2d
2 changed files with 5 additions and 9 deletions

View File

@ -65,6 +65,8 @@ public class BlurTransformation implements Transformation<Bitmap> {
script.setInput(input);
script.forEach(output);
output.copyTo(bitmap);
source.recycle();
return BitmapResource.obtain(bitmap, mBitmapPool);
}

View File

@ -33,21 +33,15 @@ public class CropSquareTransformation implements Transformation<Bitmap> {
this.mBitmapPool = pool;
}
public CropSquareTransformation(BitmapPool pool, int width, int height) {
mBitmapPool = pool;
mWidth = width;
mHeight = height;
}
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
Bitmap source = resource.get();
int size = Math.min(source.getWidth(), source.getHeight());
int width = (source.getWidth() - size) / 2;
int height = (source.getHeight() - size) / 2;
mWidth = (source.getWidth() - size) / 2;
mHeight = (source.getHeight() - size) / 2;
Bitmap bitmap = Bitmap.createBitmap(source, width, height, size, size);
Bitmap bitmap = Bitmap.createBitmap(source, mWidth, mHeight, size, size);
if (bitmap != source) {
source.recycle();
}