mirror of
https://github.com/wasabeef/glide-transformations.git
synced 2025-06-06 22:34:05 +08:00
Release 4.3.0 (#184)
* refactor: clean code * update: gpuimage * update: min sdk to 21 * refactor: remove support rs * update: gradle plugin * style: fix xml format * update: update gradle properties * release 4.2.1 * update: samples * update: sample * update:changelog * remove comments * change release version
This commit is contained in:
parent
4b4f6b1ad4
commit
09e62054e9
11
CHANGELOG.md
11
CHANGELOG.md
@ -1,6 +1,17 @@
|
||||
Change Log
|
||||
==========
|
||||
|
||||
Version 4.3.0 *(2020-09-27)*
|
||||
----------------------------
|
||||
|
||||
Feature
|
||||
- Remove support v8 renderscript (Please use BlurTransformation)
|
||||
|
||||
Update
|
||||
- minSdkVersion -> 21
|
||||
- GPUImage -> 2.1.0
|
||||
- Cleanup codes
|
||||
|
||||
Version 4.2.0 *(2020-09-15)*
|
||||
----------------------------
|
||||
|
||||
|
@ -4,7 +4,7 @@ buildscript {
|
||||
ext {
|
||||
kotlin_version = '1.3.72'
|
||||
glide_version = '4.11.0'
|
||||
gpuimage_version = '2.0.4'
|
||||
gpuimage_version = '2.1.0'
|
||||
}
|
||||
|
||||
repositories {
|
||||
@ -12,7 +12,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.2.0-alpha10'
|
||||
classpath 'com.android.tools.build:gradle:4.2.0-alpha12'
|
||||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
|
||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
|
@ -10,9 +10,6 @@ android {
|
||||
targetSdkVersion TARGET_SDK_VERSION as int
|
||||
versionCode VERSION_CODE as int
|
||||
versionName VERSION_NAME
|
||||
|
||||
renderscriptTargetApi TARGET_SDK_VERSION as int
|
||||
renderscriptSupportModeEnabled true
|
||||
}
|
||||
|
||||
// SigningConfigs
|
||||
|
@ -16,7 +16,7 @@ class MainActivity : AppCompatActivity() {
|
||||
layoutManager = LinearLayoutManager(context)
|
||||
adapter = MainAdapter(context, mutableListOf(
|
||||
Mask, NinePatchMask, RoundedCorners, CropTop, CropCenter, CropBottom, CropSquare, CropCircle,
|
||||
CropCircleWithBorder, Grayscale, Blur, SupportRSBlur, Toon, Sepia, Contrast, Invert,
|
||||
CropCircleWithBorder, Grayscale, BlurLight, BlurDeep, Toon, Sepia, Contrast, Invert,
|
||||
Pixel, Sketch, Swirl, Brightness, Kuawahara, Vignette
|
||||
))
|
||||
}
|
||||
|
@ -41,8 +41,8 @@ class MainAdapter(
|
||||
ColorFilter,
|
||||
Grayscale,
|
||||
RoundedCorners,
|
||||
Blur,
|
||||
SupportRSBlur,
|
||||
BlurLight,
|
||||
BlurDeep,
|
||||
Toon,
|
||||
Sepia,
|
||||
Contrast,
|
||||
@ -131,14 +131,14 @@ class MainAdapter(
|
||||
RoundedCornersTransformation.CornerType.DIAGONAL_FROM_TOP_LEFT)))
|
||||
.into(holder.image)
|
||||
|
||||
Blur -> Glide.with(context)
|
||||
BlurLight -> Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(BlurTransformation(25)))
|
||||
.into(holder.image)
|
||||
|
||||
SupportRSBlur -> Glide.with(context)
|
||||
BlurDeep -> Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(SupportRSBlurTransformation(25, 10)))
|
||||
.apply(bitmapTransform(BlurTransformation(25, 8)))
|
||||
.into(holder.image)
|
||||
|
||||
Toon -> Glide.with(context)
|
||||
|
@ -1,29 +1,16 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
org.gradle.parallel=true
|
||||
org.gradle.daemon=true
|
||||
org.gradle.configureondemand=true
|
||||
org.gradle.caching=true
|
||||
android.enableBuildCache=true
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
# Use R8 instead of ProGuard for code shrinking.
|
||||
android.enableR8=true
|
||||
android.enableR8.fullMode=true
|
||||
|
||||
VERSION_NAME=4.2.0
|
||||
VERSION_CODE=420
|
||||
VERSION_NAME=4.3.0
|
||||
VERSION_CODE=421
|
||||
GROUP=jp.wasabeef
|
||||
COMPILE_SDK_VERSION=30
|
||||
TARGET_SDK_VERSION=30
|
||||
MIN_SDK_VERSION=14
|
||||
MIN_SDK_VERSION=21
|
||||
|
@ -7,9 +7,6 @@ android {
|
||||
minSdkVersion MIN_SDK_VERSION as int
|
||||
targetSdkVersion TARGET_SDK_VERSION as int
|
||||
|
||||
renderscriptTargetApi TARGET_SDK_VERSION as int
|
||||
renderscriptSupportModeEnabled true
|
||||
|
||||
consumerProguardFiles 'proguard-rules.txt'
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
<manifest package="jp.wasabeef.glide.transformations"></manifest>
|
||||
<manifest package="jp.wasabeef.glide.transformations" />
|
||||
|
@ -20,6 +20,7 @@ import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.renderscript.RSRuntimeException;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@ -28,6 +29,7 @@ import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
import jp.wasabeef.glide.transformations.internal.FastBlur;
|
||||
import jp.wasabeef.glide.transformations.internal.RSBlur;
|
||||
|
||||
public class BlurTransformation extends BitmapTransformation {
|
||||
|
||||
@ -35,11 +37,11 @@ public class BlurTransformation extends BitmapTransformation {
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.BlurTransformation." + VERSION;
|
||||
|
||||
private static int MAX_RADIUS = 25;
|
||||
private static int DEFAULT_DOWN_SAMPLING = 1;
|
||||
private static final int MAX_RADIUS = 25;
|
||||
private static final int DEFAULT_DOWN_SAMPLING = 1;
|
||||
|
||||
private int radius;
|
||||
private int sampling;
|
||||
private final int radius;
|
||||
private final int sampling;
|
||||
|
||||
public BlurTransformation() {
|
||||
this(MAX_RADIUS, DEFAULT_DOWN_SAMPLING);
|
||||
@ -73,7 +75,11 @@ public class BlurTransformation extends BitmapTransformation {
|
||||
paint.setFlags(Paint.FILTER_BITMAP_FLAG);
|
||||
canvas.drawBitmap(toTransform, 0, 0, paint);
|
||||
|
||||
bitmap = FastBlur.blur(bitmap, radius, true);
|
||||
try {
|
||||
bitmap = RSBlur.blur(context, bitmap, radius);
|
||||
} catch (RSRuntimeException e) {
|
||||
bitmap = FastBlur.blur(bitmap, radius, true);
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class ColorFilterTransformation extends BitmapTransformation {
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.ColorFilterTransformation." + VERSION;
|
||||
|
||||
private int color;
|
||||
private final int color;
|
||||
|
||||
public ColorFilterTransformation(int color) {
|
||||
this.color = color;
|
||||
|
@ -38,8 +38,8 @@ public class CropCircleWithBorderTransformation extends BitmapTransformation {
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID = "jp.wasabeef.glide.transformations.CropCircleWithBorderTransformation." + VERSION;
|
||||
|
||||
private int borderSize;
|
||||
private int borderColor;
|
||||
private final int borderSize;
|
||||
private final int borderColor;
|
||||
|
||||
|
||||
public CropCircleWithBorderTransformation() {
|
||||
|
@ -30,16 +30,14 @@ import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
import jp.wasabeef.glide.transformations.internal.Utils;
|
||||
|
||||
public class MaskTransformation extends BitmapTransformation {
|
||||
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.MaskTransformation." + VERSION;
|
||||
|
||||
private static Paint paint = new Paint();
|
||||
private int maskId;
|
||||
private static final Paint paint = new Paint();
|
||||
private final int maskId;
|
||||
|
||||
static {
|
||||
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||
@ -63,7 +61,7 @@ public class MaskTransformation extends BitmapTransformation {
|
||||
Bitmap bitmap = pool.get(width, height, Bitmap.Config.ARGB_8888);
|
||||
bitmap.setHasAlpha(true);
|
||||
|
||||
Drawable mask = Utils.getMaskDrawable(context.getApplicationContext(), maskId);
|
||||
Drawable mask = context.getDrawable(maskId);
|
||||
|
||||
setCanvasBitmapDensity(toTransform, bitmap);
|
||||
|
||||
|
@ -43,10 +43,10 @@ public class RoundedCornersTransformation extends BitmapTransformation {
|
||||
DIAGONAL_FROM_TOP_LEFT, DIAGONAL_FROM_TOP_RIGHT
|
||||
}
|
||||
|
||||
private int radius;
|
||||
private int diameter;
|
||||
private int margin;
|
||||
private CornerType cornerType;
|
||||
private final int radius;
|
||||
private final int diameter;
|
||||
private final int margin;
|
||||
private final CornerType cornerType;
|
||||
|
||||
public RoundedCornersTransformation(int radius, int margin) {
|
||||
this(radius, margin, CornerType.ALL);
|
||||
|
@ -1,115 +0,0 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2020 Wasabeef
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
import jp.wasabeef.glide.transformations.internal.FastBlur;
|
||||
import jp.wasabeef.glide.transformations.internal.RSBlur;
|
||||
import jp.wasabeef.glide.transformations.internal.SupportRSBlur;
|
||||
|
||||
public class SupportRSBlurTransformation extends BitmapTransformation {
|
||||
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.SupportRSBlurTransformation." + VERSION;
|
||||
|
||||
private static int MAX_RADIUS = 25;
|
||||
private static int DEFAULT_DOWN_SAMPLING = 1;
|
||||
|
||||
private int radius;
|
||||
private int sampling;
|
||||
|
||||
public SupportRSBlurTransformation() {
|
||||
this(MAX_RADIUS, DEFAULT_DOWN_SAMPLING);
|
||||
}
|
||||
|
||||
public SupportRSBlurTransformation(int radius) {
|
||||
this(radius, DEFAULT_DOWN_SAMPLING);
|
||||
}
|
||||
|
||||
public SupportRSBlurTransformation(int radius, int sampling) {
|
||||
this.radius = radius;
|
||||
this.sampling = sampling;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@NonNull Bitmap toTransform, int outWidth, int outHeight) {
|
||||
|
||||
int width = toTransform.getWidth();
|
||||
int height = toTransform.getHeight();
|
||||
int scaledWidth = width / sampling;
|
||||
int scaledHeight = height / sampling;
|
||||
|
||||
Bitmap bitmap = pool.get(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
|
||||
|
||||
setCanvasBitmapDensity(toTransform, bitmap);
|
||||
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
canvas.scale(1 / (float) sampling, 1 / (float) sampling);
|
||||
Paint paint = new Paint();
|
||||
paint.setFlags(Paint.FILTER_BITMAP_FLAG);
|
||||
canvas.drawBitmap(toTransform, 0, 0, paint);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
try {
|
||||
bitmap = SupportRSBlur.blur(context, bitmap, radius);
|
||||
} catch (NoClassDefFoundError e) {
|
||||
bitmap = RSBlur.blur(context, bitmap, radius);
|
||||
} catch (RuntimeException e) {
|
||||
bitmap = FastBlur.blur(bitmap, radius, true);
|
||||
}
|
||||
} else {
|
||||
bitmap = FastBlur.blur(bitmap, radius, true);
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SupportRSBlurTransformation(radius=" + radius + ", sampling=" + sampling + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof SupportRSBlurTransformation &&
|
||||
((SupportRSBlurTransformation) o).radius == radius &&
|
||||
((SupportRSBlurTransformation) o).sampling == sampling;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode() + radius * 1000 + sampling * 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID + radius + sampling).getBytes(CHARSET));
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ public class BrightnessFilterTransformation extends GPUFilterTransformation {
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.BrightnessFilterTransformation." + VERSION;
|
||||
|
||||
private float brightness;
|
||||
private final float brightness;
|
||||
|
||||
public BrightnessFilterTransformation() {
|
||||
this(0.0f);
|
||||
|
@ -31,7 +31,7 @@ public class ContrastFilterTransformation extends GPUFilterTransformation {
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.ContrastFilterTransformation." + VERSION;
|
||||
|
||||
private float contrast;
|
||||
private final float contrast;
|
||||
|
||||
public ContrastFilterTransformation() {
|
||||
this(1.0f);
|
||||
|
@ -36,7 +36,7 @@ public class GPUFilterTransformation extends BitmapTransformation {
|
||||
"jp.wasabeef.glide.transformations.gpu.GPUFilterTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
private GPUImageFilter gpuImageFilter;
|
||||
private final GPUImageFilter gpuImageFilter;
|
||||
|
||||
public GPUFilterTransformation(GPUImageFilter filter) {
|
||||
this.gpuImageFilter = filter;
|
||||
|
@ -34,7 +34,7 @@ public class KuwaharaFilterTransformation extends GPUFilterTransformation {
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.KuwaharaFilterTransformation." + VERSION;
|
||||
|
||||
private int radius;
|
||||
private final int radius;
|
||||
|
||||
public KuwaharaFilterTransformation() {
|
||||
this(25);
|
||||
|
@ -33,7 +33,7 @@ public class PixelationFilterTransformation extends GPUFilterTransformation {
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.PixelationFilterTransformation." + VERSION;
|
||||
|
||||
private float pixel;
|
||||
private final float pixel;
|
||||
|
||||
public PixelationFilterTransformation() {
|
||||
this(10f);
|
||||
|
@ -33,7 +33,7 @@ public class SepiaFilterTransformation extends GPUFilterTransformation {
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.SepiaFilterTransformation." + VERSION;
|
||||
|
||||
private float intensity;
|
||||
private final float intensity;
|
||||
|
||||
public SepiaFilterTransformation() {
|
||||
this(1.0f);
|
||||
|
@ -33,9 +33,9 @@ public class SwirlFilterTransformation extends GPUFilterTransformation {
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.SwirlFilterTransformation." + VERSION;
|
||||
|
||||
private float radius;
|
||||
private float angle;
|
||||
private PointF center;
|
||||
private final float radius;
|
||||
private final float angle;
|
||||
private final PointF center;
|
||||
|
||||
public SwirlFilterTransformation() {
|
||||
this(.5f, 1.0f, new PointF(0.5f, 0.5f));
|
||||
|
@ -33,8 +33,8 @@ public class ToonFilterTransformation extends GPUFilterTransformation {
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.ToonFilterTransformation." + VERSION;
|
||||
|
||||
private float threshold;
|
||||
private float quantizationLevels;
|
||||
private final float threshold;
|
||||
private final float quantizationLevels;
|
||||
|
||||
public ToonFilterTransformation() {
|
||||
this(.2f, 10.0f);
|
||||
|
@ -36,10 +36,10 @@ public class VignetteFilterTransformation extends GPUFilterTransformation {
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.VignetteFilterTransformation." + VERSION;
|
||||
|
||||
private PointF center;
|
||||
private float[] vignetteColor;
|
||||
private float vignetteStart;
|
||||
private float vignetteEnd;
|
||||
private final PointF center;
|
||||
private final float[] vignetteColor;
|
||||
private final float vignetteStart;
|
||||
private final float vignetteEnd;
|
||||
|
||||
public VignetteFilterTransformation() {
|
||||
this(new PointF(0.5f, 0.5f), new float[]{0.0f, 0.0f, 0.0f}, 0.0f, 0.75f);
|
||||
|
@ -28,7 +28,6 @@ import android.renderscript.ScriptIntrinsicBlur;
|
||||
|
||||
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;
|
||||
Allocation input = null;
|
||||
|
@ -1,71 +0,0 @@
|
||||
package jp.wasabeef.glide.transformations.internal;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.renderscript.Allocation;
|
||||
import androidx.renderscript.Element;
|
||||
import androidx.renderscript.RSRuntimeException;
|
||||
import androidx.renderscript.RenderScript;
|
||||
import androidx.renderscript.ScriptIntrinsicBlur;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2020 Wasabeef
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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 SupportRSBlur {
|
||||
|
||||
@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);
|
||||
rs.setMessageHandler(new RenderScript.RSMessageHandler());
|
||||
input = Allocation.createFromBitmap(rs, bitmap, Allocation.MipmapControl.MIPMAP_NONE,
|
||||
Allocation.USAGE_SCRIPT);
|
||||
output = Allocation.createTyped(rs, input.getType());
|
||||
blur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
|
||||
|
||||
blur.setInput(input);
|
||||
blur.setRadius(radius);
|
||||
blur.forEach(output);
|
||||
output.copyTo(bitmap);
|
||||
} finally {
|
||||
if (rs != null) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
RenderScript.releaseAllContexts();
|
||||
} else {
|
||||
rs.destroy();
|
||||
}
|
||||
}
|
||||
if (input != null) {
|
||||
input.destroy();
|
||||
}
|
||||
if (output != null) {
|
||||
output.destroy();
|
||||
}
|
||||
if (blur != null) {
|
||||
blur.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
}
|
@ -27,21 +27,6 @@ public final class Utils {
|
||||
// Utility class.
|
||||
}
|
||||
|
||||
public static Drawable getMaskDrawable(Context context, int maskId) {
|
||||
Drawable drawable;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
drawable = context.getDrawable(maskId);
|
||||
} else {
|
||||
drawable = context.getResources().getDrawable(maskId);
|
||||
}
|
||||
|
||||
if (drawable == null) {
|
||||
throw new IllegalArgumentException("maskId is invalid");
|
||||
}
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
public static int toDp(int px) {
|
||||
return px * (int) Resources.getSystem().getDisplayMetrics().density;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user