1
0
mirror of https://github.com/wasabeef/glide-transformations.git synced 2025-06-08 23:44:04 +08:00
* update gradle wrapper

* update Copyright

* update kotlin version

* update glide

* update Copyright

* refactor to be simply

* add CircleCropWithBorder to sample

* code cleanup

* add px to dp convert

* update gradle

* update idea settings

* bump up to 4.1.0

* update readme
This commit is contained in:
Daichi Furiya 2019-08-15 13:47:18 +09:00 committed by GitHub
parent e16eda6af1
commit 0b9311813a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 450 additions and 247 deletions

116
.idea/codeStyles/Project.xml generated Normal file
View File

@ -0,0 +1,116 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<codeStyleSettings language="XML">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>

View File

@ -1,6 +1,21 @@
Change Log Change Log
========== ==========
Version 4.1.0 *(2019-08-15)*
----------------------------
Add:
- Support to CropCircle with Border [#136](https://github.com/wasabeef/glide-transformations/pull/136)
Update:
- Glide to 4.9.0
- Android Gradle plugin to 3.6.0-alpha05
- Kotlin to 1.3.41
Bug Fix:
- Fix diffrent density [#147](https://github.com/wasabeef/glide-transformations/pull/147)
Version 4.0.1 *(2018-11-20)* Version 4.0.1 *(2018-11-20)*
---------------------------- ----------------------------

View File

@ -79,25 +79,35 @@ android {
## Transformations ## Transformations
### Crop ### Crop
`CropTransformation`, `CropCircleTransformation`, `CropSquareTransformation`, - `CropTransformation`
`RoundedCornersTransformation` - `CropCircleTransformation`
- `CropCircleWithBorderTransformation`
- `CropSquareTransformation`
- `RoundedCornersTransformation`
### Color ### Color
`ColorFilterTransformation`, `GrayscaleTransformation` - `ColorFilterTransformation`
- `GrayscaleTransformation`
### Blur ### Blur
`BlurTransformation` - `BlurTransformation`
### Mask ### Mask
`MaskTransformation` - `MaskTransformation`
### GPU Filter (use [GPUImage](https://github.com/CyberAgent/android-gpuimage)) ### GPU Filter (use [GPUImage](https://github.com/CyberAgent/android-gpuimage))
**Will require add dependencies for GPUImage.** **Will require add dependencies for GPUImage.**
`ToonFilterTransformation`, `SepiaFilterTransformation`, `ContrastFilterTransformation` - `ToonFilterTransformation`
`InvertFilterTransformation`, `PixelationFilterTransformation`, `SketchFilterTransformation` - `SepiaFilterTransformation`
`SwirlFilterTransformation`, `BrightnessFilterTransformation`, `KuwaharaFilterTransformation` - `ContrastFilterTransformation`
`VignetteFilterTransformation` - `InvertFilterTransformation`
- `PixelationFilterTransformation`
- `SketchFilterTransformation`
- `SwirlFilterTransformation`
- `BrightnessFilterTransformation`
- `KuwaharaFilterTransformation`
- `VignetteFilterTransformation`
Applications using Glide Transformations Applications using Glide Transformations
@ -129,6 +139,7 @@ Contributers
------- -------
* [start141](https://github.com/start141) * [start141](https://github.com/start141)
* [squeeish](https://github.com/squeeish)
Thanks Thanks
------- -------

View File

@ -2,8 +2,8 @@
buildscript { buildscript {
ext { ext {
kotlin_version = '1.3.0' kotlin_version = '1.3.41'
glide_version = '4.8.0' glide_version = '4.9.0'
gpuimage_version = '2.0.3' gpuimage_version = '2.0.3'
} }
@ -12,7 +12,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.4.0-alpha04' classpath 'com.android.tools.build:gradle:3.6.0-alpha05'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

View File

@ -1,7 +1,7 @@
package jp.wasabeef.example.glide package jp.wasabeef.example.glide
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -15,9 +15,9 @@ class MainActivity : AppCompatActivity() {
findViewById<RecyclerView>(R.id.list).apply { findViewById<RecyclerView>(R.id.list).apply {
layoutManager = LinearLayoutManager(context) layoutManager = LinearLayoutManager(context)
adapter = MainAdapter(context, mutableListOf( adapter = MainAdapter(context, mutableListOf(
Mask, NinePatchMask, CropTop, CropCenter, CropBottom, CropSquare, CropCircle, Grayscale, Mask, NinePatchMask, CropTop, CropCenter, CropBottom, CropSquare, CropCircle,
Blur, SupportRSBlur, Toon, Sepia, Contrast, Invert, Pixel, Sketch, Swirl, Brightness, CropCircleWithBorder, Grayscale, Blur, SupportRSBlur, Toon, Sepia, Contrast, Invert,
Kuawahara, Vignette Pixel, Sketch, Swirl, Brightness, Kuawahara, Vignette
)) ))
} }
} }

View File

@ -19,6 +19,7 @@ import jp.wasabeef.example.glide.MainAdapter.Type.*
import jp.wasabeef.glide.transformations.* import jp.wasabeef.glide.transformations.*
import jp.wasabeef.glide.transformations.CropTransformation.CropType import jp.wasabeef.glide.transformations.CropTransformation.CropType
import jp.wasabeef.glide.transformations.gpu.* import jp.wasabeef.glide.transformations.gpu.*
import jp.wasabeef.glide.transformations.internal.Utils
/** /**
* Created by Wasabeef on 2015/01/11. * Created by Wasabeef on 2015/01/11.
@ -36,6 +37,7 @@ class MainAdapter(
CropBottom, CropBottom,
CropSquare, CropSquare,
CropCircle, CropCircle,
CropCircleWithBorder,
ColorFilter, ColorFilter,
Grayscale, Grayscale,
RoundedCorners, RoundedCorners,
@ -65,7 +67,7 @@ class MainAdapter(
override fun onBindViewHolder(holder: ViewHolder, position: Int) { override fun onBindViewHolder(holder: ViewHolder, position: Int) {
when (dataSet[position]) { when (dataSet[position]) {
MainAdapter.Type.Mask -> { Mask -> {
Glide.with(context) Glide.with(context)
.load(R.drawable.check) .load(R.drawable.check)
.apply(overrideOf(266.px, 252.px)) .apply(overrideOf(266.px, 252.px))
@ -73,7 +75,7 @@ class MainAdapter(
MaskTransformation(R.drawable.mask_starfish)))) MaskTransformation(R.drawable.mask_starfish))))
.into(holder.image) .into(holder.image)
} }
MainAdapter.Type.NinePatchMask -> { NinePatchMask -> {
Glide.with(context) Glide.with(context)
.load(R.drawable.check) .load(R.drawable.check)
.apply(overrideOf(300.px, 200.px)) .apply(overrideOf(300.px, 200.px))
@ -107,6 +109,12 @@ class MainAdapter(
.apply(bitmapTransform(CropCircleTransformation())) .apply(bitmapTransform(CropCircleTransformation()))
.into(holder.image) .into(holder.image)
CropCircleWithBorder -> Glide.with(context)
.load(R.drawable.demo)
.apply(bitmapTransform(
CropCircleWithBorderTransformation(Utils.toDp(4), Color.rgb(0, 145, 86))))
.into(holder.image)
ColorFilter -> Glide.with(context) ColorFilter -> Glide.with(context)
.load(R.drawable.demo) .load(R.drawable.demo)
.apply(bitmapTransform(ColorFilterTransformation(Color.argb(80, 255, 0, 0)))) .apply(bitmapTransform(ColorFilterTransformation(Color.argb(80, 255, 0, 0))))

View File

@ -27,7 +27,7 @@ android.enableR8.fullMode=true
# transitive dependency references. # transitive dependency references.
android.namespacedRClass=true android.namespacedRClass=true
VERSION_NAME=4.0.1 VERSION_NAME=4.1.0
GROUP=jp.wasabeef GROUP=jp.wasabeef
COMPILE_SDK_VERSION=28 COMPILE_SDK_VERSION=28

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-milestone-1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

18
gradlew vendored
View File

@ -1,5 +1,21 @@
#!/usr/bin/env sh #!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# 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
#
# https://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.
#
############################################################################## ##############################################################################
## ##
## Gradle start up script for UN*X ## Gradle start up script for UN*X
@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS="" DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"

18
gradlew.bat vendored
View File

@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%" == "" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS= set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome

View File

@ -1,15 +1,15 @@
package jp.wasabeef.glide.transformations; package jp.wasabeef.glide.transformations;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* Copyright 2014 Google, Inc. All rights reserved. * Copyright 2014 Google, Inc. All rights reserved.
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -20,6 +20,8 @@ package jp.wasabeef.glide.transformations;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import androidx.annotation.NonNull;
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;
@ -30,8 +32,6 @@ import com.bumptech.glide.util.Util;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
public abstract class BitmapTransformation implements Transformation<Bitmap> { public abstract class BitmapTransformation implements Transformation<Bitmap> {
@NonNull @NonNull
@ -58,12 +58,12 @@ public abstract class BitmapTransformation implements Transformation<Bitmap> {
return result; return result;
} }
void setCanvasBitmapDensity(@NonNull Bitmap toTransform, @NonNull Bitmap canvasBitmap) { void setCanvasBitmapDensity(@NonNull Bitmap toTransform, @NonNull Bitmap canvasBitmap) {
canvasBitmap.setDensity(toTransform.getDensity()); canvasBitmap.setDensity(toTransform.getDensity());
} }
protected abstract Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool, protected abstract Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
@NonNull Bitmap toTransform, int outWidth, int outHeight); @NonNull Bitmap toTransform, int outWidth, int outHeight);
@Override @Override
public abstract void updateDiskCacheKey(@NonNull MessageDigest messageDigest); public abstract void updateDiskCacheKey(@NonNull MessageDigest messageDigest);

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations; package jp.wasabeef.glide.transformations;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -21,11 +21,12 @@ import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import androidx.annotation.NonNull;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
import jp.wasabeef.glide.transformations.internal.FastBlur; import jp.wasabeef.glide.transformations.internal.FastBlur;
public class BlurTransformation extends BitmapTransformation { public class BlurTransformation extends BitmapTransformation {
@ -64,7 +65,7 @@ public class BlurTransformation extends BitmapTransformation {
Bitmap bitmap = pool.get(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888); Bitmap bitmap = pool.get(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
setCanvasBitmapDensity(toTransform,bitmap); setCanvasBitmapDensity(toTransform, bitmap);
Canvas canvas = new Canvas(bitmap); Canvas canvas = new Canvas(bitmap);
canvas.scale(1 / (float) sampling, 1 / (float) sampling); canvas.scale(1 / (float) sampling, 1 / (float) sampling);

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations; package jp.wasabeef.glide.transformations;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -23,12 +23,12 @@ import android.graphics.Paint;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffColorFilter;
import androidx.annotation.NonNull;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
public class ColorFilterTransformation extends BitmapTransformation { public class ColorFilterTransformation extends BitmapTransformation {
private static final int VERSION = 1; private static final int VERSION = 1;
@ -51,13 +51,13 @@ public class ColorFilterTransformation extends BitmapTransformation {
toTransform.getConfig() != null ? toTransform.getConfig() : Bitmap.Config.ARGB_8888; toTransform.getConfig() != null ? toTransform.getConfig() : Bitmap.Config.ARGB_8888;
Bitmap bitmap = pool.get(width, height, config); Bitmap bitmap = pool.get(width, height, config);
setCanvasBitmapDensity(toTransform, bitmap); setCanvasBitmapDensity(toTransform, bitmap);
Canvas canvas = new Canvas(bitmap); Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(); Paint paint = new Paint();
paint.setAntiAlias(true); paint.setAntiAlias(true);
paint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); paint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP));
canvas.drawBitmap(toTransform, 0, 0, paint); canvas.drawBitmap(toTransform, 0, 0, paint);
return bitmap; return bitmap;
} }

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations; package jp.wasabeef.glide.transformations;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -19,14 +19,14 @@ package jp.wasabeef.glide.transformations;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import androidx.annotation.NonNull;
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.TransformationUtils; import com.bumptech.glide.load.resource.bitmap.TransformationUtils;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
/** /**
* @deprecated Use {@link RequestOptions#circleCrop()}. * @deprecated Use {@link RequestOptions#circleCrop()}.
*/ */

View File

@ -1,14 +1,30 @@
package jp.wasabeef.glide.transformations; package jp.wasabeef.glide.transformations;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import com.bumptech.glide.load.resource.bitmap.TransformationUtils;
import java.security.MessageDigest;
import jp.wasabeef.glide.transformations.internal.Utils;
/** /**
* Copyright (C) 2017 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -16,79 +32,65 @@ package jp.wasabeef.glide.transformations;
* limitations under the License. * limitations under the License.
*/ */
public class CropCircleWithBorderTransformation implements Transformation<Bitmap> { public class CropCircleWithBorderTransformation extends BitmapTransformation {
private BitmapPool mBitmapPool;
private int borderWidth;
private int borderColor;
public CropCircleWithBorderTransformation(Context context, int borderWidth, private static final int VERSION = 1;
@ColorInt int borderColor) { private static final String ID = "jp.wasabeef.glide.transformations.CropCircleWithBorderTransformation." + VERSION;
this(Glide.get(context).getBitmapPool());
this.borderWidth = borderWidth;
this.borderColor = borderColor;
}
public CropCircleWithBorderTransformation(BitmapPool pool) { private int borderSize;
this.mBitmapPool = pool; private int borderColor;
}
@Override
public Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
Bitmap source = resource.get();
int size = Math.min(source.getWidth(), source.getHeight());
int width = (source.getWidth() - size) / 2; public CropCircleWithBorderTransformation() {
int height = (source.getHeight() - size) / 2; this.borderSize = Utils.toDp(4);
this.borderColor = Color.BLACK;
}
Bitmap bitmap = mBitmapPool.get(size, size, Bitmap.Config.ARGB_8888); public CropCircleWithBorderTransformation(int borderSize, @ColorInt int borderColor) {
if (bitmap == null) { this.borderSize = borderSize;
bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); this.borderColor = borderColor;
} }
Canvas canvas = new Canvas(bitmap); @Override
Paint paint = new Paint(); protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
BitmapShader shader = @NonNull Bitmap toTransform, int outWidth, int outHeight) {
new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
if (width != 0 || height != 0) {
// source isn't square, move viewport to center
Matrix matrix = new Matrix();
matrix.setTranslate(-width, -height);
shader.setLocalMatrix(matrix);
}
paint.setShader(shader);
paint.setAntiAlias(true);
float r = size / 2f; Bitmap bitmap = TransformationUtils.circleCrop(pool, toTransform, outWidth, outHeight);
canvas.drawCircle(r, r, r, paint);
// add border setCanvasBitmapDensity(toTransform, bitmap);
int dstBitmapWidth = bitmap.getWidth() + borderWidth * 2;
Bitmap borderedBitmap =
Bitmap.createBitmap(dstBitmapWidth, dstBitmapWidth, Bitmap.Config.ARGB_8888);
Canvas canvas1 = new Canvas(borderedBitmap);
canvas1.drawBitmap(bitmap, borderWidth, borderWidth, null);
Paint paint1 = new Paint(); Paint paint = new Paint();
paint1.setColor(borderColor); paint.setColor(borderColor);
paint1.setStyle(Paint.Style.STROKE); paint.setStyle(Paint.Style.STROKE);
paint1.setStrokeWidth(borderWidth); paint.setStrokeWidth(borderSize);
paint1.setAntiAlias(true); paint.setAntiAlias(true);
canvas1.drawCircle( Canvas canvas = new Canvas(bitmap);
canvas1.getWidth() / 2, canvas.drawCircle(
canvas1.getWidth() / 2, outWidth / 2f,
canvas1.getWidth() / 2 - borderWidth / 2, outHeight / 2f,
paint1 Math.max(outWidth, outHeight) / 2f - borderSize / 2f,
); paint
);
bitmap.recycle(); return bitmap;
}
return BitmapResource.obtain(borderedBitmap, mBitmapPool); @Override
} public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
messageDigest.update((ID + borderSize + borderColor).getBytes(CHARSET));
}
@Override public String getId() { @Override
return "CropCircleWithBorderTransformation(" + public boolean equals(Object o) {
"width=" + borderWidth + ", color=" + borderColor + ")"; return o instanceof CropCircleWithBorderTransformation &&
} ((CropCircleWithBorderTransformation) o).borderSize == borderSize &&
((CropCircleWithBorderTransformation) o).borderColor == borderColor;
}
@Override
public int hashCode() {
return ID.hashCode() + borderSize * 100 + borderColor + 10;
}
} }

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations; package jp.wasabeef.glide.transformations;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -19,13 +19,13 @@ package jp.wasabeef.glide.transformations;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import androidx.annotation.NonNull;
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.TransformationUtils; import com.bumptech.glide.load.resource.bitmap.TransformationUtils;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
public class CropSquareTransformation extends BitmapTransformation { public class CropSquareTransformation extends BitmapTransformation {
private static final int VERSION = 1; private static final int VERSION = 1;

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations; package jp.wasabeef.glide.transformations;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -21,12 +21,12 @@ import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.RectF; import android.graphics.RectF;
import androidx.annotation.NonNull;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
public class CropTransformation extends BitmapTransformation { public class CropTransformation extends BitmapTransformation {
private static final int VERSION = 1; private static final int VERSION = 1;
@ -76,7 +76,7 @@ public class CropTransformation extends BitmapTransformation {
float top = getTop(scaledHeight); float top = getTop(scaledHeight);
RectF targetRect = new RectF(left, top, left + scaledWidth, top + scaledHeight); RectF targetRect = new RectF(left, top, left + scaledWidth, top + scaledHeight);
setCanvasBitmapDensity(toTransform,bitmap); setCanvasBitmapDensity(toTransform, bitmap);
Canvas canvas = new Canvas(bitmap); Canvas canvas = new Canvas(bitmap);
canvas.drawBitmap(toTransform, null, targetRect, null); canvas.drawBitmap(toTransform, null, targetRect, null);

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations; package jp.wasabeef.glide.transformations;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -23,12 +23,12 @@ import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter; import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint; import android.graphics.Paint;
import androidx.annotation.NonNull;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
public class GrayscaleTransformation extends BitmapTransformation { public class GrayscaleTransformation extends BitmapTransformation {
private static final int VERSION = 1; private static final int VERSION = 1;
@ -45,7 +45,7 @@ public class GrayscaleTransformation extends BitmapTransformation {
toTransform.getConfig() != null ? toTransform.getConfig() : Bitmap.Config.ARGB_8888; toTransform.getConfig() != null ? toTransform.getConfig() : Bitmap.Config.ARGB_8888;
Bitmap bitmap = pool.get(width, height, config); Bitmap bitmap = pool.get(width, height, config);
setCanvasBitmapDensity(toTransform,bitmap); setCanvasBitmapDensity(toTransform, bitmap);
Canvas canvas = new Canvas(bitmap); Canvas canvas = new Canvas(bitmap);
ColorMatrix saturation = new ColorMatrix(); ColorMatrix saturation = new ColorMatrix();

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations; package jp.wasabeef.glide.transformations;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -24,11 +24,12 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode; import android.graphics.PorterDuffXfermode;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
import jp.wasabeef.glide.transformations.internal.Utils; import jp.wasabeef.glide.transformations.internal.Utils;
public class MaskTransformation extends BitmapTransformation { public class MaskTransformation extends BitmapTransformation {
@ -64,7 +65,7 @@ public class MaskTransformation extends BitmapTransformation {
Drawable mask = Utils.getMaskDrawable(context.getApplicationContext(), maskId); Drawable mask = Utils.getMaskDrawable(context.getApplicationContext(), maskId);
setCanvasBitmapDensity(toTransform,bitmap); setCanvasBitmapDensity(toTransform, bitmap);
Canvas canvas = new Canvas(bitmap); Canvas canvas = new Canvas(bitmap);
mask.setBounds(0, 0, width, height); mask.setBounds(0, 0, width, height);

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations; package jp.wasabeef.glide.transformations;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -24,12 +24,12 @@ import android.graphics.Paint;
import android.graphics.RectF; import android.graphics.RectF;
import android.graphics.Shader; import android.graphics.Shader;
import androidx.annotation.NonNull;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
public class RoundedCornersTransformation extends BitmapTransformation { public class RoundedCornersTransformation extends BitmapTransformation {
private static final int VERSION = 1; private static final int VERSION = 1;
@ -68,15 +68,15 @@ public class RoundedCornersTransformation extends BitmapTransformation {
Bitmap bitmap = pool.get(width, height, Bitmap.Config.ARGB_8888); Bitmap bitmap = pool.get(width, height, Bitmap.Config.ARGB_8888);
bitmap.setHasAlpha(true); bitmap.setHasAlpha(true);
setCanvasBitmapDensity(toTransform, bitmap); setCanvasBitmapDensity(toTransform, bitmap);
Canvas canvas = new Canvas(bitmap); Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(); Paint paint = new Paint();
paint.setAntiAlias(true); paint.setAntiAlias(true);
paint.setShader(new BitmapShader(toTransform, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)); paint.setShader(new BitmapShader(toTransform, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
drawRoundRect(canvas, paint, width, height); drawRoundRect(canvas, paint, width, height);
return bitmap; return bitmap;
} }
private void drawRoundRect(Canvas canvas, Paint paint, float width, float height) { private void drawRoundRect(Canvas canvas, Paint paint, float width, float height) {
float right = width - margin; float right = width - margin;

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations; package jp.wasabeef.glide.transformations;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -22,11 +22,12 @@ import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.os.Build; import android.os.Build;
import androidx.annotation.NonNull;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
import jp.wasabeef.glide.transformations.internal.FastBlur; import jp.wasabeef.glide.transformations.internal.FastBlur;
import jp.wasabeef.glide.transformations.internal.RSBlur; import jp.wasabeef.glide.transformations.internal.RSBlur;
import jp.wasabeef.glide.transformations.internal.SupportRSBlur; import jp.wasabeef.glide.transformations.internal.SupportRSBlur;
@ -67,13 +68,13 @@ public class SupportRSBlurTransformation extends BitmapTransformation {
Bitmap bitmap = pool.get(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888); Bitmap bitmap = pool.get(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
setCanvasBitmapDensity(toTransform, bitmap); setCanvasBitmapDensity(toTransform, bitmap);
Canvas canvas = new Canvas(bitmap); Canvas canvas = new Canvas(bitmap);
canvas.scale(1 / (float) sampling, 1 / (float) sampling); canvas.scale(1 / (float) sampling, 1 / (float) sampling);
Paint paint = new Paint(); Paint paint = new Paint();
paint.setFlags(Paint.FILTER_BITMAP_FLAG); paint.setFlags(Paint.FILTER_BITMAP_FLAG);
canvas.drawBitmap(toTransform, 0, 0, paint); canvas.drawBitmap(toTransform, 0, 0, paint);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
try { try {

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations.gpu; package jp.wasabeef.glide.transformations.gpu;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -16,9 +16,10 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License. * limitations under the License.
*/ */
import androidx.annotation.NonNull;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
import jp.co.cyberagent.android.gpuimage.filter.GPUImageBrightnessFilter; import jp.co.cyberagent.android.gpuimage.filter.GPUImageBrightnessFilter;
/** /**

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations.gpu; package jp.wasabeef.glide.transformations.gpu;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -16,9 +16,10 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License. * limitations under the License.
*/ */
import androidx.annotation.NonNull;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
import jp.co.cyberagent.android.gpuimage.filter.GPUImageContrastFilter; import jp.co.cyberagent.android.gpuimage.filter.GPUImageContrastFilter;
/** /**

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations.gpu; package jp.wasabeef.glide.transformations.gpu;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -19,11 +19,12 @@ package jp.wasabeef.glide.transformations.gpu;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import androidx.annotation.NonNull;
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
import jp.co.cyberagent.android.gpuimage.GPUImage; import jp.co.cyberagent.android.gpuimage.GPUImage;
import jp.co.cyberagent.android.gpuimage.filter.GPUImageFilter; import jp.co.cyberagent.android.gpuimage.filter.GPUImageFilter;
import jp.wasabeef.glide.transformations.BitmapTransformation; import jp.wasabeef.glide.transformations.BitmapTransformation;

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations.gpu; package jp.wasabeef.glide.transformations.gpu;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -16,9 +16,10 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License. * limitations under the License.
*/ */
import androidx.annotation.NonNull;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
import jp.co.cyberagent.android.gpuimage.filter.GPUImageColorInvertFilter; import jp.co.cyberagent.android.gpuimage.filter.GPUImageColorInvertFilter;
/** /**

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations.gpu; package jp.wasabeef.glide.transformations.gpu;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -16,9 +16,10 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License. * limitations under the License.
*/ */
import androidx.annotation.NonNull;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
import jp.co.cyberagent.android.gpuimage.filter.GPUImageKuwaharaFilter; import jp.co.cyberagent.android.gpuimage.filter.GPUImageKuwaharaFilter;
/** /**

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations.gpu; package jp.wasabeef.glide.transformations.gpu;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -16,9 +16,10 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License. * limitations under the License.
*/ */
import androidx.annotation.NonNull;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
import jp.co.cyberagent.android.gpuimage.filter.GPUImagePixelationFilter; import jp.co.cyberagent.android.gpuimage.filter.GPUImagePixelationFilter;
/** /**

View File

@ -1,7 +1,7 @@
package jp.wasabeef.glide.transformations.gpu; package jp.wasabeef.glide.transformations.gpu;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* <p> * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,14 +16,15 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License. * limitations under the License.
*/ */
import androidx.annotation.NonNull;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
import jp.co.cyberagent.android.gpuimage.filter.GPUImageSepiaToneFilter; import jp.co.cyberagent.android.gpuimage.filter.GPUImageSepiaToneFilter;
/** /**
* Applies a simple sepia effect. * Applies a simple sepia effect.
* * <p>
* The intensity with a default of 1.0. * The intensity with a default of 1.0.
*/ */
public class SepiaFilterTransformation extends GPUFilterTransformation { public class SepiaFilterTransformation extends GPUFilterTransformation {

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations.gpu; package jp.wasabeef.glide.transformations.gpu;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -16,9 +16,10 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License. * limitations under the License.
*/ */
import androidx.annotation.NonNull;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
import jp.co.cyberagent.android.gpuimage.filter.GPUImageSketchFilter; import jp.co.cyberagent.android.gpuimage.filter.GPUImageSketchFilter;
public class SketchFilterTransformation extends GPUFilterTransformation { public class SketchFilterTransformation extends GPUFilterTransformation {

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations.gpu; package jp.wasabeef.glide.transformations.gpu;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -18,9 +18,10 @@ package jp.wasabeef.glide.transformations.gpu;
import android.graphics.PointF; import android.graphics.PointF;
import androidx.annotation.NonNull;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
import jp.co.cyberagent.android.gpuimage.filter.GPUImageSwirlFilter; import jp.co.cyberagent.android.gpuimage.filter.GPUImageSwirlFilter;
/** /**

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations.gpu; package jp.wasabeef.glide.transformations.gpu;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -16,9 +16,10 @@ package jp.wasabeef.glide.transformations.gpu;
* limitations under the License. * limitations under the License.
*/ */
import androidx.annotation.NonNull;
import java.security.MessageDigest; import java.security.MessageDigest;
import androidx.annotation.NonNull;
import jp.co.cyberagent.android.gpuimage.filter.GPUImageToonFilter; import jp.co.cyberagent.android.gpuimage.filter.GPUImageToonFilter;
/** /**

View File

@ -1,14 +1,14 @@
package jp.wasabeef.glide.transformations.gpu; package jp.wasabeef.glide.transformations.gpu;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -18,10 +18,11 @@ package jp.wasabeef.glide.transformations.gpu;
import android.graphics.PointF; import android.graphics.PointF;
import androidx.annotation.NonNull;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.util.Arrays; import java.util.Arrays;
import androidx.annotation.NonNull;
import jp.co.cyberagent.android.gpuimage.filter.GPUImageVignetteFilter; import jp.co.cyberagent.android.gpuimage.filter.GPUImageVignetteFilter;
/** /**

View File

@ -3,14 +3,14 @@ package jp.wasabeef.glide.transformations.internal;
import android.graphics.Bitmap; import android.graphics.Bitmap;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -72,15 +72,15 @@ public class FastBlur {
int wh = w * h; int wh = w * h;
int div = radius + radius + 1; int div = radius + radius + 1;
int r[] = new int[wh]; int[] r = new int[wh];
int g[] = new int[wh]; int[] g = new int[wh];
int b[] = new int[wh]; int[] b = new int[wh];
int rsum, gsum, bsum, x, y, i, p, yp, yi, yw; int rsum, gsum, bsum, x, y, i, p, yp, yi, yw;
int vmin[] = new int[Math.max(w, h)]; int[] vmin = new int[Math.max(w, h)];
int divsum = (div + 1) >> 1; int divsum = (div + 1) >> 1;
divsum *= divsum; divsum *= divsum;
int dv[] = new int[256 * divsum]; int[] dv = new int[256 * divsum];
for (i = 0; i < 256 * divsum; i++) { for (i = 0; i < 256 * divsum; i++) {
dv[i] = (i / divsum); dv[i] = (i / divsum);
} }

View File

@ -11,14 +11,14 @@ import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur; import android.renderscript.ScriptIntrinsicBlur;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@ -12,14 +12,14 @@ import androidx.renderscript.RenderScript;
import androidx.renderscript.ScriptIntrinsicBlur; import androidx.renderscript.ScriptIntrinsicBlur;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

View File

@ -1,18 +1,19 @@
package jp.wasabeef.glide.transformations.internal; package jp.wasabeef.glide.transformations.internal;
import android.content.Context; import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
/** /**
* Copyright (C) 2018 Wasabeef * Copyright (C) 2019 Wasabeef
* * <p>
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* * <p>
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* * <p>
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -40,4 +41,8 @@ public final class Utils {
return drawable; return drawable;
} }
public static int toDp(int px) {
return px * (int) Resources.getSystem().getDisplayMetrics().density;
}
} }