mirror of
https://github.com/wasabeef/glide-transformations.git
synced 2025-10-04 18:03:21 +08:00
Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
2a720df48d | ||
|
06db3295a1 | ||
|
34cc92f7a4 | ||
|
5715d7a999 | ||
|
36c0d00ae9 | ||
|
a29346e8d2 | ||
|
c3f2ce75a4 | ||
|
4d47793f79 | ||
|
45c2e3bcfe | ||
|
a139c21d31 | ||
|
c3f09cdd0d | ||
|
ddd76d4f06 | ||
|
f9bca8887d | ||
|
592815a6a0 | ||
|
f6540b111f | ||
|
9bea464afc | ||
|
219b32bbcc | ||
|
4d7190847c | ||
|
0d7a93c264 |
19
CHANGELOG.md
19
CHANGELOG.md
@@ -1,6 +1,25 @@
|
||||
Change Log
|
||||
==========
|
||||
|
||||
Version 2.0.2 *(2017-03-17)*
|
||||
----------------------------
|
||||
|
||||
Update:
|
||||
- Compile & Target SDK Version 23 -> 25
|
||||
- Build Tools 23.0.2 -> 25.0.2
|
||||
- Support Library 23.2.1 -> 25.3.0
|
||||
- GPUImage for Android 1.3.0 -> 1.4.1
|
||||
|
||||
Bug Fix:
|
||||
- [Additional resource cleanup in RSBlur #45](https://github.com/wasabeef/glide-transformations/pull/45)
|
||||
|
||||
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)*
|
||||
----------------------------
|
||||
|
||||
|
@@ -29,13 +29,12 @@ Please feel free to use this.
|
||||
```groovy
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral() // GPUImage for Android
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'jp.wasabeef:glide-transformations:2.0.0'
|
||||
compile 'jp.wasabeef:glide-transformations:2.0.2'
|
||||
// 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.4.1'
|
||||
}
|
||||
```
|
||||
|
||||
@@ -119,7 +118,7 @@ Thanks
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright 2015 Wasabeef
|
||||
Copyright 2017 Wasabeef
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
BIN
art/demo.gif
BIN
art/demo.gif
Binary file not shown.
Before Width: | Height: | Size: 3.9 MiB After Width: | Height: | Size: 3.9 MiB |
@@ -5,7 +5,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.0.0-beta6'
|
||||
classpath 'com.android.tools.build:gradle:2.3.0'
|
||||
classpath 'com.novoda:bintray-release:0.3.4'
|
||||
}
|
||||
}
|
||||
|
@@ -1,58 +1,58 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion COMPILE_SDK_VERSION as int
|
||||
buildToolsVersion BUILD_TOOLS_VERSION
|
||||
compileSdkVersion COMPILE_SDK_VERSION as int
|
||||
buildToolsVersion BUILD_TOOLS_VERSION
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion MIN_SDK_VERSION as int
|
||||
targetSdkVersion TARGET_SDK_VERSION as int
|
||||
versionCode "git rev-list origin/master --count".execute().text.toInteger()
|
||||
versionName VERSION_NAME
|
||||
}
|
||||
defaultConfig {
|
||||
minSdkVersion MIN_SDK_VERSION as int
|
||||
targetSdkVersion TARGET_SDK_VERSION as int
|
||||
versionCode "git rev-list origin/master --count".execute().text.toInteger()
|
||||
versionName VERSION_NAME
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file(keyStoreProperty)
|
||||
keyAlias keyAliasProperty
|
||||
storePassword keyStorePasswordProperty
|
||||
keyPassword keyAliasPasswordProperty
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file(keyStoreProperty)
|
||||
keyAlias keyAliasProperty
|
||||
storePassword keyStorePasswordProperty
|
||||
keyPassword keyAliasPasswordProperty
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
debuggable true
|
||||
zipAlignEnabled true
|
||||
}
|
||||
release {
|
||||
debuggable false
|
||||
zipAlignEnabled true
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
buildTypes {
|
||||
debug {
|
||||
debuggable true
|
||||
zipAlignEnabled true
|
||||
}
|
||||
release {
|
||||
debuggable false
|
||||
zipAlignEnabled true
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def getKeyStoreProperty() {
|
||||
return hasProperty('WASABEEF_KEYSTORE') ? WASABEEF_KEYSTORE : "debug.keystore"
|
||||
return hasProperty('WASABEEF_KEYSTORE') ? WASABEEF_KEYSTORE : "debug.keystore"
|
||||
}
|
||||
|
||||
def getKeyAliasProperty() {
|
||||
return hasProperty('WASABEEF_KEYALIAS') ? WASABEEF_KEYALIAS : "android"
|
||||
return hasProperty('WASABEEF_KEYALIAS') ? WASABEEF_KEYALIAS : "android"
|
||||
}
|
||||
|
||||
def getKeyStorePasswordProperty() {
|
||||
return hasProperty('WASABEEF_KEYSTOREPASSWORD') ? WASABEEF_KEYSTOREPASSWORD : "androiddebugkey"
|
||||
return hasProperty('WASABEEF_KEYSTOREPASSWORD') ? WASABEEF_KEYSTOREPASSWORD : "androiddebugkey"
|
||||
}
|
||||
|
||||
def getKeyAliasPasswordProperty() {
|
||||
return hasProperty('WASABEEF_KEYALIASPASSWORD') ? WASABEEF_KEYALIASPASSWORD : "android"
|
||||
return hasProperty('WASABEEF_KEYALIASPASSWORD') ? WASABEEF_KEYALIASPASSWORD : "android"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':transformations')
|
||||
compile "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
|
||||
compile "jp.co.cyberagent.android.gpuimage:gpuimage-library:${GPUIMAGE_VERSION}"
|
||||
compile "com.android.support:appcompat-v7:${SUPPORT_PACKAGE_VERSION}"
|
||||
compile "com.android.support:recyclerview-v7:${SUPPORT_PACKAGE_VERSION}"
|
||||
compile project(':transformations')
|
||||
compile "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
|
||||
compile "jp.co.cyberagent.android.gpuimage:gpuimage-library:${GPUIMAGE_VERSION}"
|
||||
compile "com.android.support:appcompat-v7:${SUPPORT_PACKAGE_VERSION}"
|
||||
compile "com.android.support:recyclerview-v7:${SUPPORT_PACKAGE_VERSION}"
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.example.glide;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp"
|
||||
>
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
VERSION_NAME=2.0.0
|
||||
VERSION_NAME=2.0.2
|
||||
GROUP=jp.wasabeef
|
||||
ARTIFACT_ID=glide-transformations
|
||||
|
||||
COMPILE_SDK_VERSION=23
|
||||
BUILD_TOOLS_VERSION=23.0.2
|
||||
TARGET_SDK_VERSION=23
|
||||
COMPILE_SDK_VERSION=25
|
||||
BUILD_TOOLS_VERSION=25.0.2
|
||||
TARGET_SDK_VERSION=25
|
||||
MIN_SDK_VERSION=11
|
||||
|
||||
POM_DESCRIPTION=which provides simple Tranformations to Glide
|
||||
@@ -21,6 +21,6 @@ POM_DEVELOPER_EMAIL=dadadada.chop@gmail.com
|
||||
POM_DEVELOPER_URL=wasabeef.jp
|
||||
ISSUE_URL=https://github.com/wasabeef/glide-transformations/issues
|
||||
|
||||
SUPPORT_PACKAGE_VERSION=23.1.1
|
||||
SUPPORT_PACKAGE_VERSION=25.3.0
|
||||
GLIDE_VERSION=3.7.0
|
||||
GPUIMAGE_VERSION=1.3.0
|
||||
GPUIMAGE_VERSION=1.4.1
|
5
gradle/wrapper/gradle-wrapper.properties
vendored
5
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,7 +1,6 @@
|
||||
#Wed Apr 10 15:27:10 PDT 2013
|
||||
#Fri Mar 17 06:53:45 JST 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-all.zip
|
||||
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
|
||||
|
@@ -2,49 +2,32 @@ apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.novoda.bintray-release'
|
||||
|
||||
android {
|
||||
compileSdkVersion COMPILE_SDK_VERSION as int
|
||||
buildToolsVersion BUILD_TOOLS_VERSION
|
||||
compileSdkVersion COMPILE_SDK_VERSION as int
|
||||
buildToolsVersion BUILD_TOOLS_VERSION
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion MIN_SDK_VERSION as int
|
||||
targetSdkVersion TARGET_SDK_VERSION as int
|
||||
versionCode "git rev-list origin/master --count".execute().text.toInteger()
|
||||
versionName VERSION_NAME
|
||||
defaultConfig {
|
||||
minSdkVersion MIN_SDK_VERSION as int
|
||||
targetSdkVersion TARGET_SDK_VERSION as int
|
||||
versionCode "git rev-list origin/master --count".execute().text.toInteger()
|
||||
versionName VERSION_NAME
|
||||
|
||||
consumerProguardFiles 'proguard-rules.txt'
|
||||
}
|
||||
consumerProguardFiles 'proguard-rules.txt'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
|
||||
provided "jp.co.cyberagent.android.gpuimage:gpuimage-library:${GPUIMAGE_VERSION}"
|
||||
}
|
||||
|
||||
task androidJavadocs(type: Javadoc) {
|
||||
source = android.sourceSets.main.java.srcDirs
|
||||
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
|
||||
}
|
||||
|
||||
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
|
||||
classifier = 'javadoc'
|
||||
from androidJavadocs.destinationDir
|
||||
}
|
||||
|
||||
task androidSourcesJar(type: Jar) {
|
||||
classifier = 'sources'
|
||||
from android.sourceSets.main.java.srcDirs
|
||||
}
|
||||
|
||||
artifacts {
|
||||
archives androidSourcesJar
|
||||
archives androidJavadocsJar
|
||||
compile "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
|
||||
provided "jp.co.cyberagent.android.gpuimage:gpuimage-library:${GPUIMAGE_VERSION}"
|
||||
}
|
||||
|
||||
publish {
|
||||
userOrg = POM_DEVELOPER_ID
|
||||
groupId = GROUP
|
||||
artifactId = ARTIFACT_ID
|
||||
publishVersion = VERSION_NAME
|
||||
desc = POM_DESCRIPTION
|
||||
website = POM_URL
|
||||
userOrg = POM_DEVELOPER_ID
|
||||
groupId = GROUP
|
||||
artifactId = ARTIFACT_ID
|
||||
publishVersion = VERSION_NAME
|
||||
desc = POM_DESCRIPTION
|
||||
website = POM_URL
|
||||
bintrayUser = BINTRAY_USER
|
||||
bintrayKey = BINTRAY_API_KEY
|
||||
autoPublish = false
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ import android.test.ApplicationTestCase;
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -88,7 +88,7 @@ public class BlurTransformation implements Transformation<Bitmap> {
|
||||
paint.setFlags(Paint.FILTER_BITMAP_FLAG);
|
||||
canvas.drawBitmap(source, 0, 0, paint);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
try {
|
||||
bitmap = RSBlur.blur(mContext, bitmap, mRadius);
|
||||
} catch (RSRuntimeException e) {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,13 +32,13 @@ import jp.wasabeef.glide.transformations.internal.Utils;
|
||||
|
||||
public class MaskTransformation implements Transformation<Bitmap> {
|
||||
|
||||
private static Paint mMaskingPaint = new Paint();
|
||||
private static Paint sMaskingPaint = new Paint();
|
||||
private Context mContext;
|
||||
private BitmapPool mBitmapPool;
|
||||
private int mMaskId;
|
||||
|
||||
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);
|
||||
mask.setBounds(0, 0, width, height);
|
||||
mask.draw(canvas);
|
||||
canvas.drawBitmap(source, 0, 0, mMaskingPaint);
|
||||
canvas.drawBitmap(source, 0, 0, sMaskingPaint);
|
||||
|
||||
return BitmapResource.obtain(result, mBitmapPool);
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -3,7 +3,7 @@ package jp.wasabeef.glide.transformations.internal;
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@@ -11,7 +11,7 @@ import android.renderscript.RenderScript;
|
||||
import android.renderscript.ScriptIntrinsicBlur;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,16 +28,19 @@ import android.renderscript.ScriptIntrinsicBlur;
|
||||
|
||||
public class RSBlur {
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
public static Bitmap blur(Context context, Bitmap bitmap, int radius) throws RSRuntimeException {
|
||||
RenderScript rs = null;
|
||||
Allocation input = null;
|
||||
Allocation output = null;
|
||||
ScriptIntrinsicBlur blur = null;
|
||||
try {
|
||||
rs = RenderScript.create(context);
|
||||
Allocation input =
|
||||
Allocation.createFromBitmap(rs, bitmap, Allocation.MipmapControl.MIPMAP_NONE,
|
||||
rs.setMessageHandler(new RenderScript.RSMessageHandler());
|
||||
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));
|
||||
output = Allocation.createTyped(rs, input.getType());
|
||||
blur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
|
||||
|
||||
blur.setInput(input);
|
||||
blur.setRadius(radius);
|
||||
@@ -47,6 +50,15 @@ public class RSBlur {
|
||||
if (rs != null) {
|
||||
rs.destroy();
|
||||
}
|
||||
if (input != null) {
|
||||
input.destroy();
|
||||
}
|
||||
if (output != null) {
|
||||
output.destroy();
|
||||
}
|
||||
if (blur != null) {
|
||||
blur.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
|
@@ -5,7 +5,7 @@ import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2015 Wasabeef
|
||||
* Copyright (C) 2017 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
Reference in New Issue
Block a user