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

15 Commits
1.4.0 ... 2.0.1

Author SHA1 Message Date
Daichi Furiya
c3f09cdd0d Merge pull request #38 from wasabeef/v2.0.1
V2.0.1
2016-04-21 15:29:01 +09:00
wasabeef
ddd76d4f06 fix layout 2016-04-21 15:27:26 +09:00
wasabeef
f9bca8887d fix bugs issue #35 2016-04-21 15:23:22 +09:00
wasabeef
592815a6a0 update gradle 2016-04-21 15:22:58 +09:00
wasabeef
f6540b111f bump up 2.0.1 2016-04-21 15:22:46 +09:00
wasabeef
9bea464afc format 2016-04-21 15:22:21 +09:00
wasabeef
219b32bbcc format 2016-04-21 15:18:48 +09:00
Daichi Furiya
4d7190847c Merge pull request #36 from elevenfive/patch-1
Use correct field prefix
2016-04-19 13:05:36 +09:00
Matthew Zavislak
0d7a93c264 Use correct field prefix 2016-04-15 20:19:29 -07:00
Daichi Furiya
e69f775ddd Update build.gradle 2016-03-02 23:12:39 +09:00
Daichi Furiya
4b9cf87770 Update gradle-wrapper.properties 2016-03-02 23:11:59 +09:00
Daichi Furiya
cafad91b0b Update gradle-wrapper.properties 2016-03-02 23:11:43 +09:00
Daichi Furiya
933c3f7989 Merge pull request #31 from wasabeef/goodbye-v8rs
Goodbye v8.RenderScript
2016-03-02 23:11:05 +09:00
wasabeef
68bafb0f53 bump up 2.0.0 2016-03-02 23:09:31 +09:00
wasabeef
817b138980 Say v8.RenderScript goodbye 2016-03-02 22:53:34 +09:00
15 changed files with 152 additions and 131 deletions

View File

@@ -1,6 +1,18 @@
Change Log Change Log
========== ==========
Version 2.0.1 *(2016-04-21)*
----------------------------
Fix:
[#35](https://github.com/wasabeef/glide-transformations/issues/35)
RSInvalidStateException
Version 2.0.0 *(2016-03-02)*
----------------------------
Say v8.RenderScript goodbye
Version 1.4.0 *(2016-02-28)* Version 1.4.0 *(2016-02-28)*
---------------------------- ----------------------------

View File

@@ -33,7 +33,7 @@ repositories {
} }
dependencies { dependencies {
compile 'jp.wasabeef:glide-transformations:1.4.0' compile 'jp.wasabeef:glide-transformations:2.0.1'
// If you want to use the GPU Filters // If you want to use the GPU Filters
compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.3.0' compile 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.3.0'
} }
@@ -55,25 +55,10 @@ You can set a multiple transformations.
```java ```java
Glide.with(this).load(R.drawable.demo) Glide.with(this).load(R.drawable.demo)
.bitmapTransform(new BlurTransformation(context, 25, 2), new CropCircleTransformation(context)) .bitmapTransform(new BlurTransformation(context, 25), new CropCircleTransformation(context))
.into((ImageView) findViewById(R.id.image)); .into((ImageView) findViewById(R.id.image));
``` ```
## Step 4
If you are using `BlurTransformation`.
```groovy
android {
...
defaultConfig {
// Warning:Renderscript support mode is not currently supported with renderscript target 21+
renderscriptTargetApi 20
renderscriptSupportModeEnabled true
}
}
```
## Transformations ## Transformations
### Crop ### Crop

View File

@@ -5,11 +5,8 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta6' classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.novoda:bintray-release:0.3.4' classpath 'com.novoda:bintray-release:0.3.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
} }
} }

View File

@@ -1,62 +1,58 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
compileSdkVersion COMPILE_SDK_VERSION as int compileSdkVersion COMPILE_SDK_VERSION as int
buildToolsVersion BUILD_TOOLS_VERSION buildToolsVersion BUILD_TOOLS_VERSION
defaultConfig { defaultConfig {
minSdkVersion MIN_SDK_VERSION as int minSdkVersion MIN_SDK_VERSION as int
targetSdkVersion TARGET_SDK_VERSION as int targetSdkVersion TARGET_SDK_VERSION as int
versionCode "git rev-list origin/master --count".execute().text.toInteger() versionCode "git rev-list origin/master --count".execute().text.toInteger()
versionName VERSION_NAME versionName VERSION_NAME
}
// Warning:Renderscript support mode is not currently supported with renderscript target 21+ signingConfigs {
renderscriptTargetApi RENDERSCRIPT_TARGET_API as int release {
renderscriptSupportModeEnabled true storeFile file(keyStoreProperty)
keyAlias keyAliasProperty
storePassword keyStorePasswordProperty
keyPassword keyAliasPasswordProperty
} }
}
signingConfigs { buildTypes {
release { debug {
storeFile file(keyStoreProperty) debuggable true
keyAlias keyAliasProperty zipAlignEnabled true
storePassword keyStorePasswordProperty
keyPassword keyAliasPasswordProperty
}
} }
release {
buildTypes { debuggable false
debug { zipAlignEnabled true
debuggable true signingConfig signingConfigs.release
zipAlignEnabled true
}
release {
debuggable false
zipAlignEnabled true
signingConfig signingConfigs.release
}
} }
}
} }
def getKeyStoreProperty() { def getKeyStoreProperty() {
return hasProperty('WASABEEF_KEYSTORE') ? WASABEEF_KEYSTORE : "debug.keystore" return hasProperty('WASABEEF_KEYSTORE') ? WASABEEF_KEYSTORE : "debug.keystore"
} }
def getKeyAliasProperty() { def getKeyAliasProperty() {
return hasProperty('WASABEEF_KEYALIAS') ? WASABEEF_KEYALIAS : "android" return hasProperty('WASABEEF_KEYALIAS') ? WASABEEF_KEYALIAS : "android"
} }
def getKeyStorePasswordProperty() { def getKeyStorePasswordProperty() {
return hasProperty('WASABEEF_KEYSTOREPASSWORD') ? WASABEEF_KEYSTOREPASSWORD : "androiddebugkey" return hasProperty('WASABEEF_KEYSTOREPASSWORD') ? WASABEEF_KEYSTOREPASSWORD : "androiddebugkey"
} }
def getKeyAliasPasswordProperty() { def getKeyAliasPasswordProperty() {
return hasProperty('WASABEEF_KEYALIASPASSWORD') ? WASABEEF_KEYALIASPASSWORD : "android" return hasProperty('WASABEEF_KEYALIASPASSWORD') ? WASABEEF_KEYALIASPASSWORD : "android"
} }
dependencies { dependencies {
compile project(':transformations') compile project(':transformations')
compile "com.github.bumptech.glide:glide:${GLIDE_VERSION}" compile "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
compile "jp.co.cyberagent.android.gpuimage:gpuimage-library:${GPUIMAGE_VERSION}" compile "jp.co.cyberagent.android.gpuimage:gpuimage-library:${GPUIMAGE_VERSION}"
compile "com.android.support:appcompat-v7:${SUPPORT_PACKAGE_VERSION}" compile "com.android.support:appcompat-v7:${SUPPORT_PACKAGE_VERSION}"
compile "com.android.support:recyclerview-v7:${SUPPORT_PACKAGE_VERSION}" compile "com.android.support:recyclerview-v7:${SUPPORT_PACKAGE_VERSION}"
} }

View File

@@ -152,7 +152,7 @@ public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
case Blur: case Blur:
Glide.with(mContext) Glide.with(mContext)
.load(R.drawable.check) .load(R.drawable.check)
.bitmapTransform(new BlurTransformation(mContext, 25, 1)) .bitmapTransform(new BlurTransformation(mContext, 25))
.into(holder.image); .into(holder.image);
break; break;
case Toon: case Toon:

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<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="wrap_content"
android:padding="5dp" android:padding="5dp"
> >

View File

@@ -1,12 +1,10 @@
VERSION_NAME=1.4.0 VERSION_NAME=2.0.1
GROUP=jp.wasabeef GROUP=jp.wasabeef
ARTIFACT_ID=glide-transformations ARTIFACT_ID=glide-transformations
COMPILE_SDK_VERSION=23 COMPILE_SDK_VERSION=23
BUILD_TOOLS_VERSION=23.0.2 BUILD_TOOLS_VERSION=23.0.2
TARGET_SDK_VERSION=23 TARGET_SDK_VERSION=23
# Warning:Renderscript support mode is not currently supported with renderscript target 21+
RENDERSCRIPT_TARGET_API=20
MIN_SDK_VERSION=11 MIN_SDK_VERSION=11
POM_DESCRIPTION=which provides simple Tranformations to Glide POM_DESCRIPTION=which provides simple Tranformations to Glide
@@ -23,6 +21,6 @@ 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=23.1.1 SUPPORT_PACKAGE_VERSION=23.2.1
GLIDE_VERSION=3.6.1 GLIDE_VERSION=3.7.0
GPUIMAGE_VERSION=1.3.0 GPUIMAGE_VERSION=1.3.0

View File

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

View File

@@ -2,53 +2,49 @@ apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release' apply plugin: 'com.novoda.bintray-release'
android { android {
compileSdkVersion COMPILE_SDK_VERSION as int compileSdkVersion COMPILE_SDK_VERSION as int
buildToolsVersion BUILD_TOOLS_VERSION buildToolsVersion BUILD_TOOLS_VERSION
defaultConfig { defaultConfig {
minSdkVersion MIN_SDK_VERSION as int minSdkVersion MIN_SDK_VERSION as int
targetSdkVersion TARGET_SDK_VERSION as int targetSdkVersion TARGET_SDK_VERSION as int
versionCode "git rev-list origin/master --count".execute().text.toInteger() versionCode "git rev-list origin/master --count".execute().text.toInteger()
versionName VERSION_NAME versionName VERSION_NAME
// Warning:Renderscript support mode is not currently supported with renderscript target 21+ consumerProguardFiles 'proguard-rules.txt'
renderscriptTargetApi RENDERSCRIPT_TARGET_API as int }
renderscriptSupportModeEnabled true
consumerProguardFiles 'proguard-rules.txt'
}
} }
dependencies { dependencies {
compile "com.github.bumptech.glide:glide:${GLIDE_VERSION}" compile "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
provided "jp.co.cyberagent.android.gpuimage:gpuimage-library:${GPUIMAGE_VERSION}" provided "jp.co.cyberagent.android.gpuimage:gpuimage-library:${GPUIMAGE_VERSION}"
} }
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)) classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
} }
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc' classifier = 'javadoc'
from androidJavadocs.destinationDir from androidJavadocs.destinationDir
} }
task androidSourcesJar(type: Jar) { task androidSourcesJar(type: Jar) {
classifier = 'sources' classifier = 'sources'
from android.sourceSets.main.java.srcDirs from android.sourceSets.main.java.srcDirs
} }
artifacts { artifacts {
archives androidSourcesJar archives androidSourcesJar
archives androidJavadocsJar archives androidJavadocsJar
} }
publish { publish {
userOrg = POM_DEVELOPER_ID userOrg = POM_DEVELOPER_ID
groupId = GROUP groupId = GROUP
artifactId = ARTIFACT_ID artifactId = ARTIFACT_ID
publishVersion = VERSION_NAME publishVersion = VERSION_NAME
desc = POM_DESCRIPTION desc = POM_DESCRIPTION
website = POM_URL website = POM_URL
} }

View File

@@ -1,7 +1 @@
-keepclasseswithmembernames class * {
native <methods>;
}
-keep class android.support.v8.renderscript.** { *; }
-dontwarn jp.co.cyberagent.android.gpuimage.** -dontwarn jp.co.cyberagent.android.gpuimage.**

View File

@@ -8,7 +8,7 @@ import android.test.ApplicationTestCase;
*/ */
public class ApplicationTest extends ApplicationTestCase<Application> { public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() { public ApplicationTest() {
super(Application.class); super(Application.class);
} }
} }

View File

@@ -20,17 +20,15 @@ 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.support.v8.renderscript.Allocation; import android.os.Build;
import android.support.v8.renderscript.Element; import android.renderscript.RSRuntimeException;
import android.support.v8.renderscript.RSRuntimeException;
import android.support.v8.renderscript.RenderScript;
import android.support.v8.renderscript.ScriptIntrinsicBlur;
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 jp.wasabeef.glide.transformations.internal.FastBlur; import jp.wasabeef.glide.transformations.internal.FastBlur;
import jp.wasabeef.glide.transformations.internal.RSBlur;
public class BlurTransformation implements Transformation<Bitmap> { public class BlurTransformation implements Transformation<Bitmap> {
@@ -90,25 +88,14 @@ public class BlurTransformation implements Transformation<Bitmap> {
paint.setFlags(Paint.FILTER_BITMAP_FLAG); paint.setFlags(Paint.FILTER_BITMAP_FLAG);
canvas.drawBitmap(source, 0, 0, paint); canvas.drawBitmap(source, 0, 0, paint);
RenderScript rs = null; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
try { try {
rs = RenderScript.create(mContext); bitmap = RSBlur.blur(mContext, bitmap, mRadius);
Allocation input = } catch (RSRuntimeException e) {
Allocation.createFromBitmap(rs, bitmap, Allocation.MipmapControl.MIPMAP_NONE, bitmap = FastBlur.blur(bitmap, mRadius, true);
Allocation.USAGE_SCRIPT);
Allocation output = Allocation.createTyped(rs, input.getType());
ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
blur.setInput(input);
blur.setRadius(mRadius);
blur.forEach(output);
output.copyTo(bitmap);
} catch (RSRuntimeException e) {
bitmap = FastBlur.doBlur(bitmap, mRadius, true);
} finally {
if (rs != null) {
rs.destroy();
} }
} else {
bitmap = FastBlur.blur(bitmap, mRadius, true);
} }
return BitmapResource.obtain(bitmap, mBitmapPool); return BitmapResource.obtain(bitmap, mBitmapPool);

View File

@@ -32,13 +32,13 @@ import jp.wasabeef.glide.transformations.internal.Utils;
public class MaskTransformation implements Transformation<Bitmap> { public class MaskTransformation implements Transformation<Bitmap> {
private static Paint mMaskingPaint = new Paint(); private static Paint sMaskingPaint = new Paint();
private Context mContext; private Context mContext;
private BitmapPool mBitmapPool; private BitmapPool mBitmapPool;
private int mMaskId; private int mMaskId;
static { static {
mMaskingPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); sMaskingPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
} }
/** /**
@@ -73,7 +73,7 @@ public class MaskTransformation implements Transformation<Bitmap> {
Canvas canvas = new Canvas(result); Canvas canvas = new Canvas(result);
mask.setBounds(0, 0, width, height); mask.setBounds(0, 0, width, height);
mask.draw(canvas); mask.draw(canvas);
canvas.drawBitmap(source, 0, 0, mMaskingPaint); canvas.drawBitmap(source, 0, 0, sMaskingPaint);
return BitmapResource.obtain(result, mBitmapPool); return BitmapResource.obtain(result, mBitmapPool);
} }

View File

@@ -20,7 +20,7 @@ import android.graphics.Bitmap;
public class FastBlur { public class FastBlur {
public static Bitmap doBlur(Bitmap sentBitmap, int radius, boolean canReuseInBitmap) { public static Bitmap blur(Bitmap sentBitmap, int radius, boolean canReuseInBitmap) {
// Stack Blur v1.0 from // Stack Blur v1.0 from
// http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html // http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html

View File

@@ -0,0 +1,55 @@
package jp.wasabeef.glide.transformations.internal;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RSRuntimeException;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;
/**
* Copyright (C) 2015 Wasabeef
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
public class RSBlur {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static Bitmap blur(Context context, Bitmap bitmap, int radius) throws RSRuntimeException {
RenderScript rs = null;
try {
rs = RenderScript.create(context);
rs.setMessageHandler(new RenderScript.RSMessageHandler());
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));
blur.setInput(input);
blur.setRadius(radius);
blur.forEach(output);
output.copyTo(bitmap);
} finally {
if (rs != null) {
rs.destroy();
}
}
return bitmap;
}
}