1
0
mirror of https://github.com/wasabeef/glide-transformations.git synced 2025-10-04 09:53:21 +08:00

6 Commits
1.0.8 ... 1.1.0

Author SHA1 Message Date
wasabeef
2cc2104802 bump up 2015-09-06 01:29:00 +09:00
wasabeef
f83e5ef85a change the codestyle 2015-09-06 01:24:12 +09:00
wasabeef
cdbd42595a Adjustment of default parameters. 2015-09-06 01:18:40 +09:00
Daichi Furiya
987651f9da Update README.md 2015-08-12 19:26:57 +09:00
Daichi Furiya
ad376134e9 Update README.md 2015-07-25 15:36:18 +09:00
Daichi Furiya
3f695c1e9c Update CHANGELOG.md 2015-07-24 18:28:35 +09:00
31 changed files with 998 additions and 882 deletions

View File

@@ -1,6 +1,16 @@
Change Log
==========
Version 1.1.0 *(2015-07-24)*
----------------------------
Adjustment of default parameters.
Version 1.0.8 *(2015-07-24)*
----------------------------
add DownSampling to BlurTransform
Version 1.0.7 *(2015-07-18)*
----------------------------

View File

@@ -32,8 +32,9 @@ repositories {
}
dependencies {
compile 'jp.wasabeef:glide-transformations:1.0.8@aar'
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.2.3@aar'
compile 'jp.wasabeef:glide-transformations:1.1.0'
// If you want to use the GPU Filters
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.3.0'
}
```
@@ -43,7 +44,7 @@ Set Glide Transform.
```java
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));
```
@@ -52,9 +53,8 @@ Glide.with(this).load(R.drawable.demo)
You can set a multiple transformations.
```java
BitmapPool pool = Glide.get(this).getBitmapPool();
Glide.with(this).load(R.drawable.demo).bitmapTransform(
new BlurTransformation(this, pool, 25, 2), new CropCircleTransformation(pool))
Glide.with(this).load(R.drawable.demo)
.bitmapTransform(new BlurTransformation(context, 25, 2), new CropCircleTransformation(pool))
.into((ImageView) findViewById(R.id.image));
```
@@ -67,7 +67,7 @@ android {
...
defaultConfig {
...
renderscriptTargetApi 22
renderscriptTargetApi 23
renderscriptSupportModeEnabled true
}
}

View File

@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
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'
// NOTE: Do not place your application dependencies here; they belong

View File

@@ -1,15 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jp.wasabeef.example.glide" >
package="jp.wasabeef.example.glide"
>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:theme="@style/AppTheme"
>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
android:label="@string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

View File

@@ -4,17 +4,13 @@ import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
import jp.wasabeef.example.glide.MainAdapter.Type;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

View File

@@ -1,11 +1,6 @@
package jp.wasabeef.example.glide;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.PointF;
import android.support.v7.widget.RecyclerView;
@@ -14,9 +9,9 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import java.util.List;
import jp.wasabeef.glide.transformations.BlurTransformation;
import jp.wasabeef.glide.transformations.ColorFilterTransformation;
import jp.wasabeef.glide.transformations.CropCircleTransformation;
@@ -42,7 +37,6 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
private Context mContext;
private List<Type> mDataSet;
private BitmapPool mPool;
enum Type {
CropTop,
@@ -69,90 +63,84 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
public MainAdapter(Context context, List<Type> dataSet) {
mContext = context;
mDataSet = dataSet;
mPool = Glide.get(mContext).getBitmapPool();
}
@Override
public MainAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(mContext)
.inflate(R.layout.layout_list_item, parent, false);
@Override public MainAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(mContext).inflate(R.layout.layout_list_item, parent, false);
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(MainAdapter.ViewHolder holder, int position) {
@Override public void onBindViewHolder(MainAdapter.ViewHolder holder, int position) {
Transformation transformation = null;
switch (mDataSet.get(position)) {
case CropTop:
transformation =
new CropTransformation(mPool, 300, 100, CropTransformation.CropType.TOP);
new CropTransformation(mContext, 300, 100, CropTransformation.CropType.TOP);
break;
case CropCenter:
transformation = new CropTransformation(mPool, 300, 100);
transformation = new CropTransformation(mContext, 300, 100);
break;
case CropBottom:
transformation =
new CropTransformation(mPool, 300, 100, CropTransformation.CropType.BOTTOM);
new CropTransformation(mContext, 300, 100, CropTransformation.CropType.BOTTOM);
break;
case CropSquare:
transformation = new CropSquareTransformation(mPool);
transformation = new CropSquareTransformation(mContext);
break;
case CropCircle:
transformation = new CropCircleTransformation(mPool);
transformation = new CropCircleTransformation(mContext);
break;
case ColorFilter:
transformation = new ColorFilterTransformation(mPool, Color.argb(80, 255, 0, 0));
transformation = new ColorFilterTransformation(mContext, Color.argb(80, 255, 0, 0));
break;
case Grayscale:
transformation = new GrayscaleTransformation(mPool);
transformation = new GrayscaleTransformation(mContext);
break;
case RoundedCorners:
transformation = new RoundedCornersTransformation(mPool, 100, 0);
transformation = new RoundedCornersTransformation(mContext, 100, 0);
break;
case Blur:
transformation = new BlurTransformation(mContext, mPool, 25, 1);
transformation = new BlurTransformation(mContext, 25, 1);
break;
case Toon:
transformation = new ToonFilterTransformation(mContext, mPool);
transformation = new ToonFilterTransformation(mContext);
break;
case Sepia:
transformation = new SepiaFilterTransformation(mContext, mPool);
transformation = new SepiaFilterTransformation(mContext);
break;
case Contrast:
transformation = new ContrastFilterTransformation(mContext, mPool, 2.0f);
transformation = new ContrastFilterTransformation(mContext, 2.0f);
break;
case Invert:
transformation = new InvertFilterTransformation(mContext, mPool);
transformation = new InvertFilterTransformation(mContext);
break;
case Pixel:
transformation = new PixelationFilterTransformation(mContext, mPool, 20);
transformation = new PixelationFilterTransformation(mContext, 20);
break;
case Sketch:
transformation = new SketchFilterTransformation(mContext, mPool);
transformation = new SketchFilterTransformation(mContext);
break;
case Swirl:
transformation = new SwirlFilterTransformation(mContext, mPool,
0.5f, 1.0f, new PointF(0.5f, 0.5f));
transformation =
new SwirlFilterTransformation(mContext, 0.5f, 1.0f, new PointF(0.5f, 0.5f));
break;
case Brightness:
transformation = new BrightnessFilterTransformation(mContext, mPool, 0.5f);
transformation = new BrightnessFilterTransformation(mContext, 0.5f);
break;
case Kuawahara:
transformation = new KuwaharaFilterTransformation(mContext, mPool, 25);
transformation = new KuwaharaFilterTransformation(mContext, 25);
break;
case Vignette:
transformation = new VignetteFilterTransformation(mContext, mPool,
new PointF(0.5f, 0.5f), new float[]{0.0f, 0.0f, 0.0f}, 0f, 0.75f);
transformation = new VignetteFilterTransformation(mContext, new PointF(0.5f, 0.5f),
new float[] { 0.0f, 0.0f, 0.0f }, 0f, 0.75f);
break;
}
Glide.with(mContext).load(R.drawable.demo)
.bitmapTransform(transformation).into(holder.image);
Glide.with(mContext).load(R.drawable.demo).bitmapTransform(transformation).into(holder.image);
holder.title.setText(mDataSet.get(position).name());
}
@Override
public int getItemCount() {
@Override public int getItemCount() {
return mDataSet.size();
}

View File

@@ -3,11 +3,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#CC000000"
tools:context=".MainActivity">
tools:context=".MainActivity"
>
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent"
/>
</RelativeLayout>

View File

@@ -2,14 +2,16 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">
android:padding="5dp"
>
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:contentDescription="@null"/>
android:contentDescription="@null"
/>
<TextView
android:id="@+id/title"
@@ -18,6 +20,7 @@
android:layout_below="@id/image"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:textColor="@android:color/white"/>
android:textColor="@android:color/white"
/>
</RelativeLayout>

View File

@@ -1,12 +1,12 @@
VERSION_NAME=1.0.8
VERSION_CODE=8
VERSION_NAME=1.1.0
VERSION_CODE=9
GROUP=jp.wasabeef
ARTIFACT_ID=glide-transformations
COMPILE_SDK_VERSION=22
BUILD_TOOLS_VERSION=22.0.1
TARGET_SDK_VERSION=22
RENDERSCRIPT_TARGET_API=22
COMPILE_SDK_VERSION=23
BUILD_TOOLS_VERSION=23.0.1
TARGET_SDK_VERSION=23
RENDERSCRIPT_TARGET_API=23
MIN_SDK_VERSION=11
POM_DESCRIPTION=which provides simple Tranformations to Glide
@@ -23,6 +23,6 @@ POM_DEVELOPER_EMAIL=dadadada.chop@gmail.com
POM_DEVELOPER_URL=wasabeef.jp
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
GPUIMAGE_VERSION=1.2.3
GPUIMAGE_VERSION=1.3.0

View File

@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip

View File

@@ -16,11 +16,6 @@ package jp.wasabeef.glide.transformations;
* limitations under the License.
*/
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -29,6 +24,11 @@ import android.support.v8.renderscript.Allocation;
import android.support.v8.renderscript.Element;
import android.support.v8.renderscript.RenderScript;
import android.support.v8.renderscript.ScriptIntrinsicBlur;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
public class BlurTransformation implements Transformation<Bitmap> {
@@ -41,6 +41,10 @@ public class BlurTransformation implements Transformation<Bitmap> {
private int mRadius;
private int mSampling;
public BlurTransformation(Context context) {
this(context, Glide.get(context).getBitmapPool(), MAX_RADIUS, DEFAULT_DOWN_SAMPLING);
}
public BlurTransformation(Context context, BitmapPool pool) {
this(context, pool, MAX_RADIUS, DEFAULT_DOWN_SAMPLING);
}
@@ -49,6 +53,10 @@ public class BlurTransformation implements Transformation<Bitmap> {
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) {
mContext = context;
mBitmapPool = pool;
@@ -56,6 +64,13 @@ public class BlurTransformation implements Transformation<Bitmap> {
mSampling = sampling;
}
public BlurTransformation(Context context, int radius, int sampling) {
mContext = context;
mBitmapPool = Glide.get(context).getBitmapPool();
mRadius = radius;
mSampling = sampling;
}
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
Bitmap source = resource.get();
@@ -77,8 +92,8 @@ public class BlurTransformation implements Transformation<Bitmap> {
canvas.drawBitmap(source, 0, 0, paint);
RenderScript rs = RenderScript.create(mContext);
Allocation input = Allocation.createFromBitmap(rs, bitmap,
Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
Allocation input = Allocation.createFromBitmap(rs, bitmap, Allocation.MipmapControl.MIPMAP_NONE,
Allocation.USAGE_SCRIPT);
Allocation output = Allocation.createTyped(rs, input.getType());
ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
@@ -92,8 +107,7 @@ public class BlurTransformation implements Transformation<Bitmap> {
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
@Override public String getId() {
return "BlurTransformation(radius=" + mRadius + ", sampling=" + mSampling + ")";
}
}

View File

@@ -16,16 +16,17 @@ package jp.wasabeef.glide.transformations;
* limitations under the License.
*/
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
public class ColorFilterTransformation implements Transformation<Bitmap> {
@@ -33,6 +34,10 @@ public class ColorFilterTransformation implements Transformation<Bitmap> {
private int mColor;
public ColorFilterTransformation(Context context, int color) {
this(Glide.get(context).getBitmapPool(), color);
}
public ColorFilterTransformation(BitmapPool pool, int color) {
mBitmapPool = pool;
mColor = color;
@@ -61,8 +66,7 @@ public class ColorFilterTransformation implements Transformation<Bitmap> {
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
@Override public String getId() {
return "ColorFilterTransformation(color=" + mColor + ")";
}
}

View File

@@ -16,21 +16,26 @@ package jp.wasabeef.glide.transformations;
* limitations under the License.
*/
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
public class CropCircleTransformation implements Transformation<Bitmap> {
private BitmapPool mBitmapPool;
public CropCircleTransformation(Context context) {
this(Glide.get(context).getBitmapPool());
}
public CropCircleTransformation(BitmapPool pool) {
this.mBitmapPool = pool;
}
@@ -50,8 +55,8 @@ public class CropCircleTransformation implements Transformation<Bitmap> {
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
BitmapShader shader = new BitmapShader(source, BitmapShader.TileMode.CLAMP,
BitmapShader.TileMode.CLAMP);
BitmapShader shader =
new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
if (width != 0 || height != 0) {
Matrix matrix = new Matrix();
matrix.setTranslate(-width, -height);
@@ -66,8 +71,7 @@ public class CropCircleTransformation implements Transformation<Bitmap> {
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
@Override public String getId() {
return "CropCircleTransformation()";
}
}

View File

@@ -16,19 +16,24 @@ package jp.wasabeef.glide.transformations;
* limitations under the License.
*/
import android.content.Context;
import android.graphics.Bitmap;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.graphics.Bitmap;
public class CropSquareTransformation implements Transformation<Bitmap> {
private BitmapPool mBitmapPool;
private int mWidth;
private int mHeight;
public CropSquareTransformation(Context context) {
this(Glide.get(context).getBitmapPool());
}
public CropSquareTransformation(BitmapPool pool) {
this.mBitmapPool = pool;
}
@@ -51,8 +56,7 @@ public class CropSquareTransformation implements Transformation<Bitmap> {
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
@Override public String getId() {
return "CropSquareTransformation(width=" + mWidth + ", height=" + mHeight + ")";
}
}

View File

@@ -16,31 +16,48 @@ package jp.wasabeef.glide.transformations;
* limitations under the License.
*/
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.RectF;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.RectF;
public class CropTransformation implements Transformation<Bitmap> {
public enum CropType {
TOP,
CENTER,
BOTTOM
}
private BitmapPool mBitmapPool;
private int mWidth;
private int mHeight;
private CropType mCropType = CropType.CENTER;
public CropTransformation(Context context) {
this(Glide.get(context).getBitmapPool());
}
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) {
mBitmapPool = pool;
mWidth = width;
mHeight = height;
this(pool, width, height, CropType.CENTER);
}
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) {
@@ -79,10 +96,9 @@ public class CropTransformation implements Transformation<Bitmap> {
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
return "CropTransformation(width=" + mWidth + ", height=" + mHeight + ", cropType="
+ mCropType + ")";
@Override public String getId() {
return "CropTransformation(width=" + mWidth + ", height=" + mHeight + ", cropType=" + mCropType
+ ")";
}
private float getTop(float scaledHeight) {
@@ -97,10 +113,4 @@ public class CropTransformation implements Transformation<Bitmap> {
return 0;
}
}
public enum CropType {
TOP,
CENTER,
BOTTOM
}
}

View File

@@ -16,21 +16,26 @@ package jp.wasabeef.glide.transformations;
* limitations under the License.
*/
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
public class GrayscaleTransformation implements Transformation<Bitmap> {
private BitmapPool mBitmapPool;
public GrayscaleTransformation(Context context) {
this(Glide.get(context).getBitmapPool());
}
public GrayscaleTransformation(BitmapPool pool) {
mBitmapPool = pool;
}
@@ -59,8 +64,7 @@ public class GrayscaleTransformation implements Transformation<Bitmap> {
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
@Override public String getId() {
return "GrayscaleTransformation()";
}
}

View File

@@ -16,17 +16,18 @@ package jp.wasabeef.glide.transformations;
* limitations under the License.
*/
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
public class RoundedCornersTransformation implements Transformation<Bitmap> {
@@ -35,10 +36,14 @@ public class RoundedCornersTransformation implements Transformation<Bitmap> {
private int radius;
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) {
mBitmapPool = pool;
this.radius = radius;
this.margin = margin;
mBitmapPool = pool;
}
@Override
@@ -57,14 +62,13 @@ public class RoundedCornersTransformation implements Transformation<Bitmap> {
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
canvas.drawRoundRect(new RectF(margin, margin, width - margin, height - margin),
radius, radius, paint);
canvas.drawRoundRect(new RectF(margin, margin, width - margin, height - margin), radius, radius,
paint);
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
@Override public String getId() {
return "RoundedTransformation(radius=" + radius + ", margin=" + margin + ")";
}
}

View File

@@ -16,14 +16,13 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License.
*/
import android.content.Context;
import android.graphics.Bitmap;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.content.Context;
import android.graphics.Bitmap;
import jp.co.cyberagent.android.gpuimage.GPUImage;
import jp.co.cyberagent.android.gpuimage.GPUImageBrightnessFilter;
@@ -38,9 +37,16 @@ public class BrightnessFilterTransformation implements Transformation<Bitmap> {
private GPUImageBrightnessFilter mFilter = new GPUImageBrightnessFilter();
private float mBrightness;
public BrightnessFilterTransformation(Context context) {
this(context, Glide.get(context).getBitmapPool());
}
public BrightnessFilterTransformation(Context context, BitmapPool pool) {
mContext = context;
mBitmapPool = pool;
this(context, pool, 0.0f);
}
public BrightnessFilterTransformation(Context context, float brightness) {
this(context, Glide.get(context).getBitmapPool(), brightness);
}
public BrightnessFilterTransformation(Context context, BitmapPool pool, float brightness) {
@@ -64,8 +70,7 @@ public class BrightnessFilterTransformation implements Transformation<Bitmap> {
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
@Override public String getId() {
return "BrightnessFilterTransformation(brightness=" + mBrightness + ")";
}
}

View File

@@ -16,14 +16,13 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License.
*/
import android.content.Context;
import android.graphics.Bitmap;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.content.Context;
import android.graphics.Bitmap;
import jp.co.cyberagent.android.gpuimage.GPUImage;
import jp.co.cyberagent.android.gpuimage.GPUImageContrastFilter;
@@ -38,9 +37,16 @@ public class ContrastFilterTransformation implements Transformation<Bitmap> {
private GPUImageContrastFilter mFilter = new GPUImageContrastFilter();
private float mContrast;
public ContrastFilterTransformation(Context context) {
this(context, Glide.get(context).getBitmapPool());
}
public ContrastFilterTransformation(Context context, BitmapPool pool) {
mContext = context;
mBitmapPool = pool;
this(context, pool, 1.0f);
}
public ContrastFilterTransformation(Context context, float contrast) {
this(context, Glide.get(context).getBitmapPool(), contrast);
}
public ContrastFilterTransformation(Context context, BitmapPool pool, float contrast) {
@@ -64,8 +70,7 @@ public class ContrastFilterTransformation implements Transformation<Bitmap> {
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
@Override public String getId() {
return "ContrastFilterTransformation(contrast=" + mContrast + ")";
}
}

View File

@@ -16,22 +16,28 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License.
*/
import android.content.Context;
import android.graphics.Bitmap;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.content.Context;
import android.graphics.Bitmap;
import jp.co.cyberagent.android.gpuimage.GPUImage;
import jp.co.cyberagent.android.gpuimage.GPUImageColorInvertFilter;
/**
* Invert all the colors in the image.
*/
public class InvertFilterTransformation implements Transformation<Bitmap> {
private Context mContext;
private BitmapPool mBitmapPool;
public InvertFilterTransformation(Context context) {
this(context, Glide.get(context).getBitmapPool());
}
public InvertFilterTransformation(Context context, BitmapPool pool) {
mContext = context;
mBitmapPool = pool;
@@ -51,8 +57,7 @@ public class InvertFilterTransformation implements Transformation<Bitmap> {
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
@Override public String getId() {
return "InvertFilterTransformation()";
}
}

View File

@@ -16,19 +16,26 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License.
*/
import android.content.Context;
import android.graphics.Bitmap;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.content.Context;
import android.graphics.Bitmap;
import jp.co.cyberagent.android.gpuimage.GPUImage;
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.
*/
public class KuwaharaFilterTransformation implements Transformation<Bitmap> {
@@ -39,9 +46,16 @@ public class KuwaharaFilterTransformation implements Transformation<Bitmap> {
private GPUImageKuwaharaFilter mFilter = new GPUImageKuwaharaFilter();
private int mRadius;
public KuwaharaFilterTransformation(Context context) {
this(context, Glide.get(context).getBitmapPool());
}
public KuwaharaFilterTransformation(Context context, BitmapPool pool) {
mContext = context;
mBitmapPool = pool;
this(context, pool, 25);
}
public KuwaharaFilterTransformation(Context context, int radius) {
this(context, Glide.get(context).getBitmapPool(), radius);
}
public KuwaharaFilterTransformation(Context context, BitmapPool pool, int radius) {
@@ -65,8 +79,7 @@ public class KuwaharaFilterTransformation implements Transformation<Bitmap> {
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
@Override public String getId() {
return "KuwaharaFilterTransformation(radius=" + mRadius + ")";
}
}

View File

@@ -16,17 +16,21 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License.
*/
import android.content.Context;
import android.graphics.Bitmap;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.content.Context;
import android.graphics.Bitmap;
import jp.co.cyberagent.android.gpuimage.GPUImage;
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> {
private Context mContext;
@@ -35,9 +39,16 @@ public class PixelationFilterTransformation implements Transformation<Bitmap> {
private GPUImagePixelationFilter mFilter = new GPUImagePixelationFilter();
private float mPixel;
public PixelationFilterTransformation(Context context) {
this(context, Glide.get(context).getBitmapPool());
}
public PixelationFilterTransformation(Context context, BitmapPool pool) {
mContext = context;
mBitmapPool = pool;
this(context, pool, 10f);
}
public PixelationFilterTransformation(Context context, float pixel) {
this(context, Glide.get(context).getBitmapPool(), pixel);
}
public PixelationFilterTransformation(Context context, BitmapPool pool, float pixel) {
@@ -61,8 +72,7 @@ public class PixelationFilterTransformation implements Transformation<Bitmap> {
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
@Override public String getId() {
return "PixelationFilterTransformation(pixel=" + mPixel + ")";
}
}

View File

@@ -16,17 +16,21 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License.
*/
import android.content.Context;
import android.graphics.Bitmap;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.content.Context;
import android.graphics.Bitmap;
import jp.co.cyberagent.android.gpuimage.GPUImage;
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> {
private Context mContext;
@@ -35,9 +39,16 @@ public class SepiaFilterTransformation implements Transformation<Bitmap> {
private GPUImageSepiaFilter mFilter = new GPUImageSepiaFilter();
private float mIntensity;
public SepiaFilterTransformation(Context context) {
this(context, Glide.get(context).getBitmapPool());
}
public SepiaFilterTransformation(Context context, BitmapPool pool) {
mContext = context;
mBitmapPool = pool;
this(context, pool, 1.0f);
}
public SepiaFilterTransformation(Context context, float intensity) {
this(context, Glide.get(context).getBitmapPool(), intensity);
}
public SepiaFilterTransformation(Context context, BitmapPool pool, float intensity) {
@@ -61,8 +72,7 @@ public class SepiaFilterTransformation implements Transformation<Bitmap> {
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
@Override public String getId() {
return "SepiaFilterTransformation(intensity=" + mIntensity + ")";
}
}

View File

@@ -16,14 +16,13 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License.
*/
import android.content.Context;
import android.graphics.Bitmap;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.content.Context;
import android.graphics.Bitmap;
import jp.co.cyberagent.android.gpuimage.GPUImage;
import jp.co.cyberagent.android.gpuimage.GPUImageSketchFilter;
@@ -32,6 +31,10 @@ public class SketchFilterTransformation implements Transformation<Bitmap> {
private Context mContext;
private BitmapPool mBitmapPool;
public SketchFilterTransformation(Context context) {
this(context, Glide.get(context).getBitmapPool());
}
public SketchFilterTransformation(Context context, BitmapPool pool) {
mContext = context;
mBitmapPool = pool;
@@ -51,8 +54,7 @@ public class SketchFilterTransformation implements Transformation<Bitmap> {
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
@Override public String getId() {
return "SketchFilterTransformation()";
}
}

View File

@@ -16,18 +16,20 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License.
*/
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.PointF;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.PointF;
import jp.co.cyberagent.android.gpuimage.GPUImage;
import jp.co.cyberagent.android.gpuimage.GPUImageSwirlFilter;
/**
* Creates a swirl distortion on the image.
*/
public class SwirlFilterTransformation implements Transformation<Bitmap> {
private Context mContext;
@@ -38,10 +40,16 @@ public class SwirlFilterTransformation implements Transformation<Bitmap> {
private float mAngle;
private PointF mCenter;
public SwirlFilterTransformation(Context context) {
this(context, Glide.get(context).getBitmapPool());
}
public SwirlFilterTransformation(Context context, BitmapPool pool) {
mContext = context;
mBitmapPool = pool;
mCenter = new PointF();
this(context, pool, .5f, 1.0f, new PointF(0.5f, 0.5f));
}
public SwirlFilterTransformation(Context context, float radius, float angle, PointF center) {
this(context, Glide.get(context).getBitmapPool(), radius, angle, center);
}
/**
@@ -49,8 +57,8 @@ public class SwirlFilterTransformation implements Transformation<Bitmap> {
* @param angle minimum 0.0, default 1.0
* @param center default (0.5, 0.5)
*/
public SwirlFilterTransformation(Context context, BitmapPool pool,
float radius, float angle, PointF center) {
public SwirlFilterTransformation(Context context, BitmapPool pool, float radius, float angle,
PointF center) {
mContext = context;
mBitmapPool = pool;
mRadius = radius;
@@ -75,8 +83,7 @@ public class SwirlFilterTransformation implements Transformation<Bitmap> {
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
@Override public String getId() {
return "SwirlFilterTransformation(radius=" + mRadius +
",angle=" + mAngle + ",center=" + mCenter.toString() + ")";
}

View File

@@ -16,17 +16,21 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License.
*/
import android.content.Context;
import android.graphics.Bitmap;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.content.Context;
import android.graphics.Bitmap;
import jp.co.cyberagent.android.gpuimage.GPUImage;
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> {
private Context mContext;
@@ -36,13 +40,20 @@ public class ToonFilterTransformation implements Transformation<Bitmap> {
private float mThreshold;
private float mQuantizationLevels;
public ToonFilterTransformation(Context context, BitmapPool pool) {
mContext = context;
mBitmapPool = pool;
public ToonFilterTransformation(Context context) {
this(context, Glide.get(context).getBitmapPool());
}
public ToonFilterTransformation(Context context, BitmapPool pool,
float threshold, float quantizationLevels) {
public ToonFilterTransformation(Context context, BitmapPool pool) {
this(context, pool, .2f, 10.0f);
}
public ToonFilterTransformation(Context context, float threshold, float quantizationLevels) {
this(context, Glide.get(context).getBitmapPool(), threshold, quantizationLevels);
}
public ToonFilterTransformation(Context context, BitmapPool pool, float threshold,
float quantizationLevels) {
mContext = context;
mBitmapPool = pool;
mThreshold = threshold;
@@ -65,8 +76,7 @@ public class ToonFilterTransformation implements Transformation<Bitmap> {
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
@Override public String getId() {
return "ToonFilterTransformation(threshold=" + mThreshold +
",quantizationLevels=" + mQuantizationLevels + ")";
}

View File

@@ -16,24 +16,22 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License.
*/
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.PointF;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.PointF;
import java.util.Arrays;
import jp.co.cyberagent.android.gpuimage.GPUImage;
import jp.co.cyberagent.android.gpuimage.GPUImageVignetteFilter;
/**
* Performs a vignetting effect, fading out the image at the edges
* x:
* y: The directional intensity of the vignetting, with a default of x = 0.75, y = 0.5
* The directional intensity of the vignetting,
* with a default of x = 0.5, y = 0.5, start = 0, end = 0.75
*/
public class VignetteFilterTransformation implements Transformation<Bitmap> {
@@ -46,15 +44,21 @@ public class VignetteFilterTransformation implements Transformation<Bitmap> {
private float mVignetteStart;
private float mVignetteEnd;
public VignetteFilterTransformation(Context context, BitmapPool pool) {
mContext = context;
mBitmapPool = pool;
mCenter = new PointF();
public VignetteFilterTransformation(Context context) {
this(context, Glide.get(context).getBitmapPool());
}
public VignetteFilterTransformation(Context context, BitmapPool pool,
PointF center, float[] color, float start, float end) {
public VignetteFilterTransformation(Context context, BitmapPool pool) {
this(context, pool, new PointF(0.5f, 0.5f), new float[] { 0.0f, 0.0f, 0.0f }, 0.0f, 0.75f);
}
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, PointF center,
float[] color, float start, float end) {
mContext = context;
mBitmapPool = pool;
mCenter = center;
@@ -81,8 +85,7 @@ public class VignetteFilterTransformation implements Transformation<Bitmap> {
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override
public String getId() {
@Override public String getId() {
return "VignetteFilterTransformation(center=" + mCenter.toString() +
",color=" + Arrays.toString(mVignetteColor) +
",start=" + mVignetteStart + ",end=" + mVignetteEnd + ")";