mirror of
https://github.com/wasabeef/glide-transformations.git
synced 2025-06-12 10:14:04 +08:00
change the codestyle
This commit is contained in:
parent
cdbd42595a
commit
f83e5ef85a
@ -1,15 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="jp.wasabeef.example.glide" >
|
package="jp.wasabeef.example.glide"
|
||||||
|
>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/AppTheme" >
|
android:theme="@style/AppTheme"
|
||||||
|
>
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:label="@string/app_name" >
|
android:label="@string/app_name"
|
||||||
|
>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
|
||||||
|
@ -4,17 +4,13 @@ import android.os.Bundle;
|
|||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.GridLayoutManager;
|
import android.support.v7.widget.GridLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jp.wasabeef.example.glide.MainAdapter.Type;
|
import jp.wasabeef.example.glide.MainAdapter.Type;
|
||||||
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override protected void onCreate(Bundle savedInstanceState) {
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package jp.wasabeef.example.glide;
|
package jp.wasabeef.example.glide;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
|
||||||
import com.bumptech.glide.load.Transformation;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
@ -12,9 +9,9 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.load.Transformation;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import jp.wasabeef.glide.transformations.BlurTransformation;
|
import jp.wasabeef.glide.transformations.BlurTransformation;
|
||||||
import jp.wasabeef.glide.transformations.ColorFilterTransformation;
|
import jp.wasabeef.glide.transformations.ColorFilterTransformation;
|
||||||
import jp.wasabeef.glide.transformations.CropCircleTransformation;
|
import jp.wasabeef.glide.transformations.CropCircleTransformation;
|
||||||
@ -68,15 +65,12 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
|
|||||||
mDataSet = dataSet;
|
mDataSet = dataSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public MainAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
public MainAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
View v = LayoutInflater.from(mContext).inflate(R.layout.layout_list_item, parent, false);
|
||||||
View v = LayoutInflater.from(mContext)
|
|
||||||
.inflate(R.layout.layout_list_item, parent, false);
|
|
||||||
return new ViewHolder(v);
|
return new ViewHolder(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public void onBindViewHolder(MainAdapter.ViewHolder holder, int position) {
|
||||||
public void onBindViewHolder(MainAdapter.ViewHolder holder, int position) {
|
|
||||||
Transformation transformation = null;
|
Transformation transformation = null;
|
||||||
switch (mDataSet.get(position)) {
|
switch (mDataSet.get(position)) {
|
||||||
case CropTop:
|
case CropTop:
|
||||||
@ -88,8 +82,7 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
|
|||||||
break;
|
break;
|
||||||
case CropBottom:
|
case CropBottom:
|
||||||
transformation =
|
transformation =
|
||||||
new CropTransformation(mContext, 300, 100,
|
new CropTransformation(mContext, 300, 100, CropTransformation.CropType.BOTTOM);
|
||||||
CropTransformation.CropType.BOTTOM);
|
|
||||||
break;
|
break;
|
||||||
case CropSquare:
|
case CropSquare:
|
||||||
transformation = new CropSquareTransformation(mContext);
|
transformation = new CropSquareTransformation(mContext);
|
||||||
@ -128,8 +121,8 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
|
|||||||
transformation = new SketchFilterTransformation(mContext);
|
transformation = new SketchFilterTransformation(mContext);
|
||||||
break;
|
break;
|
||||||
case Swirl:
|
case Swirl:
|
||||||
transformation = new SwirlFilterTransformation(mContext,
|
transformation =
|
||||||
0.5f, 1.0f, new PointF(0.5f, 0.5f));
|
new SwirlFilterTransformation(mContext, 0.5f, 1.0f, new PointF(0.5f, 0.5f));
|
||||||
break;
|
break;
|
||||||
case Brightness:
|
case Brightness:
|
||||||
transformation = new BrightnessFilterTransformation(mContext, 0.5f);
|
transformation = new BrightnessFilterTransformation(mContext, 0.5f);
|
||||||
@ -138,18 +131,16 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
|
|||||||
transformation = new KuwaharaFilterTransformation(mContext, 25);
|
transformation = new KuwaharaFilterTransformation(mContext, 25);
|
||||||
break;
|
break;
|
||||||
case Vignette:
|
case Vignette:
|
||||||
transformation = new VignetteFilterTransformation(mContext,
|
transformation = new VignetteFilterTransformation(mContext, new PointF(0.5f, 0.5f),
|
||||||
new PointF(0.5f, 0.5f), new float[]{0.0f, 0.0f, 0.0f}, 0f, 0.75f);
|
new float[] { 0.0f, 0.0f, 0.0f }, 0f, 0.75f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Glide.with(mContext).load(R.drawable.demo)
|
Glide.with(mContext).load(R.drawable.demo).bitmapTransform(transformation).into(holder.image);
|
||||||
.bitmapTransform(transformation).into(holder.image);
|
|
||||||
holder.title.setText(mDataSet.get(position).name());
|
holder.title.setText(mDataSet.get(position).name());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public int getItemCount() {
|
||||||
public int getItemCount() {
|
|
||||||
return mDataSet.size();
|
return mDataSet.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,11 +3,13 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#CC000000"
|
android:background="#CC000000"
|
||||||
tools:context=".MainActivity">
|
tools:context=".MainActivity"
|
||||||
|
>
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/list"
|
android:id="@+id/list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"
|
||||||
|
/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -2,14 +2,16 @@
|
|||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="5dp">
|
android:padding="5dp"
|
||||||
|
>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/image"
|
android:id="@+id/image"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
android:contentDescription="@null"/>
|
android:contentDescription="@null"
|
||||||
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
@ -18,6 +20,7 @@
|
|||||||
android:layout_below="@id/image"
|
android:layout_below="@id/image"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
android:textColor="@android:color/white"/>
|
android:textColor="@android:color/white"
|
||||||
|
/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
@ -16,12 +16,6 @@ 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.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.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
@ -30,6 +24,11 @@ import android.support.v8.renderscript.Allocation;
|
|||||||
import android.support.v8.renderscript.Element;
|
import android.support.v8.renderscript.Element;
|
||||||
import android.support.v8.renderscript.RenderScript;
|
import android.support.v8.renderscript.RenderScript;
|
||||||
import android.support.v8.renderscript.ScriptIntrinsicBlur;
|
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> {
|
public class BlurTransformation implements Transformation<Bitmap> {
|
||||||
|
|
||||||
@ -93,8 +92,8 @@ public class BlurTransformation implements Transformation<Bitmap> {
|
|||||||
canvas.drawBitmap(source, 0, 0, paint);
|
canvas.drawBitmap(source, 0, 0, paint);
|
||||||
|
|
||||||
RenderScript rs = RenderScript.create(mContext);
|
RenderScript rs = RenderScript.create(mContext);
|
||||||
Allocation input = Allocation.createFromBitmap(rs, bitmap,
|
Allocation input = Allocation.createFromBitmap(rs, bitmap, Allocation.MipmapControl.MIPMAP_NONE,
|
||||||
Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
|
Allocation.USAGE_SCRIPT);
|
||||||
Allocation output = Allocation.createTyped(rs, input.getType());
|
Allocation output = Allocation.createTyped(rs, input.getType());
|
||||||
ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
|
ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
|
||||||
|
|
||||||
@ -108,8 +107,7 @@ public class BlurTransformation implements Transformation<Bitmap> {
|
|||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
|
||||||
return "BlurTransformation(radius=" + mRadius + ", sampling=" + mSampling + ")";
|
return "BlurTransformation(radius=" + mRadius + ", sampling=" + mSampling + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,18 +16,17 @@ 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.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.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;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
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> {
|
public class ColorFilterTransformation implements Transformation<Bitmap> {
|
||||||
|
|
||||||
@ -67,8 +66,7 @@ public class ColorFilterTransformation implements Transformation<Bitmap> {
|
|||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
|
||||||
return "ColorFilterTransformation(color=" + mColor + ")";
|
return "ColorFilterTransformation(color=" + mColor + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,18 +16,17 @@ 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.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.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;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Paint;
|
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> {
|
public class CropCircleTransformation implements Transformation<Bitmap> {
|
||||||
|
|
||||||
@ -56,8 +55,8 @@ public class CropCircleTransformation implements Transformation<Bitmap> {
|
|||||||
|
|
||||||
Canvas canvas = new Canvas(bitmap);
|
Canvas canvas = new Canvas(bitmap);
|
||||||
Paint paint = new Paint();
|
Paint paint = new Paint();
|
||||||
BitmapShader shader = new BitmapShader(source, BitmapShader.TileMode.CLAMP,
|
BitmapShader shader =
|
||||||
BitmapShader.TileMode.CLAMP);
|
new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
|
||||||
if (width != 0 || height != 0) {
|
if (width != 0 || height != 0) {
|
||||||
Matrix matrix = new Matrix();
|
Matrix matrix = new Matrix();
|
||||||
matrix.setTranslate(-width, -height);
|
matrix.setTranslate(-width, -height);
|
||||||
@ -72,8 +71,7 @@ public class CropCircleTransformation implements Transformation<Bitmap> {
|
|||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
|
||||||
return "CropCircleTransformation()";
|
return "CropCircleTransformation()";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,15 +16,14 @@ package jp.wasabeef.glide.transformations;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
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.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;
|
|
||||||
|
|
||||||
public class CropSquareTransformation implements Transformation<Bitmap> {
|
public class CropSquareTransformation implements Transformation<Bitmap> {
|
||||||
|
|
||||||
private BitmapPool mBitmapPool;
|
private BitmapPool mBitmapPool;
|
||||||
@ -57,8 +56,7 @@ public class CropSquareTransformation implements Transformation<Bitmap> {
|
|||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
|
||||||
return "CropSquareTransformation(width=" + mWidth + ", height=" + mHeight + ")";
|
return "CropSquareTransformation(width=" + mWidth + ", height=" + mHeight + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,17 +16,16 @@ package jp.wasabeef.glide.transformations;
|
|||||||
* limitations under the License.
|
* 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.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.Canvas;
|
|
||||||
import android.graphics.RectF;
|
|
||||||
|
|
||||||
public class CropTransformation implements Transformation<Bitmap> {
|
public class CropTransformation implements Transformation<Bitmap> {
|
||||||
|
|
||||||
public enum CropType {
|
public enum CropType {
|
||||||
@ -97,10 +96,9 @@ public class CropTransformation implements Transformation<Bitmap> {
|
|||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
return "CropTransformation(width=" + mWidth + ", height=" + mHeight + ", cropType=" + mCropType
|
||||||
return "CropTransformation(width=" + mWidth + ", height=" + mHeight + ", cropType="
|
+ ")";
|
||||||
+ mCropType + ")";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getTop(float scaledHeight) {
|
private float getTop(float scaledHeight) {
|
||||||
|
@ -16,18 +16,17 @@ 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.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.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;
|
||||||
import android.graphics.ColorMatrixColorFilter;
|
import android.graphics.ColorMatrixColorFilter;
|
||||||
import android.graphics.Paint;
|
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> {
|
public class GrayscaleTransformation implements Transformation<Bitmap> {
|
||||||
|
|
||||||
@ -65,8 +64,7 @@ public class GrayscaleTransformation implements Transformation<Bitmap> {
|
|||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
|
||||||
return "GrayscaleTransformation()";
|
return "GrayscaleTransformation()";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,6 @@ 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.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.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapShader;
|
import android.graphics.BitmapShader;
|
||||||
@ -29,6 +23,11 @@ import android.graphics.Canvas;
|
|||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.graphics.Shader;
|
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> {
|
public class RoundedCornersTransformation implements Transformation<Bitmap> {
|
||||||
|
|
||||||
@ -63,14 +62,13 @@ public class RoundedCornersTransformation implements Transformation<Bitmap> {
|
|||||||
Paint paint = new Paint();
|
Paint paint = new Paint();
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
|
paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
|
||||||
canvas.drawRoundRect(new RectF(margin, margin, width - margin, height - margin),
|
canvas.drawRoundRect(new RectF(margin, margin, width - margin, height - margin), radius, radius,
|
||||||
radius, radius, paint);
|
paint);
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
|
||||||
return "RoundedTransformation(radius=" + radius + ", margin=" + margin + ")";
|
return "RoundedTransformation(radius=" + radius + ", margin=" + margin + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,15 +16,13 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
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.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 jp.co.cyberagent.android.gpuimage.GPUImage;
|
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
||||||
import jp.co.cyberagent.android.gpuimage.GPUImageBrightnessFilter;
|
import jp.co.cyberagent.android.gpuimage.GPUImageBrightnessFilter;
|
||||||
|
|
||||||
@ -72,8 +70,7 @@ public class BrightnessFilterTransformation implements Transformation<Bitmap> {
|
|||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
|
||||||
return "BrightnessFilterTransformation(brightness=" + mBrightness + ")";
|
return "BrightnessFilterTransformation(brightness=" + mBrightness + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,15 +16,13 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
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.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 jp.co.cyberagent.android.gpuimage.GPUImage;
|
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
||||||
import jp.co.cyberagent.android.gpuimage.GPUImageContrastFilter;
|
import jp.co.cyberagent.android.gpuimage.GPUImageContrastFilter;
|
||||||
|
|
||||||
@ -72,8 +70,7 @@ public class ContrastFilterTransformation implements Transformation<Bitmap> {
|
|||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
|
||||||
return "ContrastFilterTransformation(contrast=" + mContrast + ")";
|
return "ContrastFilterTransformation(contrast=" + mContrast + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,15 +16,13 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
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.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 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;
|
||||||
|
|
||||||
@ -59,8 +57,7 @@ public class InvertFilterTransformation implements Transformation<Bitmap> {
|
|||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
|
||||||
return "InvertFilterTransformation()";
|
return "InvertFilterTransformation()";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,15 +16,13 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
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.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 jp.co.cyberagent.android.gpuimage.GPUImage;
|
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
||||||
import jp.co.cyberagent.android.gpuimage.GPUImageKuwaharaFilter;
|
import jp.co.cyberagent.android.gpuimage.GPUImageKuwaharaFilter;
|
||||||
|
|
||||||
@ -32,7 +30,8 @@ import jp.co.cyberagent.android.gpuimage.GPUImageKuwaharaFilter;
|
|||||||
* Kuwahara image abstraction, drawn from the work of Kyprianidis, et. al. in their publication
|
* 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
|
* "Anisotropic Kuwahara Filtering on the GPU" within the GPU Pro collection. This produces an
|
||||||
* oil-painting-like
|
* oil-painting-like
|
||||||
* image, but it is extremely computationally expensive, so it can take seconds to render a frame on
|
* image, but it is extremely computationally expensive, so it can take seconds to render a frame
|
||||||
|
* on
|
||||||
* an iPad 2.
|
* an iPad 2.
|
||||||
* This might be best used for still images.
|
* This might be best used for still images.
|
||||||
*
|
*
|
||||||
@ -80,8 +79,7 @@ public class KuwaharaFilterTransformation implements Transformation<Bitmap> {
|
|||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
|
||||||
return "KuwaharaFilterTransformation(radius=" + mRadius + ")";
|
return "KuwaharaFilterTransformation(radius=" + mRadius + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,15 +16,13 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
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.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 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;
|
||||||
|
|
||||||
@ -74,8 +72,7 @@ public class PixelationFilterTransformation implements Transformation<Bitmap> {
|
|||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
|
||||||
return "PixelationFilterTransformation(pixel=" + mPixel + ")";
|
return "PixelationFilterTransformation(pixel=" + mPixel + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,15 +16,13 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
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.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 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;
|
||||||
|
|
||||||
@ -74,8 +72,7 @@ public class SepiaFilterTransformation implements Transformation<Bitmap> {
|
|||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
|
||||||
return "SepiaFilterTransformation(intensity=" + mIntensity + ")";
|
return "SepiaFilterTransformation(intensity=" + mIntensity + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,15 +16,13 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
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.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 jp.co.cyberagent.android.gpuimage.GPUImage;
|
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
||||||
import jp.co.cyberagent.android.gpuimage.GPUImageSketchFilter;
|
import jp.co.cyberagent.android.gpuimage.GPUImageSketchFilter;
|
||||||
|
|
||||||
@ -56,8 +54,7 @@ public class SketchFilterTransformation implements Transformation<Bitmap> {
|
|||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
|
||||||
return "SketchFilterTransformation()";
|
return "SketchFilterTransformation()";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,16 +16,14 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* 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.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.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;
|
||||||
|
|
||||||
@ -50,8 +48,7 @@ public class SwirlFilterTransformation implements Transformation<Bitmap> {
|
|||||||
this(context, pool, .5f, 1.0f, new PointF(0.5f, 0.5f));
|
this(context, pool, .5f, 1.0f, new PointF(0.5f, 0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SwirlFilterTransformation(Context context,
|
public SwirlFilterTransformation(Context context, float radius, float angle, PointF center) {
|
||||||
float radius, float angle, PointF center) {
|
|
||||||
this(context, Glide.get(context).getBitmapPool(), radius, angle, center);
|
this(context, Glide.get(context).getBitmapPool(), radius, angle, center);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,8 +57,8 @@ public class SwirlFilterTransformation implements Transformation<Bitmap> {
|
|||||||
* @param angle minimum 0.0, default 1.0
|
* @param angle minimum 0.0, default 1.0
|
||||||
* @param center default (0.5, 0.5)
|
* @param center default (0.5, 0.5)
|
||||||
*/
|
*/
|
||||||
public SwirlFilterTransformation(Context context, BitmapPool pool,
|
public SwirlFilterTransformation(Context context, BitmapPool pool, float radius, float angle,
|
||||||
float radius, float angle, PointF center) {
|
PointF center) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mBitmapPool = pool;
|
mBitmapPool = pool;
|
||||||
mRadius = radius;
|
mRadius = radius;
|
||||||
@ -86,8 +83,7 @@ public class SwirlFilterTransformation implements Transformation<Bitmap> {
|
|||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
|
||||||
return "SwirlFilterTransformation(radius=" + mRadius +
|
return "SwirlFilterTransformation(radius=" + mRadius +
|
||||||
",angle=" + mAngle + ",center=" + mCenter.toString() + ")";
|
",angle=" + mAngle + ",center=" + mCenter.toString() + ")";
|
||||||
}
|
}
|
||||||
|
@ -16,15 +16,13 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
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.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 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;
|
||||||
|
|
||||||
@ -54,8 +52,8 @@ public class ToonFilterTransformation implements Transformation<Bitmap> {
|
|||||||
this(context, Glide.get(context).getBitmapPool(), threshold, quantizationLevels);
|
this(context, Glide.get(context).getBitmapPool(), threshold, quantizationLevels);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToonFilterTransformation(Context context, BitmapPool pool,
|
public ToonFilterTransformation(Context context, BitmapPool pool, float threshold,
|
||||||
float threshold, float quantizationLevels) {
|
float quantizationLevels) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mBitmapPool = pool;
|
mBitmapPool = pool;
|
||||||
mThreshold = threshold;
|
mThreshold = threshold;
|
||||||
@ -78,8 +76,7 @@ public class ToonFilterTransformation implements Transformation<Bitmap> {
|
|||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
|
||||||
return "ToonFilterTransformation(threshold=" + mThreshold +
|
return "ToonFilterTransformation(threshold=" + mThreshold +
|
||||||
",quantizationLevels=" + mQuantizationLevels + ")";
|
",quantizationLevels=" + mQuantizationLevels + ")";
|
||||||
}
|
}
|
||||||
|
@ -16,18 +16,15 @@ package jp.wasabeef.glide.transformations.gpu;
|
|||||||
* limitations under the License.
|
* 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.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.PointF;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
||||||
import jp.co.cyberagent.android.gpuimage.GPUImageVignetteFilter;
|
import jp.co.cyberagent.android.gpuimage.GPUImageVignetteFilter;
|
||||||
|
|
||||||
@ -55,13 +52,13 @@ public class VignetteFilterTransformation implements Transformation<Bitmap> {
|
|||||||
this(context, pool, new PointF(0.5f, 0.5f), new float[] { 0.0f, 0.0f, 0.0f }, 0.0f, 0.75f);
|
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,
|
public VignetteFilterTransformation(Context context, PointF center, float[] color, float start,
|
||||||
PointF center, float[] color, float start, float end) {
|
float end) {
|
||||||
this(context, Glide.get(context).getBitmapPool(), center, color, start, end);
|
this(context, Glide.get(context).getBitmapPool(), center, color, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VignetteFilterTransformation(Context context, BitmapPool pool,
|
public VignetteFilterTransformation(Context context, BitmapPool pool, PointF center,
|
||||||
PointF center, float[] color, float start, float end) {
|
float[] color, float start, float end) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mBitmapPool = pool;
|
mBitmapPool = pool;
|
||||||
mCenter = center;
|
mCenter = center;
|
||||||
@ -88,8 +85,7 @@ public class VignetteFilterTransformation implements Transformation<Bitmap> {
|
|||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public String getId() {
|
||||||
public String getId() {
|
|
||||||
return "VignetteFilterTransformation(center=" + mCenter.toString() +
|
return "VignetteFilterTransformation(center=" + mCenter.toString() +
|
||||||
",color=" + Arrays.toString(mVignetteColor) +
|
",color=" + Arrays.toString(mVignetteColor) +
|
||||||
",start=" + mVignetteStart + ",end=" + mVignetteEnd + ")";
|
",start=" + mVignetteStart + ",end=" + mVignetteEnd + ")";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user