mirror of
https://github.com/wasabeef/glide-transformations.git
synced 2025-07-05 07:52:42 +08:00
bug fix
This commit is contained in:
parent
e943a944ab
commit
bf2eaadf2d
@ -65,6 +65,8 @@ public class BlurTransformation implements Transformation<Bitmap> {
|
|||||||
script.setInput(input);
|
script.setInput(input);
|
||||||
script.forEach(output);
|
script.forEach(output);
|
||||||
output.copyTo(bitmap);
|
output.copyTo(bitmap);
|
||||||
|
|
||||||
|
source.recycle();
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,21 +33,15 @@ public class CropSquareTransformation implements Transformation<Bitmap> {
|
|||||||
this.mBitmapPool = pool;
|
this.mBitmapPool = pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CropSquareTransformation(BitmapPool pool, int width, int height) {
|
|
||||||
mBitmapPool = pool;
|
|
||||||
mWidth = width;
|
|
||||||
mHeight = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
|
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
|
||||||
Bitmap source = resource.get();
|
Bitmap source = resource.get();
|
||||||
int size = Math.min(source.getWidth(), source.getHeight());
|
int size = Math.min(source.getWidth(), source.getHeight());
|
||||||
|
|
||||||
int width = (source.getWidth() - size) / 2;
|
mWidth = (source.getWidth() - size) / 2;
|
||||||
int height = (source.getHeight() - 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) {
|
if (bitmap != source) {
|
||||||
source.recycle();
|
source.recycle();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user