mirror of
https://github.com/wasabeef/glide-transformations.git
synced 2025-10-04 01:43:23 +08:00
Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
58e25e613c | ||
|
c914548296 | ||
|
cfe6dc313a | ||
|
136a5512c0 | ||
|
32d0c1de82 | ||
|
e23753044e | ||
|
decd2e58d5 | ||
|
e9d2c6d209 | ||
|
79e975d490 | ||
|
a21cfb1d86 | ||
|
c0ab4282d9 | ||
|
15effa238b | ||
|
ef39ca2782 | ||
|
bdda7cdf36 | ||
|
3890c84a0f | ||
|
e3c0c8d597 | ||
|
f7d0541a19 | ||
|
900db8bc93 | ||
|
c241532a58 | ||
|
8f63c10eb9 | ||
|
6468276c50 | ||
|
e0fb7c34e0 |
15
CHANGELOG.md
15
CHANGELOG.md
@@ -1,6 +1,21 @@
|
|||||||
Change Log
|
Change Log
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
Version 1.0.7 *(2015-07-18)*
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
Bug fix : Blur not working.
|
||||||
|
|
||||||
|
Version 1.0.6 *(2015-04-23)*
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
add: CropType(Top, Center, Bottom) for CropTransformation.
|
||||||
|
|
||||||
|
Version 1.0.5 *(2015-03-09)*
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
Bug fix: Transparency.
|
||||||
|
|
||||||
Version 1.0.4 *(2015-02-13)*
|
Version 1.0.4 *(2015-02-13)*
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
|
15
README.md
15
README.md
@@ -32,7 +32,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'jp.wasabeef:glide-transformations:1.0.4@aar'
|
compile 'jp.wasabeef:glide-transformations:1.0.8@aar'
|
||||||
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.2.3@aar'
|
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.2.3@aar'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -54,7 +54,7 @@ You can set a multiple transformations.
|
|||||||
```java
|
```java
|
||||||
BitmapPool pool = Glide.get(this).getBitmapPool();
|
BitmapPool pool = Glide.get(this).getBitmapPool();
|
||||||
Glide.with(this).load(R.drawable.demo).bitmapTransform(
|
Glide.with(this).load(R.drawable.demo).bitmapTransform(
|
||||||
new BlurTransformation(this, pool, 5), new CropCircleTransformation(pool))
|
new BlurTransformation(this, pool, 25, 2), new CropCircleTransformation(pool))
|
||||||
.into((ImageView) findViewById(R.id.image));
|
.into((ImageView) findViewById(R.id.image));
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ android {
|
|||||||
...
|
...
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
...
|
...
|
||||||
renderscriptTargetApi 21
|
renderscriptTargetApi 22
|
||||||
renderscriptSupportModeEnabled true
|
renderscriptSupportModeEnabled true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,6 +92,15 @@ android {
|
|||||||
### Other
|
### Other
|
||||||
`RoundedCornersTransformation`
|
`RoundedCornersTransformation`
|
||||||
|
|
||||||
|
Applications using Glide Transformations
|
||||||
|
---
|
||||||
|
|
||||||
|
Please [ping](mailto:dadadada.chop@gmail.com) me or send a pull request if you would like to be added here.
|
||||||
|
|
||||||
|
Icon | Application
|
||||||
|
------------ | -------------
|
||||||
|
<img src="https://lh6.ggpht.com/6zKH_uQY1bxCwXL4DLo_uoFEOXdShi3BgmN6XRHlaJ-oA1svmq6y1PZkmO50nWQn2Lg=w300-rw" width="48" height="48" /> | [Ameba Ownd](https://play.google.com/store/apps/details?id=jp.co.cyberagent.madrid)
|
||||||
|
|
||||||
Developed By
|
Developed By
|
||||||
-------
|
-------
|
||||||
Daichi Furiya (Wasabeef) - <dadadada.chop@gmail.com>
|
Daichi Furiya (Wasabeef) - <dadadada.chop@gmail.com>
|
||||||
|
@@ -5,8 +5,8 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:1.0.+'
|
classpath 'com.android.tools.build:gradle:1.3.0-beta4'
|
||||||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
|
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
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
@@ -53,9 +53,8 @@ def getKeyAliasPasswordProperty() {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':transformations')
|
compile project(':transformations')
|
||||||
// compile 'jp.wasabeef:glide-transformations:1.0.4'
|
compile "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
|
||||||
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.2.3'
|
compile "jp.co.cyberagent.android.gpuimage:gpuimage-library:${GPUIMAGE_VERSION}"
|
||||||
compile 'com.android.support:appcompat-v7:21.+'
|
compile "com.android.support:appcompat-v7:${SUPPORT_PACKAGE_VERSION}"
|
||||||
compile 'com.android.support:recyclerview-v7:21.+'
|
compile "com.android.support:recyclerview-v7:${SUPPORT_PACKAGE_VERSION}"
|
||||||
compile 'com.github.bumptech.glide:glide:3.5.1'
|
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package jp.wasabeef.example.glide;
|
package jp.wasabeef.example.glide;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
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;
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ import java.util.List;
|
|||||||
import jp.wasabeef.example.glide.MainAdapter.Type;
|
import jp.wasabeef.example.glide.MainAdapter.Type;
|
||||||
|
|
||||||
|
|
||||||
public class MainActivity extends ActionBarActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -22,7 +22,9 @@ public class MainActivity extends ActionBarActivity {
|
|||||||
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
|
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
|
||||||
|
|
||||||
List<Type> dataSet = new ArrayList<>();
|
List<Type> dataSet = new ArrayList<>();
|
||||||
dataSet.add(Type.Crop);
|
dataSet.add(Type.CropTop);
|
||||||
|
dataSet.add(Type.CropCenter);
|
||||||
|
dataSet.add(Type.CropBottom);
|
||||||
dataSet.add(Type.CropSquare);
|
dataSet.add(Type.CropSquare);
|
||||||
dataSet.add(Type.CropCircle);
|
dataSet.add(Type.CropCircle);
|
||||||
dataSet.add(Type.ColorFilter);
|
dataSet.add(Type.ColorFilter);
|
||||||
|
@@ -45,7 +45,9 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
|
|||||||
private BitmapPool mPool;
|
private BitmapPool mPool;
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
Crop,
|
CropTop,
|
||||||
|
CropCenter,
|
||||||
|
CropBottom,
|
||||||
CropSquare,
|
CropSquare,
|
||||||
CropCircle,
|
CropCircle,
|
||||||
ColorFilter,
|
ColorFilter,
|
||||||
@@ -79,11 +81,19 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(MainAdapter.ViewHolder holder, int position) {
|
public void onBindViewHolder(MainAdapter.ViewHolder holder, int position) {
|
||||||
Transformation<Bitmap> transformation = null;
|
Transformation transformation = null;
|
||||||
switch (mDataSet.get(position)) {
|
switch (mDataSet.get(position)) {
|
||||||
case Crop:
|
case CropTop:
|
||||||
|
transformation =
|
||||||
|
new CropTransformation(mPool, 300, 100, CropTransformation.CropType.TOP);
|
||||||
|
break;
|
||||||
|
case CropCenter:
|
||||||
transformation = new CropTransformation(mPool, 300, 100);
|
transformation = new CropTransformation(mPool, 300, 100);
|
||||||
break;
|
break;
|
||||||
|
case CropBottom:
|
||||||
|
transformation =
|
||||||
|
new CropTransformation(mPool, 300, 100, CropTransformation.CropType.BOTTOM);
|
||||||
|
break;
|
||||||
case CropSquare:
|
case CropSquare:
|
||||||
transformation = new CropSquareTransformation(mPool);
|
transformation = new CropSquareTransformation(mPool);
|
||||||
break;
|
break;
|
||||||
@@ -100,7 +110,7 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
|
|||||||
transformation = new RoundedCornersTransformation(mPool, 100, 0);
|
transformation = new RoundedCornersTransformation(mPool, 100, 0);
|
||||||
break;
|
break;
|
||||||
case Blur:
|
case Blur:
|
||||||
transformation = new BlurTransformation(mContext, mPool, 10);
|
transformation = new BlurTransformation(mContext, mPool, 25, 1);
|
||||||
break;
|
break;
|
||||||
case Toon:
|
case Toon:
|
||||||
transformation = new ToonFilterTransformation(mContext, mPool);
|
transformation = new ToonFilterTransformation(mContext, mPool);
|
||||||
|
@@ -6,11 +6,10 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/image"
|
android:id="@+id/image"
|
||||||
android:layout_width="wrap_content"
|
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"/>
|
||||||
android:src="@drawable/demo"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
VERSION_NAME=1.0.5
|
VERSION_NAME=1.0.8
|
||||||
VERSION_CODE=5
|
VERSION_CODE=8
|
||||||
GROUP=jp.wasabeef
|
GROUP=jp.wasabeef
|
||||||
ARTIFACT_ID=glide-transformations
|
ARTIFACT_ID=glide-transformations
|
||||||
|
|
||||||
COMPILE_SDK_VERSION=21
|
COMPILE_SDK_VERSION=22
|
||||||
BUILD_TOOLS_VERSION=21.1.2
|
BUILD_TOOLS_VERSION=22.0.1
|
||||||
TARGET_SDK_VERSION=21
|
TARGET_SDK_VERSION=22
|
||||||
RENDERSCRIPT_TARGET_API=21
|
RENDERSCRIPT_TARGET_API=22
|
||||||
MIN_SDK_VERSION=11
|
MIN_SDK_VERSION=11
|
||||||
|
|
||||||
POM_DESCRIPTION=which provides simple Tranformations to Glide
|
POM_DESCRIPTION=which provides simple Tranformations to Glide
|
||||||
@@ -22,3 +22,7 @@ POM_DEVELOPER_NAME=Wasabeef
|
|||||||
POM_DEVELOPER_EMAIL=dadadada.chop@gmail.com
|
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
|
||||||
|
GLIDE_VERSION=3.6.1
|
||||||
|
GPUIMAGE_VERSION=1.2.3
|
@@ -1,6 +1,7 @@
|
|||||||
task androidJavadocs(type: Javadoc) {
|
task androidJavadocs(type: Javadoc) {
|
||||||
source = android.sourceSets.main.java.srcDirs
|
source = android.sourceSets.main.java.srcDirs
|
||||||
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
|
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
|
||||||
|
classpath += files(ext.androidJar)
|
||||||
}
|
}
|
||||||
|
|
||||||
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
|
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
|
||||||
|
@@ -15,9 +15,8 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
compile "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
|
||||||
compile 'com.github.bumptech.glide:glide:3.5.1'
|
compile "jp.co.cyberagent.android.gpuimage:gpuimage-library:${GPUIMAGE_VERSION}"
|
||||||
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.2.3'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
android.libraryVariants.all { variant ->
|
android.libraryVariants.all { variant ->
|
||||||
|
@@ -1,3 +1 @@
|
|||||||
<manifest
|
<manifest package="jp.wasabeef.glide.transformations"></manifest>
|
||||||
package="jp.wasabeef.glide.transformations">
|
|
||||||
</manifest>
|
|
||||||
|
@@ -24,27 +24,36 @@ 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.support.v8.renderscript.Allocation;
|
import android.support.v8.renderscript.Allocation;
|
||||||
|
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;
|
||||||
|
|
||||||
public class BlurTransformation implements Transformation<Bitmap> {
|
public class BlurTransformation implements Transformation<Bitmap> {
|
||||||
|
|
||||||
private static int MAX_RADIUS = 25;
|
private static int MAX_RADIUS = 25;
|
||||||
|
private static int DEFAULT_DOWN_SAMPLING = 1;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private BitmapPool mBitmapPool;
|
private BitmapPool mBitmapPool;
|
||||||
|
|
||||||
private int mRadius;
|
private int mRadius;
|
||||||
|
private int mSampling;
|
||||||
|
|
||||||
public BlurTransformation(Context context, BitmapPool pool) {
|
public BlurTransformation(Context context, BitmapPool pool) {
|
||||||
this(context, pool, MAX_RADIUS);
|
this(context, pool, MAX_RADIUS, DEFAULT_DOWN_SAMPLING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlurTransformation(Context context, BitmapPool pool, int radius) {
|
public BlurTransformation(Context context, BitmapPool pool, int radius) {
|
||||||
|
this(context, pool, radius, DEFAULT_DOWN_SAMPLING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlurTransformation(Context context, BitmapPool pool, int radius, int sampling) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mBitmapPool = pool;
|
mBitmapPool = pool;
|
||||||
mRadius = radius;
|
mRadius = radius;
|
||||||
|
mSampling = sampling;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -53,24 +62,30 @@ public class BlurTransformation implements Transformation<Bitmap> {
|
|||||||
|
|
||||||
int width = source.getWidth();
|
int width = source.getWidth();
|
||||||
int height = source.getHeight();
|
int height = source.getHeight();
|
||||||
|
int scaledWidth = width / mSampling;
|
||||||
|
int scaledHeight = height / mSampling;
|
||||||
|
|
||||||
Bitmap.Config config =
|
Bitmap bitmap = mBitmapPool.get(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
|
||||||
source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
|
|
||||||
Bitmap bitmap = mBitmapPool.get(width, height, config);
|
|
||||||
if (bitmap == null) {
|
if (bitmap == null) {
|
||||||
bitmap = Bitmap.createBitmap(width, height, config);
|
bitmap = Bitmap.createBitmap(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
|
||||||
}
|
}
|
||||||
|
|
||||||
Canvas canvas = new Canvas(bitmap);
|
Canvas canvas = new Canvas(bitmap);
|
||||||
canvas.drawBitmap(source, 0, 0, null);
|
canvas.scale(1 / (float) mSampling, 1 / (float) mSampling);
|
||||||
|
Paint paint = new Paint();
|
||||||
|
paint.setFlags(Paint.FILTER_BITMAP_FLAG);
|
||||||
|
canvas.drawBitmap(source, 0, 0, paint);
|
||||||
|
|
||||||
RenderScript rs = RenderScript.create(mContext);
|
RenderScript rs = RenderScript.create(mContext);
|
||||||
Allocation overlayAlloc = Allocation.createFromBitmap(rs, bitmap);
|
Allocation input = Allocation.createFromBitmap(rs, bitmap,
|
||||||
ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(rs, overlayAlloc.getElement());
|
Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
|
||||||
blur.setInput(overlayAlloc);
|
Allocation output = Allocation.createTyped(rs, input.getType());
|
||||||
|
ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
|
||||||
|
|
||||||
|
blur.setInput(input);
|
||||||
blur.setRadius(mRadius);
|
blur.setRadius(mRadius);
|
||||||
blur.forEach(overlayAlloc);
|
blur.forEach(output);
|
||||||
overlayAlloc.copyTo(bitmap);
|
output.copyTo(bitmap);
|
||||||
|
|
||||||
rs.destroy();
|
rs.destroy();
|
||||||
|
|
||||||
@@ -79,6 +94,6 @@ public class BlurTransformation implements Transformation<Bitmap> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return "BlurTransformation(radius=" + mRadius + ")";
|
return "BlurTransformation(radius=" + mRadius + ", sampling=" + mSampling + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,8 @@ public class CropTransformation implements Transformation<Bitmap> {
|
|||||||
private int mWidth;
|
private int mWidth;
|
||||||
private int mHeight;
|
private int mHeight;
|
||||||
|
|
||||||
|
private CropType mCropType = CropType.CENTER;
|
||||||
|
|
||||||
public CropTransformation(BitmapPool pool) {
|
public CropTransformation(BitmapPool pool) {
|
||||||
mBitmapPool = pool;
|
mBitmapPool = pool;
|
||||||
}
|
}
|
||||||
@@ -41,15 +43,18 @@ public class CropTransformation implements Transformation<Bitmap> {
|
|||||||
mHeight = height;
|
mHeight = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CropTransformation(BitmapPool pool, int width, int height, CropType cropType) {
|
||||||
|
mBitmapPool = pool;
|
||||||
|
mWidth = width;
|
||||||
|
mHeight = height;
|
||||||
|
mCropType = cropType;
|
||||||
|
}
|
||||||
|
|
||||||
@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();
|
||||||
if (mWidth == 0) {
|
mWidth = mWidth == 0 ? source.getWidth() : mWidth;
|
||||||
mWidth = source.getWidth();
|
mHeight = mHeight == 0 ? source.getHeight() : mHeight;
|
||||||
}
|
|
||||||
if (mHeight == 0) {
|
|
||||||
mHeight = source.getHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
Bitmap.Config config =
|
Bitmap.Config config =
|
||||||
source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
|
source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
|
||||||
@@ -65,7 +70,7 @@ public class CropTransformation implements Transformation<Bitmap> {
|
|||||||
float scaledWidth = scale * source.getWidth();
|
float scaledWidth = scale * source.getWidth();
|
||||||
float scaledHeight = scale * source.getHeight();
|
float scaledHeight = scale * source.getHeight();
|
||||||
float left = (mWidth - scaledWidth) / 2;
|
float left = (mWidth - scaledWidth) / 2;
|
||||||
float top = (mHeight - scaledHeight) / 2;
|
float top = getTop(scaledHeight);
|
||||||
RectF targetRect = new RectF(left, top, left + scaledWidth, top + scaledHeight);
|
RectF targetRect = new RectF(left, top, left + scaledWidth, top + scaledHeight);
|
||||||
|
|
||||||
Canvas canvas = new Canvas(bitmap);
|
Canvas canvas = new Canvas(bitmap);
|
||||||
@@ -76,6 +81,26 @@ public class CropTransformation implements Transformation<Bitmap> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return "CropTransformation(width=" + mWidth + ", height=" + mHeight + ")";
|
return "CropTransformation(width=" + mWidth + ", height=" + mHeight + ", cropType="
|
||||||
|
+ mCropType + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
private float getTop(float scaledHeight) {
|
||||||
|
switch (mCropType) {
|
||||||
|
case TOP:
|
||||||
|
return 0;
|
||||||
|
case CENTER:
|
||||||
|
return (mHeight - scaledHeight) / 2;
|
||||||
|
case BOTTOM:
|
||||||
|
return mHeight - scaledHeight;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CropType {
|
||||||
|
TOP,
|
||||||
|
CENTER,
|
||||||
|
BOTTOM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user