mirror of
https://github.com/wasabeef/glide-transformations.git
synced 2025-10-05 18:53:20 +08:00
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
4c23e38206 | ||
|
ffae37274c | ||
|
0c6f696ba7 | ||
|
3aea08abaa | ||
|
883c131ad6 | ||
|
ee1f533999 | ||
|
68a9097962 | ||
|
6269999abc | ||
|
7e93ccd9af | ||
|
07b7d24e13 | ||
|
ca648cbc7d | ||
|
67ac3e31a4 |
15
CHANGELOG.md
15
CHANGELOG.md
@@ -1,6 +1,21 @@
|
|||||||
Change Log
|
Change Log
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
Version 1.0.4 *(2015-02-13)*
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
Bug fix : remove original bitmap resource recycling.
|
||||||
|
|
||||||
|
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)*
|
Version 1.0.1 *(2015-01-21)*
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
|
@@ -32,7 +32,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'jp.wasabeef:glide-transformations:1.0.1@aar'
|
compile 'jp.wasabeef:glide-transformations:1.0.4@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'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@@ -53,7 +53,7 @@ def getKeyAliasPasswordProperty() {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':transformations')
|
compile project(':transformations')
|
||||||
// compile 'jp.wasabeef:glide-transformations:1.0.2'
|
// compile 'jp.wasabeef:glide-transformations:1.0.4'
|
||||||
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.2.3'
|
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.2.3'
|
||||||
compile 'com.android.support:appcompat-v7:21.+'
|
compile 'com.android.support:appcompat-v7:21.+'
|
||||||
compile 'com.android.support:recyclerview-v7:21.+'
|
compile 'com.android.support:recyclerview-v7:21.+'
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
VERSION_NAME=1.0.2
|
VERSION_NAME=1.0.5
|
||||||
VERSION_CODE=3
|
VERSION_CODE=5
|
||||||
GROUP=jp.wasabeef
|
GROUP=jp.wasabeef
|
||||||
ARTIFACT_ID=glide-transformations
|
ARTIFACT_ID=glide-transformations
|
||||||
|
|
||||||
|
@@ -54,9 +54,11 @@ public class BlurTransformation implements Transformation<Bitmap> {
|
|||||||
int width = source.getWidth();
|
int width = source.getWidth();
|
||||||
int height = source.getHeight();
|
int height = source.getHeight();
|
||||||
|
|
||||||
Bitmap bitmap = mBitmapPool.get(width, height, source.getConfig());
|
Bitmap.Config config =
|
||||||
|
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, source.getConfig());
|
bitmap = Bitmap.createBitmap(width, height, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
Canvas canvas = new Canvas(bitmap);
|
Canvas canvas = new Canvas(bitmap);
|
||||||
@@ -70,7 +72,6 @@ public class BlurTransformation implements Transformation<Bitmap> {
|
|||||||
blur.forEach(overlayAlloc);
|
blur.forEach(overlayAlloc);
|
||||||
overlayAlloc.copyTo(bitmap);
|
overlayAlloc.copyTo(bitmap);
|
||||||
|
|
||||||
source.recycle();
|
|
||||||
rs.destroy();
|
rs.destroy();
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
|
@@ -45,9 +45,11 @@ public class ColorFilterTransformation implements Transformation<Bitmap> {
|
|||||||
int width = source.getWidth();
|
int width = source.getWidth();
|
||||||
int height = source.getHeight();
|
int height = source.getHeight();
|
||||||
|
|
||||||
Bitmap bitmap = mBitmapPool.get(width, height, source.getConfig());
|
Bitmap.Config config =
|
||||||
|
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, source.getConfig());
|
bitmap = Bitmap.createBitmap(width, height, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
Canvas canvas = new Canvas(bitmap);
|
Canvas canvas = new Canvas(bitmap);
|
||||||
@@ -56,8 +58,6 @@ public class ColorFilterTransformation implements Transformation<Bitmap> {
|
|||||||
paint.setColorFilter(new PorterDuffColorFilter(mColor, PorterDuff.Mode.SRC_ATOP));
|
paint.setColorFilter(new PorterDuffColorFilter(mColor, PorterDuff.Mode.SRC_ATOP));
|
||||||
canvas.drawBitmap(source, 0, 0, paint);
|
canvas.drawBitmap(source, 0, 0, paint);
|
||||||
|
|
||||||
source.recycle();
|
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -43,26 +43,26 @@ public class CropCircleTransformation implements Transformation<Bitmap> {
|
|||||||
int width = (source.getWidth() - size) / 2;
|
int width = (source.getWidth() - size) / 2;
|
||||||
int height = (source.getHeight() - size) / 2;
|
int height = (source.getHeight() - size) / 2;
|
||||||
|
|
||||||
Bitmap bitmap = mBitmapPool.get(width, height, source.getConfig());
|
Bitmap bitmap = mBitmapPool.get(size, size, Bitmap.Config.ARGB_8888);
|
||||||
if (bitmap == null) {
|
if (bitmap == null) {
|
||||||
bitmap = Bitmap.createBitmap(width, height, source.getConfig());
|
bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = new BitmapShader(source, BitmapShader.TileMode.CLAMP,
|
||||||
BitmapShader.TileMode.CLAMP);
|
BitmapShader.TileMode.CLAMP);
|
||||||
Matrix matrix = new Matrix();
|
if (width != 0 || height != 0) {
|
||||||
matrix.setTranslate(-width, -height);
|
Matrix matrix = new Matrix();
|
||||||
shader.setLocalMatrix(matrix);
|
matrix.setTranslate(-width, -height);
|
||||||
|
shader.setLocalMatrix(matrix);
|
||||||
|
}
|
||||||
paint.setShader(shader);
|
paint.setShader(shader);
|
||||||
paint.setAntiAlias(true);
|
paint.setAntiAlias(true);
|
||||||
|
|
||||||
float r = size / 2f;
|
float r = size / 2f;
|
||||||
canvas.drawCircle(r, r, r, paint);
|
canvas.drawCircle(r, r, r, paint);
|
||||||
|
|
||||||
source.recycle();
|
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,15 +41,13 @@ public class CropSquareTransformation implements Transformation<Bitmap> {
|
|||||||
mWidth = (source.getWidth() - size) / 2;
|
mWidth = (source.getWidth() - size) / 2;
|
||||||
mHeight = (source.getHeight() - size) / 2;
|
mHeight = (source.getHeight() - size) / 2;
|
||||||
|
|
||||||
Bitmap bitmap = mBitmapPool.get(mWidth, mHeight, source.getConfig());
|
Bitmap.Config config =
|
||||||
|
source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
|
||||||
|
Bitmap bitmap = mBitmapPool.get(mWidth, mHeight, config);
|
||||||
if (bitmap == null) {
|
if (bitmap == null) {
|
||||||
bitmap = Bitmap.createBitmap(source, mWidth, mHeight, size, size);
|
bitmap = Bitmap.createBitmap(source, mWidth, mHeight, size, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bitmap != source) {
|
|
||||||
source.recycle();
|
|
||||||
}
|
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -51,9 +51,11 @@ public class CropTransformation implements Transformation<Bitmap> {
|
|||||||
mHeight = source.getHeight();
|
mHeight = source.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap bitmap = mBitmapPool.get(mWidth, mHeight, source.getConfig());
|
Bitmap.Config config =
|
||||||
|
source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
|
||||||
|
Bitmap bitmap = mBitmapPool.get(mWidth, mHeight, config);
|
||||||
if (bitmap == null) {
|
if (bitmap == null) {
|
||||||
bitmap = Bitmap.createBitmap(mWidth, mHeight, source.getConfig());
|
bitmap = Bitmap.createBitmap(mWidth, mHeight, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
float scaleX = (float) mWidth / source.getWidth();
|
float scaleX = (float) mWidth / source.getWidth();
|
||||||
@@ -69,8 +71,6 @@ public class CropTransformation implements Transformation<Bitmap> {
|
|||||||
Canvas canvas = new Canvas(bitmap);
|
Canvas canvas = new Canvas(bitmap);
|
||||||
canvas.drawBitmap(source, null, targetRect, null);
|
canvas.drawBitmap(source, null, targetRect, null);
|
||||||
|
|
||||||
source.recycle();
|
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,9 +42,11 @@ public class GrayscaleTransformation implements Transformation<Bitmap> {
|
|||||||
int width = source.getWidth();
|
int width = source.getWidth();
|
||||||
int height = source.getHeight();
|
int height = source.getHeight();
|
||||||
|
|
||||||
Bitmap bitmap = mBitmapPool.get(width, height, source.getConfig());
|
Bitmap.Config config =
|
||||||
|
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, source.getConfig());
|
bitmap = Bitmap.createBitmap(width, height, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
Canvas canvas = new Canvas(bitmap);
|
Canvas canvas = new Canvas(bitmap);
|
||||||
@@ -54,8 +56,6 @@ public class GrayscaleTransformation implements Transformation<Bitmap> {
|
|||||||
paint.setColorFilter(new ColorMatrixColorFilter(saturation));
|
paint.setColorFilter(new ColorMatrixColorFilter(saturation));
|
||||||
canvas.drawBitmap(source, 0, 0, paint);
|
canvas.drawBitmap(source, 0, 0, paint);
|
||||||
|
|
||||||
source.recycle();
|
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -48,9 +48,9 @@ public class RoundedCornersTransformation implements Transformation<Bitmap> {
|
|||||||
int width = source.getWidth();
|
int width = source.getWidth();
|
||||||
int height = source.getHeight();
|
int height = source.getHeight();
|
||||||
|
|
||||||
Bitmap bitmap = mBitmapPool.get(width, height, source.getConfig());
|
Bitmap bitmap = mBitmapPool.get(width, height, Bitmap.Config.ARGB_8888);
|
||||||
if (bitmap == null) {
|
if (bitmap == null) {
|
||||||
bitmap = Bitmap.createBitmap(width, height, source.getConfig());
|
bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
||||||
}
|
}
|
||||||
|
|
||||||
Canvas canvas = new Canvas(bitmap);
|
Canvas canvas = new Canvas(bitmap);
|
||||||
@@ -60,8 +60,6 @@ public class RoundedCornersTransformation implements Transformation<Bitmap> {
|
|||||||
canvas.drawRoundRect(new RectF(margin, margin, width - margin, height - margin),
|
canvas.drawRoundRect(new RectF(margin, margin, width - margin, height - margin),
|
||||||
radius, radius, paint);
|
radius, radius, paint);
|
||||||
|
|
||||||
source.recycle();
|
|
||||||
|
|
||||||
return BitmapResource.obtain(bitmap, mBitmapPool);
|
return BitmapResource.obtain(bitmap, mBitmapPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user