1
0
mirror of https://github.com/wasabeef/glide-transformations.git synced 2025-10-05 02:13:22 +08:00

15 Commits
1.0.1 ... 1.0.4

Author SHA1 Message Date
wasabeef
3aea08abaa bump up 2015-02-13 15:52:42 +09:00
Daichi Furiya
883c131ad6 Merge pull request #3 from yqritc/fix/bitmap-recycling
remove original bitmap resource recycling
2015-02-13 15:26:28 +09:00
ikeda_yoshihito
ee1f533999 remove original bitmap resource recycling 2015-02-13 12:31:30 +09:00
wasabeef
68a9097962 refactor: Bitmap.Config 2015-02-05 20:51:12 +09:00
wasabeef
6269999abc bump up 2015-02-04 01:00:50 +09:00
wasabeef
7e93ccd9af Merge branch 'master' of github.com:wasabeef/glide-transformations 2015-02-04 00:55:18 +09:00
wasabeef
07b7d24e13 bug fix 2015-02-04 00:54:22 +09:00
Daichi Furiya
ca648cbc7d bump up 2015-02-04 00:40:08 +09:00
Daichi Furiya
67ac3e31a4 Update CHANGELOG.md 2015-02-04 00:39:19 +09:00
wasabeef
1534573e8f bump up 2015-02-03 22:59:48 +09:00
wasabeef
a5487ade83 Refactor: use BitmapPool 2015-02-03 22:59:32 +09:00
wasabeef
62abca0b1e Merge branch 'master' of github.com:wasabeef/glide-transformations 2015-02-03 22:28:46 +09:00
wasabeef
a6bbdb0694 update glide 2015-02-03 22:27:19 +09:00
Daichi Furiya
2f75284dd4 Update README.md 2015-01-27 11:17:32 +09:00
Daichi Furiya
5772f60c61 Update CHANGELOG.md 2015-01-21 00:53:11 +09:00
12 changed files with 79 additions and 34 deletions

View File

@@ -1,6 +1,22 @@
Change Log
==========
Version 1.0.3 *(2015-02-05)*
----------------------------
Bug fix
Version 1.0.2 *(2015-02-04)*
----------------------------
Refactor: use BimapPool
Version 1.0.1 *(2015-01-21)*
----------------------------
fix: Blur Transformation now woking at Android 4.3
add: GPUImage to Gradle dependency
Version 1.0.0 *(2015-01-12)*
----------------------------

View File

@@ -32,8 +32,8 @@ repositories {
}
dependencies {
compile 'jp.wasabeef:glide-transformations:1.0.1'
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.2.3'
compile 'jp.wasabeef:glide-transformations:1.0.3@aar'
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.2.3@aar'
}
```

View File

@@ -53,9 +53,9 @@ def getKeyAliasPasswordProperty() {
dependencies {
compile project(':transformations')
// compile 'jp.wasabeef:glide-transformations:1.0.1'
// compile 'jp.wasabeef:glide-transformations:1.0.4'
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.2.3'
compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.android.support:recyclerview-v7:21.+'
compile 'com.github.bumptech.glide:glide:3.+'
compile 'com.github.bumptech.glide:glide:3.5.1'
}

View File

@@ -1,5 +1,5 @@
VERSION_NAME=1.0.1
VERSION_CODE=3
VERSION_NAME=1.0.4
VERSION_CODE=4
GROUP=jp.wasabeef
ARTIFACT_ID=glide-transformations

View File

@@ -16,7 +16,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.github.bumptech.glide:glide:3.4.0'
compile 'com.github.bumptech.glide:glide:3.5.1'
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.2.3'
}

View File

@@ -50,23 +50,31 @@ public class BlurTransformation implements Transformation<Bitmap> {
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
Bitmap source = resource.get();
Bitmap outBitmap = Bitmap.createBitmap(source.getWidth(), source.getHeight(),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(outBitmap);
int width = source.getWidth();
int height = source.getHeight();
Bitmap.Config config =
source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
Bitmap bitmap = mBitmapPool.get(width, height, config);
if (bitmap == null) {
bitmap = Bitmap.createBitmap(width, height, config);
}
Canvas canvas = new Canvas(bitmap);
canvas.drawBitmap(source, 0, 0, null);
RenderScript rs = RenderScript.create(mContext);
Allocation overlayAlloc = Allocation.createFromBitmap(rs, outBitmap);
Allocation overlayAlloc = Allocation.createFromBitmap(rs, bitmap);
ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(rs, overlayAlloc.getElement());
blur.setInput(overlayAlloc);
blur.setRadius(mRadius);
blur.forEach(overlayAlloc);
overlayAlloc.copyTo(outBitmap);
overlayAlloc.copyTo(bitmap);
source.recycle();
rs.destroy();
return BitmapResource.obtain(outBitmap, mBitmapPool);
return BitmapResource.obtain(bitmap, mBitmapPool);
}
@Override

View File

@@ -45,14 +45,18 @@ public class ColorFilterTransformation implements Transformation<Bitmap> {
int width = source.getWidth();
int height = source.getHeight();
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Bitmap.Config config =
source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
Bitmap bitmap = mBitmapPool.get(width, height, config);
if (bitmap == null) {
bitmap = Bitmap.createBitmap(width, height, config);
}
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColorFilter(new PorterDuffColorFilter(mColor, PorterDuff.Mode.SRC_ATOP));
canvas.drawBitmap(source, 0, 0, paint);
source.recycle();
return BitmapResource.obtain(bitmap, mBitmapPool);
}

View File

@@ -24,6 +24,7 @@ import com.bumptech.glide.load.resource.bitmap.BitmapResource;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
public class CropCircleTransformation implements Transformation<Bitmap> {
@@ -42,25 +43,26 @@ public class CropCircleTransformation implements Transformation<Bitmap> {
int width = (source.getWidth() - size) / 2;
int height = (source.getHeight() - size) / 2;
Bitmap squaredBitmap = Bitmap.createBitmap(source, width, height, size, size);
if (squaredBitmap != source) {
source.recycle();
Bitmap.Config config =
source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
Bitmap bitmap = mBitmapPool.get(size, size, config);
if (bitmap == null) {
bitmap = Bitmap.createBitmap(size, size, config);
}
Bitmap bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP,
BitmapShader shader = new BitmapShader(source, BitmapShader.TileMode.CLAMP,
BitmapShader.TileMode.CLAMP);
Matrix matrix = new Matrix();
matrix.setTranslate(-width, -height);
shader.setLocalMatrix(matrix);
paint.setShader(shader);
paint.setAntiAlias(true);
float r = size / 2f;
canvas.drawCircle(r, r, r, paint);
squaredBitmap.recycle();
return BitmapResource.obtain(bitmap, mBitmapPool);
}

View File

@@ -41,9 +41,11 @@ public class CropSquareTransformation implements Transformation<Bitmap> {
mWidth = (source.getWidth() - size) / 2;
mHeight = (source.getHeight() - size) / 2;
Bitmap bitmap = Bitmap.createBitmap(source, mWidth, mHeight, size, size);
if (bitmap != source) {
source.recycle();
Bitmap.Config config =
source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
Bitmap bitmap = mBitmapPool.get(mWidth, mHeight, config);
if (bitmap == null) {
bitmap = Bitmap.createBitmap(source, mWidth, mHeight, size, size);
}
return BitmapResource.obtain(bitmap, mBitmapPool);

View File

@@ -51,6 +51,13 @@ public class CropTransformation implements Transformation<Bitmap> {
mHeight = source.getHeight();
}
Bitmap.Config config =
source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
Bitmap bitmap = mBitmapPool.get(mWidth, mHeight, config);
if (bitmap == null) {
bitmap = Bitmap.createBitmap(mWidth, mHeight, config);
}
float scaleX = (float) mWidth / source.getWidth();
float scaleY = (float) mHeight / source.getHeight();
float scale = Math.max(scaleX, scaleY);
@@ -61,10 +68,8 @@ public class CropTransformation implements Transformation<Bitmap> {
float top = (mHeight - scaledHeight) / 2;
RectF targetRect = new RectF(left, top, left + scaledWidth, top + scaledHeight);
Bitmap bitmap = Bitmap.createBitmap(mWidth, mHeight, source.getConfig());
Canvas canvas = new Canvas(bitmap);
canvas.drawBitmap(source, null, targetRect, null);
source.recycle();
return BitmapResource.obtain(bitmap, mBitmapPool);
}

View File

@@ -42,7 +42,12 @@ public class GrayscaleTransformation implements Transformation<Bitmap> {
int width = source.getWidth();
int height = source.getHeight();
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Bitmap.Config config =
source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
Bitmap bitmap = mBitmapPool.get(width, height, config);
if (bitmap == null) {
bitmap = Bitmap.createBitmap(width, height, config);
}
Canvas canvas = new Canvas(bitmap);
ColorMatrix saturation = new ColorMatrix();
@@ -50,7 +55,6 @@ public class GrayscaleTransformation implements Transformation<Bitmap> {
Paint paint = new Paint();
paint.setColorFilter(new ColorMatrixColorFilter(saturation));
canvas.drawBitmap(source, 0, 0, paint);
source.recycle();
return BitmapResource.obtain(bitmap, mBitmapPool);
}

View File

@@ -48,7 +48,12 @@ public class RoundedCornersTransformation implements Transformation<Bitmap> {
int width = source.getWidth();
int height = source.getHeight();
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Bitmap.Config config =
source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
Bitmap bitmap = mBitmapPool.get(width, height, config);
if (bitmap == null) {
bitmap = Bitmap.createBitmap(width, height, config);
}
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
@@ -56,7 +61,6 @@ public class RoundedCornersTransformation implements Transformation<Bitmap> {
paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
canvas.drawRoundRect(new RectF(margin, margin, width - margin, height - margin),
radius, radius, paint);
source.recycle();
return BitmapResource.obtain(bitmap, mBitmapPool);
}