mirror of
https://github.com/wasabeef/glide-transformations.git
synced 2025-10-04 18:03:21 +08:00
Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
09e62054e9 | ||
|
4b4f6b1ad4 | ||
|
074b6eef45 | ||
|
fa04c1b3c9 | ||
|
056adc6451 | ||
|
1c925c932e | ||
|
b08325ec70 | ||
|
e9acc52d9e | ||
|
ce14f7bdf1 | ||
|
0b9311813a | ||
|
e16eda6af1 | ||
|
783d69c579 | ||
|
ec0e655f0a | ||
|
9d4d7990d3 | ||
|
d67f715c65 | ||
|
f09f073442 | ||
|
2e2846d354 | ||
|
3aa8e53c6a | ||
|
4818373fc5 | ||
|
8c72ad64b9 | ||
|
81e72fc553 | ||
|
0361d97018 |
7
.editorconfig
Normal file
7
.editorconfig
Normal file
@@ -0,0 +1,7 @@
|
||||
[*]
|
||||
indent_size = 2
|
||||
max_line_length = off
|
||||
insert_final_newline = true
|
||||
|
||||
[*.{kt, kts}]
|
||||
kotlin_imports_layout = ascii
|
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: wasabeef # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
28
.github/ISSUE_TEMPLATE.md
vendored
Normal file
28
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
# Future Task
|
||||
|
||||
## What is the motivation?
|
||||
|
||||
## What kind of solution can be considered?
|
||||
|
||||
## What do you want to discuss?
|
||||
|
||||
*Please add relevant labels*
|
||||
|
||||
-----
|
||||
|
||||
# Bug Reporting
|
||||
|
||||
## Steps to Reproduce
|
||||
|
||||
## Actual Results (include screenshots)
|
||||
|
||||
## Expected Results (include screenshots)
|
||||
|
||||
## URL
|
||||
|
||||
## OS details
|
||||
|
||||
- Device:
|
||||
- OS:
|
||||
|
||||
*Please add relevant labels*
|
6
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
6
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
## What does this change?
|
||||
|
||||
## What is the value of this and can you measure success?
|
||||
|
||||
## Screenshots
|
||||
|
64
.gitignore
vendored
64
.gitignore
vendored
@@ -1,19 +1,23 @@
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
# Mac OS
|
||||
.DS_store
|
||||
|
||||
# gradle files
|
||||
.gradle
|
||||
# Built application files
|
||||
*.apk
|
||||
*.ap_
|
||||
|
||||
# Intellij project files
|
||||
.idea
|
||||
*.iml
|
||||
# Files for the ART/Dalvik VM
|
||||
*.dex
|
||||
|
||||
# generated files
|
||||
# Java class files
|
||||
*.class
|
||||
|
||||
# Generated files
|
||||
bin/
|
||||
gen/
|
||||
obj/
|
||||
apk/
|
||||
target/
|
||||
out/
|
||||
|
||||
# Gradle files
|
||||
.gradle/
|
||||
build/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
@@ -21,3 +25,41 @@ local.properties
|
||||
|
||||
# Proguard folder generated by Eclipse
|
||||
proguard/
|
||||
|
||||
# Log Files
|
||||
*.log
|
||||
|
||||
# Android Studio Navigation editor temp files
|
||||
.navigation/
|
||||
|
||||
# Android Studio captures folder
|
||||
captures/
|
||||
|
||||
# IntelliJ
|
||||
*.iml
|
||||
.idea/workspace.xml
|
||||
.idea/tasks.xml
|
||||
.idea/gradle.xml
|
||||
.idea/assetWizardSettings.xml
|
||||
.idea/dictionaries
|
||||
.idea/libraries
|
||||
.idea/caches
|
||||
.idea/misc.xml
|
||||
.idea/modules.xml
|
||||
.idea/navEditor.xml
|
||||
.idea/markdown*
|
||||
.idea/jarRepositories.xml
|
||||
.idea/inspectionProfiles/Project_Default.xml
|
||||
.idea/compiler.xml
|
||||
projectFilesBackup/
|
||||
|
||||
# Keystore files
|
||||
# Uncomment the following line if you do not want to check your keystore files in.
|
||||
#*.jks
|
||||
|
||||
# External native build folder generated in Android Studio 2.2 and later
|
||||
.externalNativeBuild
|
||||
|
||||
# Google Services (e.g. APIs or Firebase)
|
||||
google-services.json
|
||||
|
||||
|
116
.idea/codeStyles/Project.xml
generated
Normal file
116
.idea/codeStyles/Project.xml
generated
Normal 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>
|
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
4
.idea/encodings.xml
generated
Normal file
4
.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
|
||||
</project>
|
12
.idea/runConfigurations.xml
generated
Normal file
12
.idea/runConfigurations.xml
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
74
CHANGELOG.md
74
CHANGELOG.md
@@ -1,6 +1,80 @@
|
||||
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)*
|
||||
----------------------------
|
||||
|
||||
Update:
|
||||
- Compile & Target SDK Version 28 -> 30
|
||||
- GPUImage 2.0.3 -> 2.0.4
|
||||
- Glide 4.9.0 -> 4.11.0
|
||||
|
||||
Bugfix:
|
||||
- RoundedCornersTransformation with DIAGONAL_FROM_TOP_LEFT does not work [#178](https://github.com/wasabeef/glide-transformations/pull/178)
|
||||
|
||||
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)*
|
||||
----------------------------
|
||||
|
||||
Add:
|
||||
- consumerProguardFiles setting
|
||||
|
||||
Version 4.0.0 *(2018-11-16)*
|
||||
----------------------------
|
||||
|
||||
Update:
|
||||
- Migrate to AndroidX
|
||||
- Remove novoda-bintray-plugin
|
||||
|
||||
Version 3.3.0 *(2018-04-23)*
|
||||
----------------------------
|
||||
|
||||
Update:
|
||||
- Support Library 27.1.0 -> 27.1.1
|
||||
- Glide 4.6.1 -> 4.7.1
|
||||
|
||||
Feature:
|
||||
- SupportRSBlurTransformation [#125](https://github.com/wasabeef/glide-transformations/pull/125)
|
||||
it's using RenderScript support mode but can you choose to use or not.
|
||||
Thank you [@fougere-mike](https://github.com/fougere-mike)
|
||||
|
||||
Bug Fix:
|
||||
- Set detail of Cache key [#119](https://github.com/wasabeef/glide-transformations/issues/119)
|
||||
|
||||
Version 3.2.0 *(2018-04-10)*
|
||||
----------------------------
|
||||
|
||||
Update:
|
||||
- Support Library 27.0.2 -> 27.1.0
|
||||
|
||||
Bug Fix:
|
||||
- We quit use the RenderScript [#120](https://github.com/wasabeef/glide-transformations/issues/120)
|
||||
|
||||
Version 3.1.1 *(2018-02-13)*
|
||||
----------------------------
|
||||
|
||||
|
70
README.md
70
README.md
@@ -32,9 +32,9 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'jp.wasabeef:glide-transformations:3.1.1'
|
||||
implementation 'jp.wasabeef:glide-transformations:4.x.x'
|
||||
// If you want to use the GPU Filters
|
||||
implementation 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.4.1'
|
||||
implementation 'jp.co.cyberagent.android:gpuimage:2.x.x'
|
||||
}
|
||||
```
|
||||
|
||||
@@ -42,47 +42,72 @@ dependencies {
|
||||
|
||||
Set Glide Transform.
|
||||
|
||||
```java
|
||||
```kotlin
|
||||
Glide.with(this).load(R.drawable.demo)
|
||||
.apply(bitmapTransform(new BlurTransformation(25)))
|
||||
.into((ImageView) findViewById(R.id.image));
|
||||
.apply(RequestOptions.bitmapTransform(BlurTransformation(25, 3)))
|
||||
.into(imageView)
|
||||
```
|
||||
|
||||
## Advanced Step 3
|
||||
|
||||
You can set a multiple transformations.
|
||||
|
||||
```java
|
||||
MultiTransformation multi = new MultiTransformation(
|
||||
new BlurTransformation(25),
|
||||
new RoundedCornersTransformation(128, 0, RoundedCornersTransformation.CornerType.BOTTOM))))
|
||||
```kotlin
|
||||
val multi = MultiTransformation<Bitmap>(
|
||||
BlurTransformation(25),
|
||||
RoundedCornersTransformation(128, 0, CornerType.BOTTOM))))
|
||||
Glide.with(this).load(R.drawable.demo)
|
||||
.apply(bitmapTransform(multi))
|
||||
.into((ImageView) findViewById(R.id.image));
|
||||
.apply(RequestOptions.bitmapTransform(multi))
|
||||
.into(imageView))
|
||||
```
|
||||
|
||||
# Step 4
|
||||
|
||||
If you are using `SupportRSBlurTransformation`.
|
||||
|
||||
```groovy
|
||||
android {
|
||||
//...
|
||||
defaultConfig {
|
||||
//...
|
||||
renderscriptTargetApi YOUR_TARGET_SDK_VERSION as int
|
||||
renderscriptSupportModeEnabled true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Transformations
|
||||
|
||||
### Crop
|
||||
`CropTransformation`, `CropCircleTransformation`, `CropSquareTransformation`,
|
||||
`RoundedCornersTransformation`
|
||||
- `CropTransformation`
|
||||
- `CropCircleTransformation`
|
||||
- `CropCircleWithBorderTransformation`
|
||||
- `CropSquareTransformation`
|
||||
- `RoundedCornersTransformation`
|
||||
|
||||
### Color
|
||||
`ColorFilterTransformation`, `GrayscaleTransformation`
|
||||
- `ColorFilterTransformation`
|
||||
- `GrayscaleTransformation`
|
||||
|
||||
### Blur
|
||||
`BlurTransformation`
|
||||
- `BlurTransformation`
|
||||
|
||||
### Mask
|
||||
`MaskTransformation`
|
||||
- `MaskTransformation`
|
||||
|
||||
### GPU Filter (use [GPUImage](https://github.com/CyberAgent/android-gpuimage))
|
||||
**Will require add dependencies for GPUImage.**
|
||||
|
||||
`ToonFilterTransformation`, `SepiaFilterTransformation`, `ContrastFilterTransformation`
|
||||
`InvertFilterTransformation`, `PixelationFilterTransformation`, `SketchFilterTransformation`
|
||||
`SwirlFilterTransformation`, `BrightnessFilterTransformation`, `KuwaharaFilterTransformation`
|
||||
`VignetteFilterTransformation`
|
||||
- `ToonFilterTransformation`
|
||||
- `SepiaFilterTransformation`
|
||||
- `ContrastFilterTransformation`
|
||||
- `InvertFilterTransformation`
|
||||
- `PixelationFilterTransformation`
|
||||
- `SketchFilterTransformation`
|
||||
- `SwirlFilterTransformation`
|
||||
- `BrightnessFilterTransformation`
|
||||
- `KuwaharaFilterTransformation`
|
||||
- `VignetteFilterTransformation`
|
||||
|
||||
|
||||
Applications using Glide Transformations
|
||||
@@ -110,10 +135,11 @@ Contributions
|
||||
|
||||
Any contributions are welcome!
|
||||
|
||||
Contributers
|
||||
Contributors
|
||||
-------
|
||||
|
||||
* [start141](https://github.com/start141)
|
||||
* [squeeish](https://github.com/squeeish)
|
||||
|
||||
Thanks
|
||||
-------
|
||||
@@ -123,7 +149,7 @@ Thanks
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright 2018 Wasabeef
|
||||
Copyright (C) 2020 Wasabeef
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
15
build.gradle
15
build.gradle
@@ -1,13 +1,21 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext {
|
||||
kotlin_version = '1.3.72'
|
||||
glide_version = '4.11.0'
|
||||
gpuimage_version = '2.1.0'
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.0.1'
|
||||
classpath 'com.novoda:bintray-release:0.8.0'
|
||||
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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +23,5 @@ allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
@@ -1,63 +1,41 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
android {
|
||||
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()
|
||||
versionCode VERSION_CODE as int
|
||||
versionName VERSION_NAME
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file(keyStoreProperty)
|
||||
keyAlias keyAliasProperty
|
||||
storePassword keyStorePasswordProperty
|
||||
keyPassword keyAliasPasswordProperty
|
||||
}
|
||||
}
|
||||
// SigningConfigs
|
||||
apply from: '../signingConfigs/debug.gradle', to: android
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
debuggable true
|
||||
zipAlignEnabled true
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
release {
|
||||
debuggable false
|
||||
zipAlignEnabled true
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
shrinkResources true
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def getKeyStoreProperty() {
|
||||
return hasProperty('WASABEEF_KEYSTORE') ? WASABEEF_KEYSTORE : "debug.keystore"
|
||||
}
|
||||
|
||||
def getKeyAliasProperty() {
|
||||
return hasProperty('WASABEEF_KEYALIAS') ? WASABEEF_KEYALIAS : "android"
|
||||
}
|
||||
|
||||
def getKeyStorePasswordProperty() {
|
||||
return hasProperty('WASABEEF_KEYSTOREPASSWORD') ? WASABEEF_KEYSTOREPASSWORD : "androiddebugkey"
|
||||
}
|
||||
|
||||
def getKeyAliasPasswordProperty() {
|
||||
return hasProperty('WASABEEF_KEYALIASPASSWORD') ? WASABEEF_KEYALIASPASSWORD : "android"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':transformations')
|
||||
implementation "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
|
||||
annotationProcessor "com.github.bumptech.glide:compiler:${GLIDE_VERSION}"
|
||||
implementation "jp.co.cyberagent.android.gpuimage:gpuimage-library:${GPUIMAGE_VERSION}"
|
||||
implementation "com.android.support:appcompat-v7:${SUPPORT_PACKAGE_VERSION}"
|
||||
implementation "com.android.support:recyclerview-v7:${SUPPORT_PACKAGE_VERSION}"
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta4'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation "com.github.bumptech.glide:glide:$glide_version"
|
||||
kapt "com.github.bumptech.glide:compiler:$glide_version"
|
||||
implementation "jp.co.cyberagent.android:gpuimage:$gpuimage_version"
|
||||
implementation "androidx.appcompat:appcompat:1.3.0-alpha02"
|
||||
implementation "androidx.recyclerview:recyclerview:1.2.0-alpha05"
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
|
||||
}
|
||||
|
@@ -1,22 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="jp.wasabeef.example.glide"
|
||||
>
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="jp.wasabeef.example.glide">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme"
|
||||
>
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
>
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package jp.wasabeef.example.glide;
|
||||
package jp.wasabeef.example.glide
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
* Copyright (C) 2020 Wasabeef
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,12 +16,8 @@ package jp.wasabeef.example.glide;
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources
|
||||
|
||||
public class Utils {
|
||||
val Float.px: Float get() = (this * Resources.getSystem().displayMetrics.density)
|
||||
|
||||
public static int dip2px(Context context, float dp) {
|
||||
float scale = context.getResources().getDisplayMetrics().density;
|
||||
return (int) (dp * scale + 0.5f);
|
||||
}
|
||||
}
|
||||
val Int.px: Int get() = ((this * Resources.getSystem().displayMetrics.density).toInt())
|
@@ -1,45 +0,0 @@
|
||||
package jp.wasabeef.example.glide;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import jp.wasabeef.example.glide.MainAdapter.Type;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@Override protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
|
||||
List<Type> dataSet = new ArrayList<>();
|
||||
dataSet.add(Type.Mask);
|
||||
dataSet.add(Type.NinePatchMask);
|
||||
dataSet.add(Type.CropTop);
|
||||
dataSet.add(Type.CropCenter);
|
||||
dataSet.add(Type.CropBottom);
|
||||
dataSet.add(Type.CropSquare);
|
||||
dataSet.add(Type.CropCircle);
|
||||
dataSet.add(Type.ColorFilter);
|
||||
dataSet.add(Type.Grayscale);
|
||||
dataSet.add(Type.RoundedCorners);
|
||||
dataSet.add(Type.Blur);
|
||||
dataSet.add(Type.Toon);
|
||||
dataSet.add(Type.Sepia);
|
||||
dataSet.add(Type.Contrast);
|
||||
dataSet.add(Type.Invert);
|
||||
dataSet.add(Type.Pixel);
|
||||
dataSet.add(Type.Sketch);
|
||||
dataSet.add(Type.Swirl);
|
||||
dataSet.add(Type.Brightness);
|
||||
dataSet.add(Type.Kuawahara);
|
||||
dataSet.add(Type.Vignette);
|
||||
|
||||
recyclerView.setAdapter(new MainAdapter(this, dataSet));
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package jp.wasabeef.example.glide
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import jp.wasabeef.example.glide.MainAdapter.Type.*
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
findViewById<RecyclerView>(R.id.list).apply {
|
||||
layoutManager = LinearLayoutManager(context)
|
||||
adapter = MainAdapter(context, mutableListOf(
|
||||
Mask, NinePatchMask, RoundedCorners, CropTop, CropCenter, CropBottom, CropSquare, CropCircle,
|
||||
CropCircleWithBorder, Grayscale, BlurLight, BlurDeep, Toon, Sepia, Contrast, Invert,
|
||||
Pixel, Sketch, Swirl, Brightness, Kuawahara, Vignette
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,247 +0,0 @@
|
||||
package jp.wasabeef.example.glide;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PointF;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.MultiTransformation;
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||
import java.util.List;
|
||||
import jp.wasabeef.glide.transformations.BlurTransformation;
|
||||
import jp.wasabeef.glide.transformations.ColorFilterTransformation;
|
||||
import jp.wasabeef.glide.transformations.CropCircleTransformation;
|
||||
import jp.wasabeef.glide.transformations.CropSquareTransformation;
|
||||
import jp.wasabeef.glide.transformations.CropTransformation;
|
||||
import jp.wasabeef.glide.transformations.CropTransformation.CropType;
|
||||
import jp.wasabeef.glide.transformations.GrayscaleTransformation;
|
||||
import jp.wasabeef.glide.transformations.MaskTransformation;
|
||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||
import jp.wasabeef.glide.transformations.gpu.BrightnessFilterTransformation;
|
||||
import jp.wasabeef.glide.transformations.gpu.ContrastFilterTransformation;
|
||||
import jp.wasabeef.glide.transformations.gpu.InvertFilterTransformation;
|
||||
import jp.wasabeef.glide.transformations.gpu.KuwaharaFilterTransformation;
|
||||
import jp.wasabeef.glide.transformations.gpu.PixelationFilterTransformation;
|
||||
import jp.wasabeef.glide.transformations.gpu.SepiaFilterTransformation;
|
||||
import jp.wasabeef.glide.transformations.gpu.SketchFilterTransformation;
|
||||
import jp.wasabeef.glide.transformations.gpu.SwirlFilterTransformation;
|
||||
import jp.wasabeef.glide.transformations.gpu.ToonFilterTransformation;
|
||||
import jp.wasabeef.glide.transformations.gpu.VignetteFilterTransformation;
|
||||
|
||||
import static com.bumptech.glide.request.RequestOptions.bitmapTransform;
|
||||
import static com.bumptech.glide.request.RequestOptions.overrideOf;
|
||||
|
||||
/**
|
||||
* Created by Wasabeef on 2015/01/11.
|
||||
*/
|
||||
public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
|
||||
|
||||
private Context context;
|
||||
private List<Type> dataSet;
|
||||
|
||||
enum Type {
|
||||
Mask,
|
||||
NinePatchMask,
|
||||
CropTop,
|
||||
CropCenter,
|
||||
CropBottom,
|
||||
CropSquare,
|
||||
CropCircle,
|
||||
ColorFilter,
|
||||
Grayscale,
|
||||
RoundedCorners,
|
||||
Blur,
|
||||
Toon,
|
||||
Sepia,
|
||||
Contrast,
|
||||
Invert,
|
||||
Pixel,
|
||||
Sketch,
|
||||
Swirl,
|
||||
Brightness,
|
||||
Kuawahara,
|
||||
Vignette
|
||||
}
|
||||
|
||||
public MainAdapter(Context context, List<Type> dataSet) {
|
||||
this.context = context;
|
||||
this.dataSet = dataSet;
|
||||
}
|
||||
|
||||
@Override public MainAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View v = LayoutInflater.from(context).inflate(R.layout.layout_list_item, parent, false);
|
||||
return new ViewHolder(v);
|
||||
}
|
||||
|
||||
@Override public void onBindViewHolder(MainAdapter.ViewHolder holder, int position) {
|
||||
switch (dataSet.get(position)) {
|
||||
case Mask: {
|
||||
int width = Utils.dip2px(context, 266.66f);
|
||||
int height = Utils.dip2px(context, 252.66f);
|
||||
Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(overrideOf(width, height))
|
||||
.apply(bitmapTransform(new MultiTransformation<>(new CenterCrop(),
|
||||
new MaskTransformation(R.drawable.mask_starfish))))
|
||||
.into(holder.image);
|
||||
break;
|
||||
}
|
||||
case NinePatchMask: {
|
||||
int width = Utils.dip2px(context, 300.0f);
|
||||
int height = Utils.dip2px(context, 200.0f);
|
||||
Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(overrideOf(width, height))
|
||||
.apply(bitmapTransform(new MultiTransformation<>(new CenterCrop(),
|
||||
new MaskTransformation(R.drawable.mask_chat_right))))
|
||||
.into(holder.image);
|
||||
break;
|
||||
}
|
||||
case CropTop:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(
|
||||
new CropTransformation(Utils.dip2px(context, 300), Utils.dip2px(context, 100),
|
||||
CropType.TOP)))
|
||||
.into(holder.image);
|
||||
break;
|
||||
case CropCenter:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(
|
||||
new CropTransformation(Utils.dip2px(context, 300), Utils.dip2px(context, 100), CropType.CENTER)))
|
||||
.into(holder.image);
|
||||
break;
|
||||
case CropBottom:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(
|
||||
new CropTransformation(Utils.dip2px(context, 300), Utils.dip2px(context, 100),
|
||||
CropType.BOTTOM)))
|
||||
.into(holder.image);
|
||||
|
||||
break;
|
||||
case CropSquare:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(new CropSquareTransformation()))
|
||||
.into(holder.image);
|
||||
break;
|
||||
case CropCircle:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(new CropCircleTransformation()))
|
||||
.into(holder.image);
|
||||
break;
|
||||
case ColorFilter:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(new ColorFilterTransformation(Color.argb(80, 255, 0, 0))))
|
||||
.into(holder.image);
|
||||
break;
|
||||
case Grayscale:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(new GrayscaleTransformation()))
|
||||
.into(holder.image);
|
||||
break;
|
||||
case RoundedCorners:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(new RoundedCornersTransformation(45, 0,
|
||||
RoundedCornersTransformation.CornerType.BOTTOM)))
|
||||
.into(holder.image);
|
||||
break;
|
||||
case Blur:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(new BlurTransformation(25)))
|
||||
.into(holder.image);
|
||||
break;
|
||||
case Toon:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(new ToonFilterTransformation()))
|
||||
.into(holder.image);
|
||||
break;
|
||||
case Sepia:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(new SepiaFilterTransformation()))
|
||||
.into(holder.image);
|
||||
break;
|
||||
case Contrast:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(new ContrastFilterTransformation(2.0f)))
|
||||
.into(holder.image);
|
||||
break;
|
||||
case Invert:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(new InvertFilterTransformation()))
|
||||
.into(holder.image);
|
||||
break;
|
||||
case Pixel:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(new PixelationFilterTransformation(20)))
|
||||
.into(holder.image);
|
||||
break;
|
||||
case Sketch:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(new SketchFilterTransformation()))
|
||||
.into(holder.image);
|
||||
break;
|
||||
case Swirl:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(
|
||||
new SwirlFilterTransformation(0.5f, 1.0f, new PointF(0.5f, 0.5f))).dontAnimate())
|
||||
.into(holder.image);
|
||||
break;
|
||||
case Brightness:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(new BrightnessFilterTransformation(0.5f)).dontAnimate())
|
||||
.into(holder.image);
|
||||
break;
|
||||
case Kuawahara:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(new KuwaharaFilterTransformation(25)).dontAnimate())
|
||||
.into(holder.image);
|
||||
break;
|
||||
case Vignette:
|
||||
Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(new VignetteFilterTransformation(new PointF(0.5f, 0.5f),
|
||||
new float[] { 0.0f, 0.0f, 0.0f }, 0f, 0.75f)).dontAnimate())
|
||||
.into(holder.image);
|
||||
break;
|
||||
}
|
||||
holder.title.setText(dataSet.get(position).name());
|
||||
}
|
||||
|
||||
@Override public int getItemCount() {
|
||||
return dataSet.size();
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public ImageView image;
|
||||
public TextView title;
|
||||
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
image = (ImageView) itemView.findViewById(R.id.image);
|
||||
title = (TextView) itemView.findViewById(R.id.title);
|
||||
}
|
||||
}
|
||||
}
|
203
example/src/main/java/jp/wasabeef/example/glide/MainAdapter.kt
Normal file
203
example/src/main/java/jp/wasabeef/example/glide/MainAdapter.kt
Normal file
@@ -0,0 +1,203 @@
|
||||
package jp.wasabeef.example.glide
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Color
|
||||
import android.graphics.PointF
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.MultiTransformation
|
||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop
|
||||
import com.bumptech.glide.request.RequestOptions.bitmapTransform
|
||||
import com.bumptech.glide.request.RequestOptions.overrideOf
|
||||
import jp.wasabeef.example.glide.MainAdapter.Type.*
|
||||
import jp.wasabeef.glide.transformations.*
|
||||
import jp.wasabeef.glide.transformations.CropTransformation.CropType
|
||||
import jp.wasabeef.glide.transformations.gpu.*
|
||||
import jp.wasabeef.glide.transformations.internal.Utils
|
||||
|
||||
/**
|
||||
* Created by Wasabeef on 2015/01/11.
|
||||
*/
|
||||
class MainAdapter(
|
||||
private val context: Context,
|
||||
private val dataSet: MutableList<Type>
|
||||
) : RecyclerView.Adapter<MainAdapter.ViewHolder>() {
|
||||
|
||||
enum class Type {
|
||||
Mask,
|
||||
NinePatchMask,
|
||||
CropTop,
|
||||
CropCenter,
|
||||
CropBottom,
|
||||
CropSquare,
|
||||
CropCircle,
|
||||
CropCircleWithBorder,
|
||||
ColorFilter,
|
||||
Grayscale,
|
||||
RoundedCorners,
|
||||
BlurLight,
|
||||
BlurDeep,
|
||||
Toon,
|
||||
Sepia,
|
||||
Contrast,
|
||||
Invert,
|
||||
Pixel,
|
||||
Sketch,
|
||||
Swirl,
|
||||
Brightness,
|
||||
Kuawahara,
|
||||
Vignette
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet.size
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val v = LayoutInflater.from(context).inflate(R.layout.layout_list_item, parent, false)
|
||||
return ViewHolder(v)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
|
||||
when (dataSet[position]) {
|
||||
Mask -> {
|
||||
Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(overrideOf(266.px, 252.px))
|
||||
.apply(bitmapTransform(MultiTransformation<Bitmap>(CenterCrop(),
|
||||
MaskTransformation(R.drawable.mask_starfish))))
|
||||
.into(holder.image)
|
||||
}
|
||||
NinePatchMask -> {
|
||||
Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(overrideOf(300.px, 200.px))
|
||||
.apply(bitmapTransform(MultiTransformation<Bitmap>(CenterCrop(),
|
||||
MaskTransformation(R.drawable.mask_chat_right))))
|
||||
.into(holder.image)
|
||||
}
|
||||
|
||||
CropTop -> Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(CropTransformation(300.px, 100.px, CropType.TOP)))
|
||||
.into(holder.image)
|
||||
|
||||
CropCenter -> Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(CropTransformation(300.px, 100.px, CropType.CENTER)))
|
||||
.into(holder.image)
|
||||
|
||||
CropBottom -> Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(CropTransformation(300.px, 100.px, CropType.BOTTOM)))
|
||||
.into(holder.image)
|
||||
|
||||
CropSquare -> Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(CropSquareTransformation()))
|
||||
.into(holder.image)
|
||||
|
||||
CropCircle -> Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(CropCircleTransformation()))
|
||||
.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)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(ColorFilterTransformation(Color.argb(80, 255, 0, 0))))
|
||||
.into(holder.image)
|
||||
|
||||
Grayscale -> Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(GrayscaleTransformation()))
|
||||
.into(holder.image)
|
||||
|
||||
RoundedCorners -> Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(RoundedCornersTransformation(120, 0,
|
||||
RoundedCornersTransformation.CornerType.DIAGONAL_FROM_TOP_LEFT)))
|
||||
.into(holder.image)
|
||||
|
||||
BlurLight -> Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(BlurTransformation(25)))
|
||||
.into(holder.image)
|
||||
|
||||
BlurDeep -> Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(BlurTransformation(25, 8)))
|
||||
.into(holder.image)
|
||||
|
||||
Toon -> Glide.with(context)
|
||||
.load(R.drawable.demo)
|
||||
.apply(bitmapTransform(ToonFilterTransformation()))
|
||||
.into(holder.image)
|
||||
|
||||
Sepia -> Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(SepiaFilterTransformation()))
|
||||
.into(holder.image)
|
||||
|
||||
Contrast -> Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(ContrastFilterTransformation(2.0f)))
|
||||
.into(holder.image)
|
||||
|
||||
Invert -> Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(InvertFilterTransformation()))
|
||||
.into(holder.image)
|
||||
|
||||
Pixel -> Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(PixelationFilterTransformation(20f)))
|
||||
.into(holder.image)
|
||||
|
||||
Sketch -> Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(SketchFilterTransformation()))
|
||||
.into(holder.image)
|
||||
|
||||
Swirl -> Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(
|
||||
SwirlFilterTransformation(0.5f, 1.0f, PointF(0.5f, 0.5f))).dontAnimate())
|
||||
.into(holder.image)
|
||||
|
||||
Brightness -> Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(BrightnessFilterTransformation(0.5f)).dontAnimate())
|
||||
.into(holder.image)
|
||||
|
||||
Kuawahara -> Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(KuwaharaFilterTransformation(25)).dontAnimate())
|
||||
.into(holder.image)
|
||||
|
||||
Vignette -> Glide.with(context)
|
||||
.load(R.drawable.check)
|
||||
.apply(bitmapTransform(VignetteFilterTransformation(PointF(0.5f, 0.5f),
|
||||
floatArrayOf(0.0f, 0.0f, 0.0f), 0f, 0.75f)).dontAnimate())
|
||||
.into(holder.image)
|
||||
}
|
||||
holder.title.text = dataSet[position].name
|
||||
}
|
||||
|
||||
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
var image: ImageView = itemView.findViewById(R.id.image)
|
||||
var title: TextView = itemView.findViewById(R.id.title)
|
||||
}
|
||||
}
|
@@ -1,22 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
/>
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
@@ -1,10 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
@@ -19,8 +17,8 @@
|
||||
app:layout_constraintBottom_toTopOf="@+id/title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
/>
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -30,6 +28,5 @@
|
||||
android:layout_marginStart="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
/>
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
@@ -1,26 +1,16 @@
|
||||
VERSION_NAME=3.1.1
|
||||
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
org.gradle.parallel=true
|
||||
org.gradle.daemon=true
|
||||
org.gradle.configureondemand=true
|
||||
org.gradle.caching=true
|
||||
android.enableBuildCache=true
|
||||
android.useAndroidX=true
|
||||
# Use R8 instead of ProGuard for code shrinking.
|
||||
android.enableR8.fullMode=true
|
||||
|
||||
VERSION_NAME=4.3.0
|
||||
VERSION_CODE=421
|
||||
GROUP=jp.wasabeef
|
||||
ARTIFACT_ID=glide-transformations
|
||||
|
||||
COMPILE_SDK_VERSION=27
|
||||
BUILD_TOOLS_VERSION=27.0.3
|
||||
TARGET_SDK_VERSION=27
|
||||
MIN_SDK_VERSION=14
|
||||
|
||||
POM_DESCRIPTION=which provides simple Tranformations to Glide
|
||||
POM_URL=https://github.com/wasabeef/glide-transformations
|
||||
POM_SCM_URL=scm:git@github.com:wasabeef/glide-transformations.git
|
||||
POM_SCM_CONNECTION=scm:git@github.com:wasabeef/glide-transformations.git
|
||||
POM_SCM_DEV_CONNECTION=scm:git@github.com:wasabeef/glide-transformations.git
|
||||
POM_LICENCE_NAME=The Apache Software License, Version 2.0
|
||||
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
POM_LICENCE_DIST=repo
|
||||
POM_DEVELOPER_ID=wasabeef
|
||||
POM_DEVELOPER_NAME=Wasabeef
|
||||
POM_DEVELOPER_EMAIL=dadadada.chop@gmail.com
|
||||
POM_DEVELOPER_URL=wasabeef.jp
|
||||
ISSUE_URL=https://github.com/wasabeef/glide-transformations/issues
|
||||
|
||||
SUPPORT_PACKAGE_VERSION=27.0.2
|
||||
GLIDE_VERSION=4.6.1
|
||||
GPUIMAGE_VERSION=1.4.1
|
||||
COMPILE_SDK_VERSION=30
|
||||
TARGET_SDK_VERSION=30
|
||||
MIN_SDK_VERSION=21
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-bin.zip
|
||||
|
53
gradlew
vendored
53
gradlew
vendored
@@ -1,5 +1,21 @@
|
||||
#!/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
|
||||
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
|
||||
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.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
@@ -66,6 +82,7 @@ esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
@@ -109,10 +126,11 @@ if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
@@ -138,19 +156,19 @@ if $cygwin ; then
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
@@ -159,14 +177,9 @@ save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
43
gradlew.bat
vendored
43
gradlew.bat
vendored
@@ -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
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@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
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@@ -35,7 +54,7 @@ goto fail
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
@@ -45,28 +64,14 @@ echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
14
signingConfigs/debug.gradle
Normal file
14
signingConfigs/debug.gradle
Normal file
@@ -0,0 +1,14 @@
|
||||
signingConfigs {
|
||||
debug {
|
||||
storeFile file("debug.keystore")
|
||||
storePassword "android"
|
||||
keyAlias "androiddebugkey"
|
||||
keyPassword "android"
|
||||
}
|
||||
}
|
||||
|
||||
// $ keytool -v -list -keystore
|
||||
// Certificate fingerprints:
|
||||
// MD5: 28:22:7C:A4:B9:2F:6E:C7:D5:58:62:48:EB:7E:82:C3
|
||||
// SHA1: 94:25:A9:50:9C:0E:AE:AA:00:37:5E:D6:71:E3:BC:ED:17:E5:0C:A3
|
||||
// SHA256: 04:92:39:09:3D:1C:B6:16:BE:55:58:A3:5F:3B:BB:CB:0B:E7:F1:DA:AA:26:C5:2D:BD:2F:44:CF:AE:47:CF:87
|
BIN
signingConfigs/debug.keystore
Normal file
BIN
signingConfigs/debug.keystore
Normal file
Binary file not shown.
@@ -1,34 +1,41 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'com.novoda.bintray-release'
|
||||
|
||||
android {
|
||||
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
|
||||
|
||||
consumerProguardFiles 'proguard-rules.txt'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "com.github.bumptech.glide:glide:${GLIDE_VERSION}"
|
||||
annotationProcessor "com.github.bumptech.glide:compiler:${GLIDE_VERSION}"
|
||||
compileOnly "jp.co.cyberagent.android.gpuimage:gpuimage-library:${GPUIMAGE_VERSION}"
|
||||
implementation "com.github.bumptech.glide:glide:$glide_version"
|
||||
annotationProcessor "com.github.bumptech.glide:compiler:$glide_version"
|
||||
compileOnly "jp.co.cyberagent.android:gpuimage:$gpuimage_version"
|
||||
}
|
||||
|
||||
publish {
|
||||
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
|
||||
ext {
|
||||
bintrayRepo = 'maven'
|
||||
bintrayName = 'glide-transformations'
|
||||
bintrayUserOrg = 'wasabeef'
|
||||
publishedGroupId = 'jp.wasabeef'
|
||||
libraryName = 'glide-transformations'
|
||||
artifact = 'glide-transformations'
|
||||
libraryDescription = 'Which provides simple Transformations to Glide'
|
||||
siteUrl = 'https://github.com/wasabeef/glide-transformations'
|
||||
gitUrl = 'https://github.com/wasabeef/glide-transformations.git'
|
||||
issueUrl = 'https://github.com/wasabeef/glide-transformations/issues'
|
||||
libraryVersion = VERSION_NAME
|
||||
developerId = 'wasabeef'
|
||||
developerName = 'Wasabeef'
|
||||
developerEmail = 'dadadada.chop@gmail.com'
|
||||
licenseName = 'The Apache Software License, Version 2.0'
|
||||
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
||||
allLicenses = ["Apache-2.0"]
|
||||
}
|
||||
|
||||
apply from: 'https://gist.githubusercontent.com/wasabeef/cf14805bee509baf7461974582f17d26/raw/bintray-v1.gradle'
|
||||
apply from: 'https://gist.githubusercontent.com/wasabeef/cf14805bee509baf7461974582f17d26/raw/install-v1.gradle'
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
-keep public class * implements com.bumptech.glide.module.GlideModule
|
||||
-keep public class * extends com.bumptech.glide.module.AppGlideModule
|
||||
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
|
||||
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
|
||||
**[] $VALUES;
|
||||
public *;
|
||||
}
|
||||
|
@@ -1 +1 @@
|
||||
<manifest package="jp.wasabeef.glide.transformations"></manifest>
|
||||
<manifest package="jp.wasabeef.glide.transformations" />
|
||||
|
@@ -1,15 +1,15 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
* Copyright (C) 2020 Wasabeef
|
||||
* Copyright 2014 Google, Inc. All rights reserved.
|
||||
*
|
||||
* <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.
|
||||
@@ -19,7 +19,9 @@ package jp.wasabeef.glide.transformations;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.Transformation;
|
||||
import com.bumptech.glide.load.engine.Resource;
|
||||
@@ -27,13 +29,15 @@ import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapResource;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.util.Util;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
public abstract class BitmapTransformation implements Transformation<Bitmap> {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public final Resource<Bitmap> transform(Context context, Resource<Bitmap> resource, int outWidth,
|
||||
int outHeight) {
|
||||
public final Resource<Bitmap> transform(@NonNull Context context, @NonNull Resource<Bitmap> resource,
|
||||
int outWidth, int outHeight) {
|
||||
if (!Util.isValidDimensions(outWidth, outHeight)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Cannot apply transformation on width: " + outWidth + " or height: " + outHeight
|
||||
@@ -54,12 +58,19 @@ public abstract class BitmapTransformation implements Transformation<Bitmap> {
|
||||
return result;
|
||||
}
|
||||
|
||||
void setCanvasBitmapDensity(@NonNull Bitmap toTransform, @NonNull Bitmap canvasBitmap) {
|
||||
canvasBitmap.setDensity(toTransform.getDensity());
|
||||
}
|
||||
|
||||
protected abstract Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@NonNull Bitmap toTransform, int outWidth, int outHeight);
|
||||
|
||||
@Override public abstract void updateDiskCacheKey(MessageDigest messageDigest);
|
||||
@Override
|
||||
public abstract void updateDiskCacheKey(@NonNull MessageDigest messageDigest);
|
||||
|
||||
@Override public abstract boolean equals(Object o);
|
||||
@Override
|
||||
public abstract boolean equals(Object o);
|
||||
|
||||
@Override public abstract int hashCode();
|
||||
@Override
|
||||
public abstract int hashCode();
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -20,11 +20,14 @@ import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Build;
|
||||
import android.renderscript.RSRuntimeException;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
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;
|
||||
|
||||
@@ -33,13 +36,12 @@ public class BlurTransformation extends BitmapTransformation {
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.BlurTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
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);
|
||||
@@ -54,7 +56,8 @@ public class BlurTransformation extends BitmapTransformation {
|
||||
this.sampling = sampling;
|
||||
}
|
||||
|
||||
@Override protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@Override
|
||||
protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@NonNull Bitmap toTransform, int outWidth, int outHeight) {
|
||||
|
||||
int width = toTransform.getWidth();
|
||||
@@ -64,38 +67,42 @@ public class BlurTransformation extends BitmapTransformation {
|
||||
|
||||
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 = RSBlur.blur(context, bitmap, radius);
|
||||
} catch (RSRuntimeException e) {
|
||||
bitmap = FastBlur.blur(bitmap, radius, true);
|
||||
}
|
||||
} else {
|
||||
bitmap = FastBlur.blur(bitmap, radius, true);
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BlurTransformation(radius=" + radius + ", sampling=" + sampling + ")";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
return o instanceof BlurTransformation;
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof BlurTransformation &&
|
||||
((BlurTransformation) o).radius == radius &&
|
||||
((BlurTransformation) o).sampling == sampling;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return ID.hashCode();
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode() + radius * 1000 + sampling * 10;
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID + radius + sampling).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -22,8 +22,11 @@ import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
public class ColorFilterTransformation extends BitmapTransformation {
|
||||
@@ -31,15 +34,15 @@ public class ColorFilterTransformation extends BitmapTransformation {
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.ColorFilterTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
private int color;
|
||||
private final int color;
|
||||
|
||||
public ColorFilterTransformation(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@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();
|
||||
@@ -48,6 +51,8 @@ public class ColorFilterTransformation extends BitmapTransformation {
|
||||
toTransform.getConfig() != null ? toTransform.getConfig() : Bitmap.Config.ARGB_8888;
|
||||
Bitmap bitmap = pool.get(width, height, config);
|
||||
|
||||
setCanvasBitmapDensity(toTransform, bitmap);
|
||||
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
Paint paint = new Paint();
|
||||
paint.setAntiAlias(true);
|
||||
@@ -57,19 +62,24 @@ public class ColorFilterTransformation extends BitmapTransformation {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ColorFilterTransformation(color=" + color + ")";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
return o instanceof ColorFilterTransformation;
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof ColorFilterTransformation &&
|
||||
((ColorFilterTransformation) o).color == color;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return ID.hashCode();
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode() + color * 10;
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID + color).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -18,10 +18,13 @@ package jp.wasabeef.glide.transformations;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
import com.bumptech.glide.load.resource.bitmap.TransformationUtils;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
/**
|
||||
@@ -33,26 +36,30 @@ public class CropCircleTransformation extends BitmapTransformation {
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.CropCircleTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
@Override protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@Override
|
||||
protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@NonNull Bitmap toTransform, int outWidth, int outHeight) {
|
||||
return TransformationUtils.circleCrop(pool, toTransform, outWidth, outHeight);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CropCircleTransformation()";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof CropCircleTransformation;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode();
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,96 @@
|
||||
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) 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 CropCircleWithBorderTransformation extends BitmapTransformation {
|
||||
|
||||
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID = "jp.wasabeef.glide.transformations.CropCircleWithBorderTransformation." + VERSION;
|
||||
|
||||
private final int borderSize;
|
||||
private final int borderColor;
|
||||
|
||||
|
||||
public CropCircleWithBorderTransformation() {
|
||||
this.borderSize = Utils.toDp(4);
|
||||
this.borderColor = Color.BLACK;
|
||||
}
|
||||
|
||||
public CropCircleWithBorderTransformation(int borderSize, @ColorInt int borderColor) {
|
||||
this.borderSize = borderSize;
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@NonNull Bitmap toTransform, int outWidth, int outHeight) {
|
||||
|
||||
Bitmap bitmap = TransformationUtils.circleCrop(pool, toTransform, outWidth, outHeight);
|
||||
|
||||
setCanvasBitmapDensity(toTransform, bitmap);
|
||||
|
||||
Paint paint = new Paint();
|
||||
paint.setColor(borderColor);
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
paint.setStrokeWidth(borderSize);
|
||||
paint.setAntiAlias(true);
|
||||
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
canvas.drawCircle(
|
||||
outWidth / 2f,
|
||||
outHeight / 2f,
|
||||
Math.max(outWidth, outHeight) / 2f - borderSize / 2f,
|
||||
paint
|
||||
);
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID + borderSize + borderColor).getBytes(CHARSET));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof CropCircleWithBorderTransformation &&
|
||||
((CropCircleWithBorderTransformation) o).borderSize == borderSize &&
|
||||
((CropCircleWithBorderTransformation) o).borderColor == borderColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode() + borderSize * 100 + borderColor + 10;
|
||||
}
|
||||
}
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -18,9 +18,12 @@ package jp.wasabeef.glide.transformations;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
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;
|
||||
|
||||
public class CropSquareTransformation extends BitmapTransformation {
|
||||
@@ -28,29 +31,33 @@ public class CropSquareTransformation extends BitmapTransformation {
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.CropSquareTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
private int size;
|
||||
|
||||
@Override protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@Override
|
||||
protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@NonNull Bitmap toTransform, int outWidth, int outHeight) {
|
||||
this.size = Math.max(outWidth, outHeight);
|
||||
return TransformationUtils.centerCrop(pool, toTransform, size, size);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CropSquareTransformation(size=" + size + ")";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
return o instanceof CropSquareTransformation;
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof CropSquareTransformation && ((CropSquareTransformation) o).size == size;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return ID.hashCode();
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode() + size * 10;
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID + size).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -20,15 +20,17 @@ import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.RectF;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
public class CropTransformation extends BitmapTransformation {
|
||||
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID = "jp.wasabeef.glide.transformations.CropTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
public enum CropType {
|
||||
TOP,
|
||||
@@ -51,7 +53,8 @@ public class CropTransformation extends BitmapTransformation {
|
||||
this.cropType = cropType;
|
||||
}
|
||||
|
||||
@Override protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@Override
|
||||
protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@NonNull Bitmap toTransform, int outWidth, int outHeight) {
|
||||
|
||||
width = width == 0 ? toTransform.getWidth() : width;
|
||||
@@ -73,29 +76,14 @@ public class CropTransformation extends BitmapTransformation {
|
||||
float top = getTop(scaledHeight);
|
||||
RectF targetRect = new RectF(left, top, left + scaledWidth, top + scaledHeight);
|
||||
|
||||
setCanvasBitmapDensity(toTransform, bitmap);
|
||||
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
canvas.drawBitmap(toTransform, null, targetRect, null);
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return "CropTransformation(width=" + width + ", height=" + height + ", cropType=" + cropType
|
||||
+ ")";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
return o instanceof CropTransformation;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return ID.hashCode();
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
}
|
||||
|
||||
private float getTop(float scaledHeight) {
|
||||
switch (cropType) {
|
||||
case TOP:
|
||||
@@ -108,4 +96,27 @@ public class CropTransformation extends BitmapTransformation {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CropTransformation(width=" + width + ", height=" + height + ", cropType=" + cropType + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof CropTransformation &&
|
||||
((CropTransformation) o).width == width &&
|
||||
((CropTransformation) o).height == height &&
|
||||
((CropTransformation) o).cropType == cropType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode() + width * 100000 + height * 1000 + cropType.ordinal() * 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID + width + height + cropType).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -22,8 +22,11 @@ import android.graphics.Canvas;
|
||||
import android.graphics.ColorMatrix;
|
||||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
public class GrayscaleTransformation extends BitmapTransformation {
|
||||
@@ -31,9 +34,9 @@ public class GrayscaleTransformation extends BitmapTransformation {
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.GrayscaleTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
@Override protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@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();
|
||||
@@ -42,6 +45,8 @@ public class GrayscaleTransformation extends BitmapTransformation {
|
||||
toTransform.getConfig() != null ? toTransform.getConfig() : Bitmap.Config.ARGB_8888;
|
||||
Bitmap bitmap = pool.get(width, height, config);
|
||||
|
||||
setCanvasBitmapDensity(toTransform, bitmap);
|
||||
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
ColorMatrix saturation = new ColorMatrix();
|
||||
saturation.setSaturation(0f);
|
||||
@@ -52,19 +57,23 @@ public class GrayscaleTransformation extends BitmapTransformation {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GrayscaleTransformation()";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof GrayscaleTransformation;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode();
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -23,20 +23,21 @@ import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
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 final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
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));
|
||||
@@ -51,7 +52,8 @@ public class MaskTransformation extends BitmapTransformation {
|
||||
this.maskId = maskId;
|
||||
}
|
||||
|
||||
@Override protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@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();
|
||||
@@ -59,7 +61,9 @@ 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);
|
||||
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
mask.setBounds(0, 0, width, height);
|
||||
@@ -69,19 +73,24 @@ public class MaskTransformation extends BitmapTransformation {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MaskTransformation(maskId=" + maskId + ")";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
return o instanceof MaskTransformation;
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof MaskTransformation &&
|
||||
((MaskTransformation) o).maskId == maskId;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return ID.hashCode();
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode() + maskId * 10;
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID + maskId).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -23,7 +23,9 @@ import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
@@ -32,7 +34,6 @@ public class RoundedCornersTransformation extends BitmapTransformation {
|
||||
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID = "jp.wasabeef.glide.transformations.RoundedCornersTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
public enum CornerType {
|
||||
ALL,
|
||||
@@ -42,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);
|
||||
@@ -58,7 +59,8 @@ public class RoundedCornersTransformation extends BitmapTransformation {
|
||||
this.cornerType = cornerType;
|
||||
}
|
||||
|
||||
@Override protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@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();
|
||||
@@ -66,6 +68,8 @@ public class RoundedCornersTransformation extends BitmapTransformation {
|
||||
Bitmap bitmap = pool.get(width, height, Bitmap.Config.ARGB_8888);
|
||||
bitmap.setHasAlpha(true);
|
||||
|
||||
setCanvasBitmapDensity(toTransform, bitmap);
|
||||
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
Paint paint = new Paint();
|
||||
paint.setAntiAlias(true);
|
||||
@@ -218,8 +222,8 @@ public class RoundedCornersTransformation extends BitmapTransformation {
|
||||
radius, paint);
|
||||
canvas.drawRoundRect(new RectF(right - diameter, bottom - diameter, right, bottom), radius,
|
||||
radius, paint);
|
||||
canvas.drawRect(new RectF(margin, margin + radius, right - diameter, bottom), paint);
|
||||
canvas.drawRect(new RectF(margin + diameter, margin, right, bottom - radius), paint);
|
||||
canvas.drawRect(new RectF(margin, margin + radius, right - radius, bottom), paint);
|
||||
canvas.drawRect(new RectF(margin + radius, margin, right, bottom - radius), paint);
|
||||
}
|
||||
|
||||
private void drawDiagonalFromTopRightRoundRect(Canvas canvas, Paint paint, float right,
|
||||
@@ -232,20 +236,28 @@ public class RoundedCornersTransformation extends BitmapTransformation {
|
||||
canvas.drawRect(new RectF(margin + radius, margin + radius, right, bottom), paint);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RoundedTransformation(radius=" + radius + ", margin=" + margin + ", diameter="
|
||||
+ diameter + ", cornerType=" + cornerType.name() + ")";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
return o instanceof RoundedCornersTransformation;
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof RoundedCornersTransformation &&
|
||||
((RoundedCornersTransformation) o).radius == radius &&
|
||||
((RoundedCornersTransformation) o).diameter == diameter &&
|
||||
((RoundedCornersTransformation) o).margin == margin &&
|
||||
((RoundedCornersTransformation) o).cornerType == cornerType;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return ID.hashCode();
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode() + radius * 10000 + diameter * 1000 + margin * 100 + cornerType.ordinal() * 10;
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID + radius + diameter + margin + cornerType).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -16,8 +16,11 @@ package jp.wasabeef.glide.transformations.gpu;
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import jp.co.cyberagent.android.gpuimage.GPUImageBrightnessFilter;
|
||||
|
||||
import jp.co.cyberagent.android.gpuimage.filter.GPUImageBrightnessFilter;
|
||||
|
||||
/**
|
||||
* brightness value ranges from -1.0 to 1.0, with 0.0 as the normal level
|
||||
@@ -27,9 +30,8 @@ public class BrightnessFilterTransformation extends GPUFilterTransformation {
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.BrightnessFilterTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
private float brightness;
|
||||
private final float brightness;
|
||||
|
||||
public BrightnessFilterTransformation() {
|
||||
this(0.0f);
|
||||
@@ -42,19 +44,24 @@ public class BrightnessFilterTransformation extends GPUFilterTransformation {
|
||||
filter.setBrightness(this.brightness);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BrightnessFilterTransformation(brightness=" + brightness + ")";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
return o instanceof BrightnessFilterTransformation;
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof BrightnessFilterTransformation &&
|
||||
((BrightnessFilterTransformation) o).brightness == brightness;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return ID.hashCode();
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode() + (int) ((brightness + 1.0f) * 10);
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID + brightness).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -16,8 +16,11 @@ package jp.wasabeef.glide.transformations.gpu;
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import jp.co.cyberagent.android.gpuimage.GPUImageContrastFilter;
|
||||
|
||||
import jp.co.cyberagent.android.gpuimage.filter.GPUImageContrastFilter;
|
||||
|
||||
/**
|
||||
* contrast value ranges from 0.0 to 4.0, with 1.0 as the normal level
|
||||
@@ -27,9 +30,8 @@ public class ContrastFilterTransformation extends GPUFilterTransformation {
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.ContrastFilterTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
private float contrast;
|
||||
private final float contrast;
|
||||
|
||||
public ContrastFilterTransformation() {
|
||||
this(1.0f);
|
||||
@@ -42,19 +44,23 @@ public class ContrastFilterTransformation extends GPUFilterTransformation {
|
||||
filter.setContrast(this.contrast);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ContrastFilterTransformation(contrast=" + contrast + ")";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof ContrastFilterTransformation;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return ID.hashCode();
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode() + (int) (contrast * 10);
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID + contrast).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -18,11 +18,15 @@ package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
import jp.co.cyberagent.android.gpuimage.GPUImage;
|
||||
import jp.co.cyberagent.android.gpuimage.GPUImageFilter;
|
||||
import jp.co.cyberagent.android.gpuimage.filter.GPUImageFilter;
|
||||
import jp.wasabeef.glide.transformations.BitmapTransformation;
|
||||
|
||||
public class GPUFilterTransformation extends BitmapTransformation {
|
||||
@@ -32,13 +36,14 @@ 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;
|
||||
}
|
||||
|
||||
@Override protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@Override
|
||||
protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
|
||||
@NonNull Bitmap toTransform, int outWidth, int outHeight) {
|
||||
GPUImage gpuImage = new GPUImage(context);
|
||||
gpuImage.setImage(toTransform);
|
||||
@@ -47,23 +52,28 @@ public class GPUFilterTransformation extends BitmapTransformation {
|
||||
return gpuImage.getBitmapWithFilterApplied();
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") public <T> T getFilter() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getFilter() {
|
||||
return (T) gpuImageFilter;
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof GPUFilterTransformation;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode();
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -16,8 +16,11 @@ package jp.wasabeef.glide.transformations.gpu;
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import jp.co.cyberagent.android.gpuimage.GPUImageColorInvertFilter;
|
||||
|
||||
import jp.co.cyberagent.android.gpuimage.filter.GPUImageColorInvertFilter;
|
||||
|
||||
/**
|
||||
* Invert all the colors in the image.
|
||||
@@ -27,25 +30,28 @@ public class InvertFilterTransformation extends GPUFilterTransformation {
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.InvertFilterTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
public InvertFilterTransformation() {
|
||||
super(new GPUImageColorInvertFilter());
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "InvertFilterTransformation()";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof InvertFilterTransformation;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode();
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -16,12 +16,15 @@ package jp.wasabeef.glide.transformations.gpu;
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import jp.co.cyberagent.android.gpuimage.GPUImageKuwaharaFilter;
|
||||
|
||||
import jp.co.cyberagent.android.gpuimage.filter.GPUImageKuwaharaFilter;
|
||||
|
||||
/**
|
||||
* Kuwahara all the colors in the image.
|
||||
*
|
||||
* <p>
|
||||
* The radius to sample from when creating the brush-stroke effect, with a default of 25.
|
||||
* The larger the radius, the slower the filter.
|
||||
*/
|
||||
@@ -30,9 +33,8 @@ public class KuwaharaFilterTransformation extends GPUFilterTransformation {
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.KuwaharaFilterTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
private int radius;
|
||||
private final int radius;
|
||||
|
||||
public KuwaharaFilterTransformation() {
|
||||
this(25);
|
||||
@@ -45,19 +47,23 @@ public class KuwaharaFilterTransformation extends GPUFilterTransformation {
|
||||
filter.setRadius(this.radius);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "KuwaharaFilterTransformation(radius=" + radius + ")";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof KuwaharaFilterTransformation;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return ID.hashCode();
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode() + radius * 10;
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID + radius).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -16,12 +16,15 @@ package jp.wasabeef.glide.transformations.gpu;
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import jp.co.cyberagent.android.gpuimage.GPUImagePixelationFilter;
|
||||
|
||||
import jp.co.cyberagent.android.gpuimage.filter.GPUImagePixelationFilter;
|
||||
|
||||
/**
|
||||
* Applies a Pixelation effect to the image.
|
||||
*
|
||||
* <p>
|
||||
* The pixel with a default of 10.0.
|
||||
*/
|
||||
public class PixelationFilterTransformation extends GPUFilterTransformation {
|
||||
@@ -29,9 +32,8 @@ public class PixelationFilterTransformation extends GPUFilterTransformation {
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.PixelationFilterTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
private float pixel;
|
||||
private final float pixel;
|
||||
|
||||
public PixelationFilterTransformation() {
|
||||
this(10f);
|
||||
@@ -44,19 +46,23 @@ public class PixelationFilterTransformation extends GPUFilterTransformation {
|
||||
filter.setPixel(this.pixel);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PixelationFilterTransformation(pixel=" + pixel + ")";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof PixelationFilterTransformation;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return ID.hashCode();
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode() + (int) (pixel * 10);
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID + pixel).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -16,12 +16,15 @@ package jp.wasabeef.glide.transformations.gpu;
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import jp.co.cyberagent.android.gpuimage.GPUImageSepiaFilter;
|
||||
|
||||
import jp.co.cyberagent.android.gpuimage.filter.GPUImageSepiaToneFilter;
|
||||
|
||||
/**
|
||||
* Applies a simple sepia effect.
|
||||
*
|
||||
* <p>
|
||||
* The intensity with a default of 1.0.
|
||||
*/
|
||||
public class SepiaFilterTransformation extends GPUFilterTransformation {
|
||||
@@ -29,34 +32,37 @@ public class SepiaFilterTransformation extends GPUFilterTransformation {
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.SepiaFilterTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
private float intensity;
|
||||
private final float intensity;
|
||||
|
||||
public SepiaFilterTransformation() {
|
||||
this(1.0f);
|
||||
}
|
||||
|
||||
public SepiaFilterTransformation(float intensity) {
|
||||
super(new GPUImageSepiaFilter());
|
||||
super(new GPUImageSepiaToneFilter());
|
||||
this.intensity = intensity;
|
||||
GPUImageSepiaFilter filter = getFilter();
|
||||
GPUImageSepiaToneFilter filter = getFilter();
|
||||
filter.setIntensity(this.intensity);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SepiaFilterTransformation(intensity=" + intensity + ")";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof SepiaFilterTransformation;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return ID.hashCode();
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode() + (int) (intensity * 10);
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID + intensity).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -16,33 +16,39 @@ package jp.wasabeef.glide.transformations.gpu;
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import jp.co.cyberagent.android.gpuimage.GPUImageSketchFilter;
|
||||
|
||||
import jp.co.cyberagent.android.gpuimage.filter.GPUImageSketchFilter;
|
||||
|
||||
public class SketchFilterTransformation extends GPUFilterTransformation {
|
||||
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.SketchFilterTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
public SketchFilterTransformation() {
|
||||
super(new GPUImageSketchFilter());
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SketchFilterTransformation()";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof SketchFilterTransformation;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode();
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -17,8 +17,12 @@ package jp.wasabeef.glide.transformations.gpu;
|
||||
*/
|
||||
|
||||
import android.graphics.PointF;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import jp.co.cyberagent.android.gpuimage.GPUImageSwirlFilter;
|
||||
|
||||
import jp.co.cyberagent.android.gpuimage.filter.GPUImageSwirlFilter;
|
||||
|
||||
/**
|
||||
* Creates a swirl distortion on the image.
|
||||
@@ -28,11 +32,10 @@ public class SwirlFilterTransformation extends GPUFilterTransformation {
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.SwirlFilterTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
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));
|
||||
@@ -54,20 +57,27 @@ public class SwirlFilterTransformation extends GPUFilterTransformation {
|
||||
filter.setCenter(this.center);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SwirlFilterTransformation(radius=" + radius + ",angle=" + angle + ",center="
|
||||
+ center.toString() + ")";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
return o instanceof SwirlFilterTransformation;
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof SwirlFilterTransformation &&
|
||||
((SwirlFilterTransformation) o).radius == radius &&
|
||||
((SwirlFilterTransformation) o).angle == radius &&
|
||||
((SwirlFilterTransformation) o).center.equals(center.x, center.y);
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return ID.hashCode();
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode() + (int) (radius * 1000) + (int) (angle * 10) + center.hashCode();
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID + radius + angle + center.hashCode()).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -16,8 +16,11 @@ package jp.wasabeef.glide.transformations.gpu;
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import jp.co.cyberagent.android.gpuimage.GPUImageToonFilter;
|
||||
|
||||
import jp.co.cyberagent.android.gpuimage.filter.GPUImageToonFilter;
|
||||
|
||||
/**
|
||||
* The threshold at which to apply the edges, default of 0.2.
|
||||
@@ -29,10 +32,9 @@ public class ToonFilterTransformation extends GPUFilterTransformation {
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.ToonFilterTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
private float threshold;
|
||||
private float quantizationLevels;
|
||||
private final float threshold;
|
||||
private final float quantizationLevels;
|
||||
|
||||
public ToonFilterTransformation() {
|
||||
this(.2f, 10.0f);
|
||||
@@ -47,20 +49,26 @@ public class ToonFilterTransformation extends GPUFilterTransformation {
|
||||
filter.setQuantizationLevels(this.quantizationLevels);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ToonFilterTransformation(threshold=" + threshold + ",quantizationLevels="
|
||||
+ quantizationLevels + ")";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
return o instanceof ToonFilterTransformation;
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof ToonFilterTransformation &&
|
||||
((ToonFilterTransformation) o).threshold == threshold &&
|
||||
((ToonFilterTransformation) o).quantizationLevels == quantizationLevels;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return ID.hashCode();
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode() + (int) (threshold * 1000) + (int) (quantizationLevels * 10);
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID + threshold + quantizationLevels).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package jp.wasabeef.glide.transformations.gpu;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -17,9 +17,13 @@ package jp.wasabeef.glide.transformations.gpu;
|
||||
*/
|
||||
|
||||
import android.graphics.PointF;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Arrays;
|
||||
import jp.co.cyberagent.android.gpuimage.GPUImageVignetteFilter;
|
||||
|
||||
import jp.co.cyberagent.android.gpuimage.filter.GPUImageVignetteFilter;
|
||||
|
||||
/**
|
||||
* Performs a vignetting effect, fading out the image at the edges
|
||||
@@ -31,15 +35,14 @@ public class VignetteFilterTransformation extends GPUFilterTransformation {
|
||||
private static final int VERSION = 1;
|
||||
private static final String ID =
|
||||
"jp.wasabeef.glide.transformations.gpu.VignetteFilterTransformation." + VERSION;
|
||||
private static final byte[] ID_BYTES = ID.getBytes(CHARSET);
|
||||
|
||||
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);
|
||||
this(new PointF(0.5f, 0.5f), new float[]{0.0f, 0.0f, 0.0f}, 0.0f, 0.75f);
|
||||
}
|
||||
|
||||
public VignetteFilterTransformation(PointF center, float[] color, float start, float end) {
|
||||
@@ -55,20 +58,29 @@ public class VignetteFilterTransformation extends GPUFilterTransformation {
|
||||
filter.setVignetteEnd(vignetteEnd);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VignetteFilterTransformation(center=" + center.toString() + ",color=" + Arrays.toString(
|
||||
vignetteColor) + ",start=" + vignetteStart + ",end=" + vignetteEnd + ")";
|
||||
}
|
||||
|
||||
@Override public boolean equals(Object o) {
|
||||
return o instanceof VignetteFilterTransformation;
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof VignetteFilterTransformation &&
|
||||
((VignetteFilterTransformation) o).center.equals(center.x, center.y) &&
|
||||
Arrays.equals(((VignetteFilterTransformation) o).vignetteColor, vignetteColor) &&
|
||||
((VignetteFilterTransformation) o).vignetteStart == vignetteStart &&
|
||||
((VignetteFilterTransformation) o).vignetteEnd == vignetteEnd;
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
return ID.hashCode();
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ID.hashCode() + center.hashCode() + Arrays.hashCode(vignetteColor) +
|
||||
(int) (vignetteStart * 100) + (int) (vignetteEnd * 10);
|
||||
}
|
||||
|
||||
@Override public void updateDiskCacheKey(MessageDigest messageDigest) {
|
||||
messageDigest.update(ID_BYTES);
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update((ID + center + Arrays.hashCode(vignetteColor) + vignetteStart + vignetteEnd).getBytes(CHARSET));
|
||||
}
|
||||
}
|
||||
|
@@ -3,14 +3,14 @@ package jp.wasabeef.glide.transformations.internal;
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -72,15 +72,15 @@ public class FastBlur {
|
||||
int wh = w * h;
|
||||
int div = radius + radius + 1;
|
||||
|
||||
int r[] = new int[wh];
|
||||
int g[] = new int[wh];
|
||||
int b[] = new int[wh];
|
||||
int[] r = new int[wh];
|
||||
int[] g = new int[wh];
|
||||
int[] b = new int[wh];
|
||||
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;
|
||||
divsum *= divsum;
|
||||
int dv[] = new int[256 * divsum];
|
||||
int[] dv = new int[256 * divsum];
|
||||
for (i = 0; i < 256 * divsum; i++) {
|
||||
dv[i] = (i / divsum);
|
||||
}
|
||||
|
@@ -11,14 +11,14 @@ import android.renderscript.RenderScript;
|
||||
import android.renderscript.ScriptIntrinsicBlur;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -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,18 +1,19 @@
|
||||
package jp.wasabeef.glide.transformations.internal;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 Wasabeef
|
||||
*
|
||||
* 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.
|
||||
@@ -26,18 +27,7 @@ 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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user