mirror of
https://github.com/wasabeef/glide-transformations.git
synced 2025-06-08 07:24:05 +08:00
Adjustment of default parameters.
This commit is contained in:
parent
987651f9da
commit
cdbd42595a
@ -1,6 +1,11 @@
|
|||||||
Change Log
|
Change Log
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
Version 1.1.0 *(2015-07-24)*
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
Adjustment of default parameters.
|
||||||
|
|
||||||
Version 1.0.8 *(2015-07-24)*
|
Version 1.0.8 *(2015-07-24)*
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
|
13
README.md
13
README.md
@ -32,9 +32,9 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'jp.wasabeef:glide-transformations:1.0.8'
|
compile 'jp.wasabeef:glide-transformations:1.1.0'
|
||||||
// If you want to use the GPU Filters
|
// If you want to use the GPU Filters
|
||||||
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.2.3'
|
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.3.0'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ Set Glide Transform.
|
|||||||
|
|
||||||
```java
|
```java
|
||||||
Glide.with(this).load(R.drawable.demo)
|
Glide.with(this).load(R.drawable.demo)
|
||||||
.bitmapTransform(new BlurTransformation(this, Glide.get(this).getBitmapPool()))
|
.bitmapTransform(new BlurTransformation(context))
|
||||||
.into((ImageView) findViewById(R.id.image));
|
.into((ImageView) findViewById(R.id.image));
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -53,9 +53,8 @@ Glide.with(this).load(R.drawable.demo)
|
|||||||
You can set a multiple transformations.
|
You can set a multiple transformations.
|
||||||
|
|
||||||
```java
|
```java
|
||||||
BitmapPool pool = Glide.get(this).getBitmapPool();
|
Glide.with(this).load(R.drawable.demo)
|
||||||
Glide.with(this).load(R.drawable.demo).bitmapTransform(
|
.bitmapTransform(new BlurTransformation(context, 25, 2), new CropCircleTransformation(pool))
|
||||||
new BlurTransformation(this, pool, 25, 2), new CropCircleTransformation(pool))
|
|
||||||
.into((ImageView) findViewById(R.id.image));
|
.into((ImageView) findViewById(R.id.image));
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -68,7 +67,7 @@ android {
|
|||||||
...
|
...
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
...
|
...
|
||||||
renderscriptTargetApi 22
|
renderscriptTargetApi 23
|
||||||
renderscriptSupportModeEnabled true
|
renderscriptSupportModeEnabled true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.3.0-beta4'
|
classpath 'com.android.tools.build:gradle:1.3.1'
|
||||||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
|
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
@ -2,10 +2,8 @@ package jp.wasabeef.example.glide;
|
|||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
@ -42,7 +40,6 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
|
|||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private List<Type> mDataSet;
|
private List<Type> mDataSet;
|
||||||
private BitmapPool mPool;
|
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
CropTop,
|
CropTop,
|
||||||
@ -69,7 +66,6 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
|
|||||||
public MainAdapter(Context context, List<Type> dataSet) {
|
public MainAdapter(Context context, List<Type> dataSet) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mDataSet = dataSet;
|
mDataSet = dataSet;
|
||||||
mPool = Glide.get(mContext).getBitmapPool();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -85,63 +81,64 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
|
|||||||
switch (mDataSet.get(position)) {
|
switch (mDataSet.get(position)) {
|
||||||
case CropTop:
|
case CropTop:
|
||||||
transformation =
|
transformation =
|
||||||
new CropTransformation(mPool, 300, 100, CropTransformation.CropType.TOP);
|
new CropTransformation(mContext, 300, 100, CropTransformation.CropType.TOP);
|
||||||
break;
|
break;
|
||||||
case CropCenter:
|
case CropCenter:
|
||||||
transformation = new CropTransformation(mPool, 300, 100);
|
transformation = new CropTransformation(mContext, 300, 100);
|
||||||
break;
|
break;
|
||||||
case CropBottom:
|
case CropBottom:
|
||||||
transformation =
|
transformation =
|
||||||
new CropTransformation(mPool, 300, 100, CropTransformation.CropType.BOTTOM);
|
new CropTransformation(mContext, 300, 100,
|
||||||
|
CropTransformation.CropType.BOTTOM);
|
||||||
break;
|
break;
|
||||||
case CropSquare:
|
case CropSquare:
|
||||||
transformation = new CropSquareTransformation(mPool);
|
transformation = new CropSquareTransformation(mContext);
|
||||||
break;
|
break;
|
||||||
case CropCircle:
|
case CropCircle:
|
||||||
transformation = new CropCircleTransformation(mPool);
|
transformation = new CropCircleTransformation(mContext);
|
||||||
break;
|
break;
|
||||||
case ColorFilter:
|
case ColorFilter:
|
||||||
transformation = new ColorFilterTransformation(mPool, Color.argb(80, 255, 0, 0));
|
transformation = new ColorFilterTransformation(mContext, Color.argb(80, 255, 0, 0));
|
||||||
break;
|
break;
|
||||||
case Grayscale:
|
case Grayscale:
|
||||||
transformation = new GrayscaleTransformation(mPool);
|
transformation = new GrayscaleTransformation(mContext);
|
||||||
break;
|
break;
|
||||||
case RoundedCorners:
|
case RoundedCorners:
|
||||||
transformation = new RoundedCornersTransformation(mPool, 100, 0);
|
transformation = new RoundedCornersTransformation(mContext, 100, 0);
|
||||||
break;
|
break;
|
||||||
case Blur:
|
case Blur:
|
||||||
transformation = new BlurTransformation(mContext, mPool, 25, 1);
|
transformation = new BlurTransformation(mContext, 25, 1);
|
||||||
break;
|
break;
|
||||||
case Toon:
|
case Toon:
|
||||||
transformation = new ToonFilterTransformation(mContext, mPool);
|
transformation = new ToonFilterTransformation(mContext);
|
||||||
break;
|
break;
|
||||||
case Sepia:
|
case Sepia:
|
||||||
transformation = new SepiaFilterTransformation(mContext, mPool);
|
transformation = new SepiaFilterTransformation(mContext);
|
||||||
break;
|
break;
|
||||||
case Contrast:
|
case Contrast:
|
||||||
transformation = new ContrastFilterTransformation(mContext, mPool, 2.0f);
|
transformation = new ContrastFilterTransformation(mContext, 2.0f);
|
||||||
break;
|
break;
|
||||||
case Invert:
|
case Invert:
|
||||||
transformation = new InvertFilterTransformation(mContext, mPool);
|
transformation = new InvertFilterTransformation(mContext);
|
||||||
break;
|
break;
|
||||||
case Pixel:
|
case Pixel:
|
||||||
transformation = new PixelationFilterTransformation(mContext, mPool, 20);
|
transformation = new PixelationFilterTransformation(mContext, 20);
|
||||||
break;
|
break;
|
||||||
case Sketch:
|
case Sketch:
|
||||||
transformation = new SketchFilterTransformation(mContext, mPool);
|
transformation = new SketchFilterTransformation(mContext);
|
||||||
break;
|
break;
|
||||||
case Swirl:
|
case Swirl:
|
||||||
transformation = new SwirlFilterTransformation(mContext, mPool,
|
transformation = new SwirlFilterTransformation(mContext,
|
||||||
0.5f, 1.0f, new PointF(0.5f, 0.5f));
|
0.5f, 1.0f, new PointF(0.5f, 0.5f));
|
||||||
break;
|
break;
|
||||||
case Brightness:
|
case Brightness:
|
||||||
transformation = new BrightnessFilterTransformation(mContext, mPool, 0.5f);
|
transformation = new BrightnessFilterTransformation(mContext, 0.5f);
|
||||||
break;
|
break;
|
||||||
case Kuawahara:
|
case Kuawahara:
|
||||||
transformation = new KuwaharaFilterTransformation(mContext, mPool, 25);
|
transformation = new KuwaharaFilterTransformation(mContext, 25);
|
||||||
break;
|
break;
|
||||||
case Vignette:
|
case Vignette:
|
||||||
transformation = new VignetteFilterTransformation(mContext, mPool,
|
transformation = new VignetteFilterTransformation(mContext,
|
||||||
new PointF(0.5f, 0.5f), new float[]{0.0f, 0.0f, 0.0f}, 0f, 0.75f);
|
new PointF(0.5f, 0.5f), new float[]{0.0f, 0.0f, 0.0f}, 0f, 0.75f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
VERSION_NAME=1.0.8
|
VERSION_NAME=1.1.0
|
||||||
VERSION_CODE=8
|
VERSION_CODE=9
|
||||||
GROUP=jp.wasabeef
|
GROUP=jp.wasabeef
|
||||||
ARTIFACT_ID=glide-transformations
|
ARTIFACT_ID=glide-transformations
|
||||||
|
|
||||||
COMPILE_SDK_VERSION=22
|
COMPILE_SDK_VERSION=23
|
||||||
BUILD_TOOLS_VERSION=22.0.1
|
BUILD_TOOLS_VERSION=23.0.1
|
||||||
TARGET_SDK_VERSION=22
|
TARGET_SDK_VERSION=23
|
||||||
RENDERSCRIPT_TARGET_API=22
|
RENDERSCRIPT_TARGET_API=23
|
||||||
MIN_SDK_VERSION=11
|
MIN_SDK_VERSION=11
|
||||||
|
|
||||||
POM_DESCRIPTION=which provides simple Tranformations to Glide
|
POM_DESCRIPTION=which provides simple Tranformations to Glide
|
||||||
@ -23,6 +23,6 @@ POM_DEVELOPER_EMAIL=dadadada.chop@gmail.com
|
|||||||
POM_DEVELOPER_URL=wasabeef.jp
|
POM_DEVELOPER_URL=wasabeef.jp
|
||||||
ISSUE_URL=https://github.com/wasabeef/glide-transformations/issues
|
ISSUE_URL=https://github.com/wasabeef/glide-transformations/issues
|
||||||
|
|
||||||
SUPPORT_PACKAGE_VERSION=22.2.1
|
SUPPORT_PACKAGE_VERSION=23.0.1
|
||||||
GLIDE_VERSION=3.6.1
|
GLIDE_VERSION=3.6.1
|
||||||
GPUIMAGE_VERSION=1.2.3
|
GPUIMAGE_VERSION=1.3.0
|
@ -16,6 +16,7 @@ package jp.wasabeef.glide.transformations;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
@ -41,6 +42,10 @@ public class BlurTransformation implements Transformation<Bitmap> {
|
|||||||
private int mRadius;
|
private int mRadius;
|
||||||
private int mSampling;
|
private int mSampling;
|
||||||
|
|
||||||
|
public BlurTransformation(Context context) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool(), MAX_RADIUS, DEFAULT_DOWN_SAMPLING);
|
||||||
|
}
|
||||||
|
|
||||||
public BlurTransformation(Context context, BitmapPool pool) {
|
public BlurTransformation(Context context, BitmapPool pool) {
|
||||||
this(context, pool, MAX_RADIUS, DEFAULT_DOWN_SAMPLING);
|
this(context, pool, MAX_RADIUS, DEFAULT_DOWN_SAMPLING);
|
||||||
}
|
}
|
||||||
@ -49,6 +54,10 @@ public class BlurTransformation implements Transformation<Bitmap> {
|
|||||||
this(context, pool, radius, DEFAULT_DOWN_SAMPLING);
|
this(context, pool, radius, DEFAULT_DOWN_SAMPLING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlurTransformation(Context context, int radius) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool(), radius, DEFAULT_DOWN_SAMPLING);
|
||||||
|
}
|
||||||
|
|
||||||
public BlurTransformation(Context context, BitmapPool pool, int radius, int sampling) {
|
public BlurTransformation(Context context, BitmapPool pool, int radius, int sampling) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mBitmapPool = pool;
|
mBitmapPool = pool;
|
||||||
@ -56,6 +65,13 @@ public class BlurTransformation implements Transformation<Bitmap> {
|
|||||||
mSampling = sampling;
|
mSampling = sampling;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlurTransformation(Context context, int radius, int sampling) {
|
||||||
|
mContext = context;
|
||||||
|
mBitmapPool = Glide.get(context).getBitmapPool();
|
||||||
|
mRadius = radius;
|
||||||
|
mSampling = sampling;
|
||||||
|
}
|
||||||
|
|
||||||
@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();
|
||||||
|
@ -16,11 +16,13 @@ package jp.wasabeef.glide.transformations;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
|
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
|
||||||
|
|
||||||
|
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.Paint;
|
||||||
@ -33,6 +35,10 @@ public class ColorFilterTransformation implements Transformation<Bitmap> {
|
|||||||
|
|
||||||
private int mColor;
|
private int mColor;
|
||||||
|
|
||||||
|
public ColorFilterTransformation(Context context, int color) {
|
||||||
|
this(Glide.get(context).getBitmapPool(), color);
|
||||||
|
}
|
||||||
|
|
||||||
public ColorFilterTransformation(BitmapPool pool, int color) {
|
public ColorFilterTransformation(BitmapPool pool, int color) {
|
||||||
mBitmapPool = pool;
|
mBitmapPool = pool;
|
||||||
mColor = color;
|
mColor = color;
|
||||||
|
@ -16,11 +16,13 @@ package jp.wasabeef.glide.transformations;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
|
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapShader;
|
import android.graphics.BitmapShader;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
@ -31,6 +33,10 @@ public class CropCircleTransformation implements Transformation<Bitmap> {
|
|||||||
|
|
||||||
private BitmapPool mBitmapPool;
|
private BitmapPool mBitmapPool;
|
||||||
|
|
||||||
|
public CropCircleTransformation(Context context) {
|
||||||
|
this(Glide.get(context).getBitmapPool());
|
||||||
|
}
|
||||||
|
|
||||||
public CropCircleTransformation(BitmapPool pool) {
|
public CropCircleTransformation(BitmapPool pool) {
|
||||||
this.mBitmapPool = pool;
|
this.mBitmapPool = pool;
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,13 @@ package jp.wasabeef.glide.transformations;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
|
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
public class CropSquareTransformation implements Transformation<Bitmap> {
|
public class CropSquareTransformation implements Transformation<Bitmap> {
|
||||||
@ -29,6 +31,10 @@ public class CropSquareTransformation implements Transformation<Bitmap> {
|
|||||||
private int mWidth;
|
private int mWidth;
|
||||||
private int mHeight;
|
private int mHeight;
|
||||||
|
|
||||||
|
public CropSquareTransformation(Context context) {
|
||||||
|
this(Glide.get(context).getBitmapPool());
|
||||||
|
}
|
||||||
|
|
||||||
public CropSquareTransformation(BitmapPool pool) {
|
public CropSquareTransformation(BitmapPool pool) {
|
||||||
this.mBitmapPool = pool;
|
this.mBitmapPool = pool;
|
||||||
}
|
}
|
||||||
|
@ -16,31 +16,49 @@ package jp.wasabeef.glide.transformations;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
|
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
|
|
||||||
public class CropTransformation implements Transformation<Bitmap> {
|
public class CropTransformation implements Transformation<Bitmap> {
|
||||||
|
|
||||||
|
public enum CropType {
|
||||||
|
TOP,
|
||||||
|
CENTER,
|
||||||
|
BOTTOM
|
||||||
|
}
|
||||||
|
|
||||||
private BitmapPool mBitmapPool;
|
private BitmapPool mBitmapPool;
|
||||||
private int mWidth;
|
private int mWidth;
|
||||||
private int mHeight;
|
private int mHeight;
|
||||||
|
|
||||||
private CropType mCropType = CropType.CENTER;
|
private CropType mCropType = CropType.CENTER;
|
||||||
|
|
||||||
|
public CropTransformation(Context context) {
|
||||||
|
this(Glide.get(context).getBitmapPool());
|
||||||
|
}
|
||||||
|
|
||||||
public CropTransformation(BitmapPool pool) {
|
public CropTransformation(BitmapPool pool) {
|
||||||
mBitmapPool = pool;
|
this(pool, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CropTransformation(Context context, int width, int height) {
|
||||||
|
this(Glide.get(context).getBitmapPool(), width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CropTransformation(BitmapPool pool, int width, int height) {
|
public CropTransformation(BitmapPool pool, int width, int height) {
|
||||||
mBitmapPool = pool;
|
this(pool, width, height, CropType.CENTER);
|
||||||
mWidth = width;
|
}
|
||||||
mHeight = height;
|
|
||||||
|
public CropTransformation(Context context, int width, int height, CropType cropType) {
|
||||||
|
this(Glide.get(context).getBitmapPool(), width, height, cropType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CropTransformation(BitmapPool pool, int width, int height, CropType cropType) {
|
public CropTransformation(BitmapPool pool, int width, int height, CropType cropType) {
|
||||||
@ -97,10 +115,4 @@ public class CropTransformation implements Transformation<Bitmap> {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum CropType {
|
|
||||||
TOP,
|
|
||||||
CENTER,
|
|
||||||
BOTTOM
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,13 @@ package jp.wasabeef.glide.transformations;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
|
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.ColorMatrix;
|
import android.graphics.ColorMatrix;
|
||||||
@ -31,6 +33,10 @@ public class GrayscaleTransformation implements Transformation<Bitmap> {
|
|||||||
|
|
||||||
private BitmapPool mBitmapPool;
|
private BitmapPool mBitmapPool;
|
||||||
|
|
||||||
|
public GrayscaleTransformation(Context context) {
|
||||||
|
this(Glide.get(context).getBitmapPool());
|
||||||
|
}
|
||||||
|
|
||||||
public GrayscaleTransformation(BitmapPool pool) {
|
public GrayscaleTransformation(BitmapPool pool) {
|
||||||
mBitmapPool = pool;
|
mBitmapPool = pool;
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,13 @@ package jp.wasabeef.glide.transformations;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
|
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapShader;
|
import android.graphics.BitmapShader;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
@ -35,10 +37,14 @@ public class RoundedCornersTransformation implements Transformation<Bitmap> {
|
|||||||
private int radius;
|
private int radius;
|
||||||
private int margin;
|
private int margin;
|
||||||
|
|
||||||
|
public RoundedCornersTransformation(Context context, int radius, int margin) {
|
||||||
|
this(Glide.get(context).getBitmapPool(), radius, margin);
|
||||||
|
}
|
||||||
|
|
||||||
public RoundedCornersTransformation(BitmapPool pool, int radius, int margin) {
|
public RoundedCornersTransformation(BitmapPool pool, int radius, int margin) {
|
||||||
|
mBitmapPool = pool;
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
this.margin = margin;
|
this.margin = margin;
|
||||||
mBitmapPool = pool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,6 +16,7 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
@ -38,9 +39,16 @@ public class BrightnessFilterTransformation implements Transformation<Bitmap> {
|
|||||||
private GPUImageBrightnessFilter mFilter = new GPUImageBrightnessFilter();
|
private GPUImageBrightnessFilter mFilter = new GPUImageBrightnessFilter();
|
||||||
private float mBrightness;
|
private float mBrightness;
|
||||||
|
|
||||||
|
public BrightnessFilterTransformation(Context context) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool());
|
||||||
|
}
|
||||||
|
|
||||||
public BrightnessFilterTransformation(Context context, BitmapPool pool) {
|
public BrightnessFilterTransformation(Context context, BitmapPool pool) {
|
||||||
mContext = context;
|
this(context, pool, 0.0f);
|
||||||
mBitmapPool = pool;
|
}
|
||||||
|
|
||||||
|
public BrightnessFilterTransformation(Context context, float brightness) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool(), brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BrightnessFilterTransformation(Context context, BitmapPool pool, float brightness) {
|
public BrightnessFilterTransformation(Context context, BitmapPool pool, float brightness) {
|
||||||
|
@ -16,6 +16,7 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
@ -38,9 +39,16 @@ public class ContrastFilterTransformation implements Transformation<Bitmap> {
|
|||||||
private GPUImageContrastFilter mFilter = new GPUImageContrastFilter();
|
private GPUImageContrastFilter mFilter = new GPUImageContrastFilter();
|
||||||
private float mContrast;
|
private float mContrast;
|
||||||
|
|
||||||
|
public ContrastFilterTransformation(Context context) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool());
|
||||||
|
}
|
||||||
|
|
||||||
public ContrastFilterTransformation(Context context, BitmapPool pool) {
|
public ContrastFilterTransformation(Context context, BitmapPool pool) {
|
||||||
mContext = context;
|
this(context, pool, 1.0f);
|
||||||
mBitmapPool = pool;
|
}
|
||||||
|
|
||||||
|
public ContrastFilterTransformation(Context context, float contrast) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool(), contrast);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContrastFilterTransformation(Context context, BitmapPool pool, float contrast) {
|
public ContrastFilterTransformation(Context context, BitmapPool pool, float contrast) {
|
||||||
|
@ -16,6 +16,7 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
@ -27,11 +28,18 @@ import android.graphics.Bitmap;
|
|||||||
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
||||||
import jp.co.cyberagent.android.gpuimage.GPUImageColorInvertFilter;
|
import jp.co.cyberagent.android.gpuimage.GPUImageColorInvertFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invert all the colors in the image.
|
||||||
|
*/
|
||||||
public class InvertFilterTransformation implements Transformation<Bitmap> {
|
public class InvertFilterTransformation implements Transformation<Bitmap> {
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private BitmapPool mBitmapPool;
|
private BitmapPool mBitmapPool;
|
||||||
|
|
||||||
|
public InvertFilterTransformation(Context context) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool());
|
||||||
|
}
|
||||||
|
|
||||||
public InvertFilterTransformation(Context context, BitmapPool pool) {
|
public InvertFilterTransformation(Context context, BitmapPool pool) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mBitmapPool = pool;
|
mBitmapPool = pool;
|
||||||
|
@ -16,6 +16,7 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
@ -28,7 +29,14 @@ import jp.co.cyberagent.android.gpuimage.GPUImage;
|
|||||||
import jp.co.cyberagent.android.gpuimage.GPUImageKuwaharaFilter;
|
import jp.co.cyberagent.android.gpuimage.GPUImageKuwaharaFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The radius to sample from when creating the brush-stroke effect, with a default of 3.
|
* Kuwahara image abstraction, drawn from the work of Kyprianidis, et. al. in their publication
|
||||||
|
* "Anisotropic Kuwahara Filtering on the GPU" within the GPU Pro collection. This produces an
|
||||||
|
* oil-painting-like
|
||||||
|
* image, but it is extremely computationally expensive, so it can take seconds to render a frame on
|
||||||
|
* an iPad 2.
|
||||||
|
* This might be best used for still images.
|
||||||
|
*
|
||||||
|
* The radius to sample from when creating the brush-stroke effect, with a default of 25.
|
||||||
* The larger the radius, the slower the filter.
|
* The larger the radius, the slower the filter.
|
||||||
*/
|
*/
|
||||||
public class KuwaharaFilterTransformation implements Transformation<Bitmap> {
|
public class KuwaharaFilterTransformation implements Transformation<Bitmap> {
|
||||||
@ -39,9 +47,16 @@ public class KuwaharaFilterTransformation implements Transformation<Bitmap> {
|
|||||||
private GPUImageKuwaharaFilter mFilter = new GPUImageKuwaharaFilter();
|
private GPUImageKuwaharaFilter mFilter = new GPUImageKuwaharaFilter();
|
||||||
private int mRadius;
|
private int mRadius;
|
||||||
|
|
||||||
|
public KuwaharaFilterTransformation(Context context) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool());
|
||||||
|
}
|
||||||
|
|
||||||
public KuwaharaFilterTransformation(Context context, BitmapPool pool) {
|
public KuwaharaFilterTransformation(Context context, BitmapPool pool) {
|
||||||
mContext = context;
|
this(context, pool, 25);
|
||||||
mBitmapPool = pool;
|
}
|
||||||
|
|
||||||
|
public KuwaharaFilterTransformation(Context context, int radius) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool(), radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KuwaharaFilterTransformation(Context context, BitmapPool pool, int radius) {
|
public KuwaharaFilterTransformation(Context context, BitmapPool pool, int radius) {
|
||||||
|
@ -16,6 +16,7 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
@ -27,6 +28,11 @@ import android.graphics.Bitmap;
|
|||||||
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
||||||
import jp.co.cyberagent.android.gpuimage.GPUImagePixelationFilter;
|
import jp.co.cyberagent.android.gpuimage.GPUImagePixelationFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies a Pixelation effect to the image.
|
||||||
|
*
|
||||||
|
* The pixel with a default of 10.0.
|
||||||
|
*/
|
||||||
public class PixelationFilterTransformation implements Transformation<Bitmap> {
|
public class PixelationFilterTransformation implements Transformation<Bitmap> {
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@ -35,9 +41,16 @@ public class PixelationFilterTransformation implements Transformation<Bitmap> {
|
|||||||
private GPUImagePixelationFilter mFilter = new GPUImagePixelationFilter();
|
private GPUImagePixelationFilter mFilter = new GPUImagePixelationFilter();
|
||||||
private float mPixel;
|
private float mPixel;
|
||||||
|
|
||||||
|
public PixelationFilterTransformation(Context context) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool());
|
||||||
|
}
|
||||||
|
|
||||||
public PixelationFilterTransformation(Context context, BitmapPool pool) {
|
public PixelationFilterTransformation(Context context, BitmapPool pool) {
|
||||||
mContext = context;
|
this(context, pool, 10f);
|
||||||
mBitmapPool = pool;
|
}
|
||||||
|
|
||||||
|
public PixelationFilterTransformation(Context context, float pixel) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool(), pixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PixelationFilterTransformation(Context context, BitmapPool pool, float pixel) {
|
public PixelationFilterTransformation(Context context, BitmapPool pool, float pixel) {
|
||||||
|
@ -16,6 +16,7 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
@ -27,6 +28,11 @@ import android.graphics.Bitmap;
|
|||||||
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
||||||
import jp.co.cyberagent.android.gpuimage.GPUImageSepiaFilter;
|
import jp.co.cyberagent.android.gpuimage.GPUImageSepiaFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies a simple sepia effect.
|
||||||
|
*
|
||||||
|
* The intensity with a default of 1.0.
|
||||||
|
*/
|
||||||
public class SepiaFilterTransformation implements Transformation<Bitmap> {
|
public class SepiaFilterTransformation implements Transformation<Bitmap> {
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@ -35,9 +41,16 @@ public class SepiaFilterTransformation implements Transformation<Bitmap> {
|
|||||||
private GPUImageSepiaFilter mFilter = new GPUImageSepiaFilter();
|
private GPUImageSepiaFilter mFilter = new GPUImageSepiaFilter();
|
||||||
private float mIntensity;
|
private float mIntensity;
|
||||||
|
|
||||||
|
public SepiaFilterTransformation(Context context) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool());
|
||||||
|
}
|
||||||
|
|
||||||
public SepiaFilterTransformation(Context context, BitmapPool pool) {
|
public SepiaFilterTransformation(Context context, BitmapPool pool) {
|
||||||
mContext = context;
|
this(context, pool, 1.0f);
|
||||||
mBitmapPool = pool;
|
}
|
||||||
|
|
||||||
|
public SepiaFilterTransformation(Context context, float intensity) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool(), intensity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SepiaFilterTransformation(Context context, BitmapPool pool, float intensity) {
|
public SepiaFilterTransformation(Context context, BitmapPool pool, float intensity) {
|
||||||
|
@ -16,6 +16,7 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
@ -32,6 +33,10 @@ public class SketchFilterTransformation implements Transformation<Bitmap> {
|
|||||||
private Context mContext;
|
private Context mContext;
|
||||||
private BitmapPool mBitmapPool;
|
private BitmapPool mBitmapPool;
|
||||||
|
|
||||||
|
public SketchFilterTransformation(Context context) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool());
|
||||||
|
}
|
||||||
|
|
||||||
public SketchFilterTransformation(Context context, BitmapPool pool) {
|
public SketchFilterTransformation(Context context, BitmapPool pool) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mBitmapPool = pool;
|
mBitmapPool = pool;
|
||||||
|
@ -16,6 +16,7 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
@ -28,6 +29,9 @@ import android.graphics.PointF;
|
|||||||
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
||||||
import jp.co.cyberagent.android.gpuimage.GPUImageSwirlFilter;
|
import jp.co.cyberagent.android.gpuimage.GPUImageSwirlFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a swirl distortion on the image.
|
||||||
|
*/
|
||||||
public class SwirlFilterTransformation implements Transformation<Bitmap> {
|
public class SwirlFilterTransformation implements Transformation<Bitmap> {
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@ -38,10 +42,17 @@ public class SwirlFilterTransformation implements Transformation<Bitmap> {
|
|||||||
private float mAngle;
|
private float mAngle;
|
||||||
private PointF mCenter;
|
private PointF mCenter;
|
||||||
|
|
||||||
|
public SwirlFilterTransformation(Context context) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool());
|
||||||
|
}
|
||||||
|
|
||||||
public SwirlFilterTransformation(Context context, BitmapPool pool) {
|
public SwirlFilterTransformation(Context context, BitmapPool pool) {
|
||||||
mContext = context;
|
this(context, pool, .5f, 1.0f, new PointF(0.5f, 0.5f));
|
||||||
mBitmapPool = pool;
|
}
|
||||||
mCenter = new PointF();
|
|
||||||
|
public SwirlFilterTransformation(Context context,
|
||||||
|
float radius, float angle, PointF center) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool(), radius, angle, center);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,6 +16,7 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
@ -27,6 +28,11 @@ import android.graphics.Bitmap;
|
|||||||
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
||||||
import jp.co.cyberagent.android.gpuimage.GPUImageToonFilter;
|
import jp.co.cyberagent.android.gpuimage.GPUImageToonFilter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The threshold at which to apply the edges, default of 0.2.
|
||||||
|
* The levels of quantization for the posterization of colors within the scene,
|
||||||
|
* with a default of 10.0.
|
||||||
|
*/
|
||||||
public class ToonFilterTransformation implements Transformation<Bitmap> {
|
public class ToonFilterTransformation implements Transformation<Bitmap> {
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
@ -36,9 +42,16 @@ public class ToonFilterTransformation implements Transformation<Bitmap> {
|
|||||||
private float mThreshold;
|
private float mThreshold;
|
||||||
private float mQuantizationLevels;
|
private float mQuantizationLevels;
|
||||||
|
|
||||||
|
public ToonFilterTransformation(Context context) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool());
|
||||||
|
}
|
||||||
|
|
||||||
public ToonFilterTransformation(Context context, BitmapPool pool) {
|
public ToonFilterTransformation(Context context, BitmapPool pool) {
|
||||||
mContext = context;
|
this(context, pool, .2f, 10.0f);
|
||||||
mBitmapPool = pool;
|
}
|
||||||
|
|
||||||
|
public ToonFilterTransformation(Context context, float threshold, float quantizationLevels) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool(), threshold, quantizationLevels);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToonFilterTransformation(Context context, BitmapPool pool,
|
public ToonFilterTransformation(Context context, BitmapPool pool,
|
||||||
|
@ -16,6 +16,7 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.Transformation;
|
import com.bumptech.glide.load.Transformation;
|
||||||
import com.bumptech.glide.load.engine.Resource;
|
import com.bumptech.glide.load.engine.Resource;
|
||||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||||
@ -32,8 +33,8 @@ import jp.co.cyberagent.android.gpuimage.GPUImageVignetteFilter;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs a vignetting effect, fading out the image at the edges
|
* Performs a vignetting effect, fading out the image at the edges
|
||||||
* x:
|
* The directional intensity of the vignetting,
|
||||||
* y: The directional intensity of the vignetting, with a default of x = 0.75, y = 0.5
|
* with a default of x = 0.5, y = 0.5, start = 0, end = 0.75
|
||||||
*/
|
*/
|
||||||
public class VignetteFilterTransformation implements Transformation<Bitmap> {
|
public class VignetteFilterTransformation implements Transformation<Bitmap> {
|
||||||
|
|
||||||
@ -46,11 +47,17 @@ public class VignetteFilterTransformation implements Transformation<Bitmap> {
|
|||||||
private float mVignetteStart;
|
private float mVignetteStart;
|
||||||
private float mVignetteEnd;
|
private float mVignetteEnd;
|
||||||
|
|
||||||
|
public VignetteFilterTransformation(Context context) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool());
|
||||||
|
}
|
||||||
|
|
||||||
public VignetteFilterTransformation(Context context, BitmapPool pool) {
|
public VignetteFilterTransformation(Context context, BitmapPool pool) {
|
||||||
mContext = context;
|
this(context, pool, new PointF(0.5f, 0.5f), new float[]{0.0f, 0.0f, 0.0f}, 0.0f, 0.75f);
|
||||||
mBitmapPool = pool;
|
}
|
||||||
mCenter = new PointF();
|
|
||||||
|
public VignetteFilterTransformation(Context context,
|
||||||
|
PointF center, float[] color, float start, float end) {
|
||||||
|
this(context, Glide.get(context).getBitmapPool(), center, color, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VignetteFilterTransformation(Context context, BitmapPool pool,
|
public VignetteFilterTransformation(Context context, BitmapPool pool,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user