mirror of
https://github.com/wasabeef/glide-transformations.git
synced 2025-06-09 07:54:04 +08:00
Refactor
This commit is contained in:
parent
f839029adb
commit
a330118112
@ -35,6 +35,7 @@ public class BrightnessFilterTransformation implements Transformation<Bitmap> {
|
||||
private Context mContext;
|
||||
private BitmapPool mBitmapPool;
|
||||
|
||||
private GPUImageBrightnessFilter mFilter = new GPUImageBrightnessFilter();
|
||||
private float mBrightness;
|
||||
|
||||
public BrightnessFilterTransformation(Context context, BitmapPool pool) {
|
||||
@ -46,6 +47,7 @@ public class BrightnessFilterTransformation implements Transformation<Bitmap> {
|
||||
mContext = context;
|
||||
mBitmapPool = pool;
|
||||
mBrightness = brightness;
|
||||
mFilter.setBrightness(mBrightness);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,12 +56,7 @@ public class BrightnessFilterTransformation implements Transformation<Bitmap> {
|
||||
|
||||
GPUImage gpuImage = new GPUImage(mContext);
|
||||
gpuImage.setImage(source);
|
||||
GPUImageBrightnessFilter filter = new GPUImageBrightnessFilter();
|
||||
if (mBrightness != 0) {
|
||||
filter.setBrightness(mBrightness);
|
||||
}
|
||||
|
||||
gpuImage.setFilter(filter);
|
||||
gpuImage.setFilter(mFilter);
|
||||
Bitmap bitmap = gpuImage.getBitmapWithFilterApplied();
|
||||
|
||||
source.recycle();
|
||||
|
@ -35,6 +35,7 @@ public class ContrastFilterTransformation implements Transformation<Bitmap> {
|
||||
private Context mContext;
|
||||
private BitmapPool mBitmapPool;
|
||||
|
||||
private GPUImageContrastFilter mFilter = new GPUImageContrastFilter();
|
||||
private float mContrast;
|
||||
|
||||
public ContrastFilterTransformation(Context context, BitmapPool pool) {
|
||||
@ -46,6 +47,7 @@ public class ContrastFilterTransformation implements Transformation<Bitmap> {
|
||||
mContext = context;
|
||||
mBitmapPool = pool;
|
||||
mContrast = contrast;
|
||||
mFilter.setContrast(mContrast);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,12 +56,7 @@ public class ContrastFilterTransformation implements Transformation<Bitmap> {
|
||||
|
||||
GPUImage gpuImage = new GPUImage(mContext);
|
||||
gpuImage.setImage(source);
|
||||
GPUImageContrastFilter filter = new GPUImageContrastFilter();
|
||||
if (mContrast != 0) {
|
||||
filter.setContrast(mContrast);
|
||||
}
|
||||
|
||||
gpuImage.setFilter(filter);
|
||||
gpuImage.setFilter(mFilter);
|
||||
Bitmap bitmap = gpuImage.getBitmapWithFilterApplied();
|
||||
|
||||
source.recycle();
|
||||
|
@ -32,6 +32,7 @@ public class PixelationFilterTransformation implements Transformation<Bitmap> {
|
||||
private Context mContext;
|
||||
private BitmapPool mBitmapPool;
|
||||
|
||||
private GPUImagePixelationFilter mFilter = new GPUImagePixelationFilter();
|
||||
private float mPixel;
|
||||
|
||||
public PixelationFilterTransformation(Context context, BitmapPool pool) {
|
||||
@ -43,6 +44,7 @@ public class PixelationFilterTransformation implements Transformation<Bitmap> {
|
||||
mContext = context;
|
||||
mBitmapPool = pool;
|
||||
mPixel = pixel;
|
||||
mFilter.setPixel(mPixel);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,12 +53,7 @@ public class PixelationFilterTransformation implements Transformation<Bitmap> {
|
||||
|
||||
GPUImage gpuImage = new GPUImage(mContext);
|
||||
gpuImage.setImage(source);
|
||||
GPUImagePixelationFilter filter = new GPUImagePixelationFilter();
|
||||
if (mPixel != 0) {
|
||||
filter.setPixel(mPixel);
|
||||
}
|
||||
|
||||
gpuImage.setFilter(filter);
|
||||
gpuImage.setFilter(mFilter);
|
||||
Bitmap bitmap = gpuImage.getBitmapWithFilterApplied();
|
||||
|
||||
source.recycle();
|
||||
|
@ -32,6 +32,7 @@ public class SepiaFilterTransformation implements Transformation<Bitmap> {
|
||||
private Context mContext;
|
||||
private BitmapPool mBitmapPool;
|
||||
|
||||
private GPUImageSepiaFilter mFilter = new GPUImageSepiaFilter();
|
||||
private float mIntensity;
|
||||
|
||||
public SepiaFilterTransformation(Context context, BitmapPool pool) {
|
||||
@ -43,6 +44,7 @@ public class SepiaFilterTransformation implements Transformation<Bitmap> {
|
||||
mContext = context;
|
||||
mBitmapPool = pool;
|
||||
mIntensity = intensity;
|
||||
mFilter.setIntensity(mIntensity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -51,12 +53,7 @@ public class SepiaFilterTransformation implements Transformation<Bitmap> {
|
||||
|
||||
GPUImage gpuImage = new GPUImage(mContext);
|
||||
gpuImage.setImage(source);
|
||||
GPUImageSepiaFilter filter = new GPUImageSepiaFilter();
|
||||
if (mIntensity != 0) {
|
||||
filter.setIntensity(mIntensity);
|
||||
}
|
||||
|
||||
gpuImage.setFilter(filter);
|
||||
gpuImage.setFilter(mFilter);
|
||||
Bitmap bitmap = gpuImage.getBitmapWithFilterApplied();
|
||||
|
||||
source.recycle();
|
||||
|
@ -33,6 +33,7 @@ public class SwirlFilterTransformation implements Transformation<Bitmap> {
|
||||
private Context mContext;
|
||||
private BitmapPool mBitmapPool;
|
||||
|
||||
private GPUImageSwirlFilter mFilter = new GPUImageSwirlFilter();
|
||||
private float mRadius;
|
||||
private float mAngle;
|
||||
private PointF mCenter;
|
||||
@ -54,6 +55,9 @@ public class SwirlFilterTransformation implements Transformation<Bitmap> {
|
||||
mRadius = radius;
|
||||
mAngle = angle;
|
||||
mCenter = center;
|
||||
mFilter.setRadius(mRadius);
|
||||
mFilter.setAngle(mAngle);
|
||||
mFilter.setCenter(mCenter);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,18 +66,7 @@ public class SwirlFilterTransformation implements Transformation<Bitmap> {
|
||||
|
||||
GPUImage gpuImage = new GPUImage(mContext);
|
||||
gpuImage.setImage(source);
|
||||
GPUImageSwirlFilter filter = new GPUImageSwirlFilter();
|
||||
if (mRadius != 0) {
|
||||
filter.setRadius(mRadius);
|
||||
}
|
||||
if (mAngle != 0) {
|
||||
filter.setAngle(mAngle);
|
||||
}
|
||||
if (mCenter != null) {
|
||||
filter.setCenter(mCenter);
|
||||
}
|
||||
|
||||
gpuImage.setFilter(filter);
|
||||
gpuImage.setFilter(mFilter);
|
||||
Bitmap bitmap = gpuImage.getBitmapWithFilterApplied();
|
||||
|
||||
source.recycle();
|
||||
|
@ -32,6 +32,7 @@ public class ToonFilterTransformation implements Transformation<Bitmap> {
|
||||
private Context mContext;
|
||||
private BitmapPool mBitmapPool;
|
||||
|
||||
private GPUImageToonFilter mFilter = new GPUImageToonFilter();
|
||||
private float mThreshold;
|
||||
private float mQuantizationLevels;
|
||||
|
||||
@ -46,6 +47,8 @@ public class ToonFilterTransformation implements Transformation<Bitmap> {
|
||||
mBitmapPool = pool;
|
||||
mThreshold = threshold;
|
||||
mQuantizationLevels = quantizationLevels;
|
||||
mFilter.setThreshold(mThreshold);
|
||||
mFilter.setQuantizationLevels(mQuantizationLevels);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -54,15 +57,7 @@ public class ToonFilterTransformation implements Transformation<Bitmap> {
|
||||
|
||||
GPUImage gpuImage = new GPUImage(mContext);
|
||||
gpuImage.setImage(source);
|
||||
GPUImageToonFilter filter = new GPUImageToonFilter();
|
||||
if (mThreshold != 0) {
|
||||
filter.setThreshold(mThreshold);
|
||||
}
|
||||
if (mQuantizationLevels != 0) {
|
||||
filter.setQuantizationLevels(mQuantizationLevels);
|
||||
}
|
||||
|
||||
gpuImage.setFilter(filter);
|
||||
gpuImage.setFilter(mFilter);
|
||||
Bitmap bitmap = gpuImage.getBitmapWithFilterApplied();
|
||||
|
||||
source.recycle();
|
||||
|
Loading…
x
Reference in New Issue
Block a user