main d950f0c33f27 cached
63 files
119.8 KB
31.7k tokens
174 symbols
1 requests
Download .txt
Repository: wasabeef/glide-transformations
Branch: main
Commit: d950f0c33f27
Files: 63
Total size: 119.8 KB

Directory structure:
gitextract_94bctmql/

├── .editorconfig
├── .github/
│   ├── FUNDING.yml
│   ├── ISSUE_TEMPLATE.md
│   └── PULL_REQUEST_TEMPLATE.md
├── .gitignore
├── .idea/
│   ├── codeStyles/
│   │   ├── Project.xml
│   │   └── codeStyleConfig.xml
│   ├── encodings.xml
│   ├── runConfigurations.xml
│   └── vcs.xml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── build.gradle
├── example/
│   ├── build.gradle
│   ├── proguard-rules.pro
│   └── src/
│       └── main/
│           ├── AndroidManifest.xml
│           ├── java/
│           │   └── jp/
│           │       └── wasabeef/
│           │           └── example/
│           │               └── glide/
│           │                   ├── Ext.kt
│           │                   ├── MainActivity.kt
│           │                   └── MainAdapter.kt
│           └── res/
│               ├── layout/
│               │   ├── activity_main.xml
│               │   └── layout_list_item.xml
│               ├── values/
│               │   ├── colors.xml
│               │   ├── dimens.xml
│               │   ├── strings.xml
│               │   └── styles.xml
│               └── values-w820dp/
│                   └── dimens.xml
├── gradle/
│   └── wrapper/
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
├── signingConfigs/
│   ├── debug.gradle
│   └── debug.keystore
└── transformations/
    ├── build.gradle
    ├── proguard-rules.txt
    └── src/
        ├── androidTest/
        │   └── java/
        │       └── jp/
        │           └── wasabeef/
        │               └── glide/
        │                   └── transformations/
        │                       └── ApplicationTest.java
        └── main/
            ├── AndroidManifest.xml
            └── java/
                └── jp/
                    └── wasabeef/
                        └── glide/
                            └── transformations/
                                ├── BitmapTransformation.java
                                ├── BlurTransformation.java
                                ├── ColorFilterTransformation.java
                                ├── CropCircleTransformation.java
                                ├── CropCircleWithBorderTransformation.java
                                ├── CropSquareTransformation.java
                                ├── CropTransformation.java
                                ├── GrayscaleTransformation.java
                                ├── MaskTransformation.java
                                ├── RoundedCornersTransformation.java
                                ├── gpu/
                                │   ├── BrightnessFilterTransformation.java
                                │   ├── ContrastFilterTransformation.java
                                │   ├── GPUFilterTransformation.java
                                │   ├── InvertFilterTransformation.java
                                │   ├── KuwaharaFilterTransformation.java
                                │   ├── PixelationFilterTransformation.java
                                │   ├── SepiaFilterTransformation.java
                                │   ├── SketchFilterTransformation.java
                                │   ├── SwirlFilterTransformation.java
                                │   ├── ToonFilterTransformation.java
                                │   └── VignetteFilterTransformation.java
                                └── internal/
                                    ├── FastBlur.java
                                    ├── RSBlur.java
                                    └── Utils.java

================================================
FILE CONTENTS
================================================

================================================
FILE: .editorconfig
================================================
[*]
indent_size = 2
max_line_length = off
insert_final_newline = true

[*.{kt, kts}]
kotlin_imports_layout = ascii



================================================
FILE: .github/FUNDING.yml
================================================
# 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']


================================================
FILE: .github/ISSUE_TEMPLATE.md
================================================
# 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*


================================================
FILE: .github/PULL_REQUEST_TEMPLATE.md
================================================
## What does this change?

## What is the value of this and can you measure success?

## Screenshots



================================================
FILE: .gitignore
================================================
# Mac OS
.DS_store

# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
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



================================================
FILE: .idea/codeStyles/Project.xml
================================================
<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>

================================================
FILE: .idea/codeStyles/codeStyleConfig.xml
================================================
<component name="ProjectCodeStyleConfiguration">
  <state>
    <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
  </state>
</component>

================================================
FILE: .idea/encodings.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>

================================================
FILE: .idea/runConfigurations.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="RunConfigurationProducerService">
    <option name="ignoredProducers">
      <set>
        <option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
        <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>

================================================
FILE: .idea/vcs.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="VcsDirectoryMappings">
    <mapping directory="" vcs="Git" />
  </component>
</project>

================================================
FILE: CHANGELOG.md
================================================
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)*
----------------------------

Update:  
- Glide 4.5.0 -> 4.6.1  

Bug Fix:  
- Fix settings fot proguard.

Version 3.1.0 *(2018-01-26)*
----------------------------

Update:  
- Compile & Target SDK Version 25 -> 27  
- Build Tools 26.0.1 -> 27.0.3  
- Support Library 25.3.1 -> 27.0.2  
- Glide 4.0.0 -> 4.5.0  

Bug Fix:  
- [Implement equals() and hashCode() methods #105](https://github.com/wasabeef/glide-transformations/pull/105)  
- Use RenderScript#releaseAllContexts  

Version 3.0.1 *(2017-09-08)*
----------------------------

Bug Fix:
- [Deleted a setting for DexGuard #86](https://github.com/wasabeef/glide-transformations/issues/86)

Version 3.0.0 *(2017-09-06)*
----------------------------

Update:
- Build Tools 25.0.2 -> 26.0.1
- Min SDK Version 11 -> 14
- Glide 3.7.0 -> 4.0.0

Feature: 
- Supported Glide 4.0.0

Version 2.0.2 *(2017-03-17)*
----------------------------

Update:
- Compile & Target SDK Version 23 -> 25
- Build Tools 23.0.2 -> 25.0.2
- Support Library 23.2.1 -> 25.3.0
- GPUImage for Android 1.3.0 -> 1.4.1

Bug Fix:
- [Additional resource cleanup in RSBlur #45](https://github.com/wasabeef/glide-transformations/pull/45)
 
Version 2.0.1 *(2016-04-21)*
----------------------------

Fix:
 [#35](https://github.com/wasabeef/glide-transformations/issues/35)
 RSInvalidStateException

Version 2.0.0 *(2016-03-02)*
----------------------------

Say v8.RenderScript goodbye

Version 1.4.0 *(2016-02-28)*
----------------------------

fix Issue [#29](https://github.com/wasabeef/glide-transformations/issues/29)
 Use FastBlur as a fallback upon RenderScript failure.

Version 1.3.1 *(2015-11-27)*
----------------------------

Change the renderscriptTargetApi down to 20.  
 Warning:Renderscript support mode is not currently supported with renderscript target 21+

fix: memory leak.

Version 1.3.0 *(2015-11-10)*
----------------------------

add round corner type to RoundedCornersTransformation.  
Thanks to [kaelaela](https://github.com/kaelaela)

Version 1.2.1 *(2015-09-18)*
----------------------------

Merged NinePatchMaskTransformation to MaskTransformation.

Version 1.2.0 *(2015-09-16)*
----------------------------

add new transformations MaskTransformation and NinePatchMaskTransformation.  
Thanks to [start141](https://github.com/start141)

Version 1.1.0 *(2015-09-05)*
----------------------------

Adjustment of default parameters.

Version 1.0.8 *(2015-07-24)*
----------------------------

add DownSampling to BlurTransform

Version 1.0.7 *(2015-07-18)*
----------------------------

Bug fix : Blur not working.

Version 1.0.6 *(2015-04-23)*
----------------------------

add: CropType(Top, Center, Bottom) for CropTransformation.

Version 1.0.5 *(2015-03-09)*
----------------------------

Bug fix: Transparency.

Version 1.0.4 *(2015-02-13)*
----------------------------

Bug fix : remove original bitmap resource recycling.

Version 1.0.3 *(2015-02-05)*
----------------------------

Bug fix

Version 1.0.2 *(2015-02-04)*
----------------------------

Refactor: use BimapPool

Version 1.0.1 *(2015-01-21)*
----------------------------

fix: Blur Transformation now woking at Android 4.3
add: GPUImage to Gradle dependency 

Version 1.0.0 *(2015-01-12)*
----------------------------

Initial release.


================================================
FILE: LICENSE
================================================
Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "{}"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright {yyyy} {name of copyright owner}

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.



================================================
FILE: README.md
================================================
Glide Transformations
======================
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-glide--transformations-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1363)
[![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/jp.wasabeef/glide-transformations/badge.svg)](https://search.maven.org/artifact/jp.wasabeef/glide-transformations)

An Android transformation library providing a variety of image transformations for [Glide](https://github.com/bumptech/glide).

Please feel free to use this.


#### Are you using Picasso or Fresco?
[Picasso Transformations](https://github.com/wasabeef/picasso-transformations)  
[Fresco Processors](https://github.com/wasabeef/fresco-processors)

# Demo

### Original Image
<img src="art/demo-org.jpg" width="30%">

### Transformations
<img src="art/demo.gif" width="50%">

# How do I use it?

## Step 1

#### Gradle
```groovy
repositories {
  mavenCentral()
}

dependencies {
  implementation 'jp.wasabeef:glide-transformations:4.3.0'
  // If you want to use the GPU Filters
  implementation 'jp.co.cyberagent.android:gpuimage:2.1.0'
}
```

## Step 2

Set Glide Transform.

```kotlin
Glide.with(this).load(R.drawable.demo)
  .apply(RequestOptions.bitmapTransform(BlurTransformation(25, 3)))
  .into(imageView)
```

## Advanced Step 3

You can set a multiple transformations.

```kotlin
val multi = MultiTransformation<Bitmap>(
  BlurTransformation(25),
  RoundedCornersTransformation(128, 0, CornerType.BOTTOM))))
Glide.with(this).load(R.drawable.demo)
  .apply(RequestOptions.bitmapTransform(multi))
  .into(imageView))
```

## Transformations

### Crop
- `CropTransformation`
- `CropCircleTransformation`
- `CropCircleWithBorderTransformation`
- `CropSquareTransformation`
- `RoundedCornersTransformation`

### Color
- `ColorFilterTransformation`
- `GrayscaleTransformation`

### Blur
- `BlurTransformation`

### Mask
- `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`


Applications using Glide Transformations
---

Please [ping](mailto:dadadada.chop@gmail.com) me or send a pull request if you would like to be added here.

Icon | Application
------------ | -------------
<img src="https://lh6.ggpht.com/6zKH_uQY1bxCwXL4DLo_uoFEOXdShi3BgmN6XRHlaJ-oA1svmq6y1PZkmO50nWQn2Lg=w300-rw" width="48" height="48" /> | [Ameba Ownd](https://play.google.com/store/apps/details?id=jp.co.cyberagent.madrid)
<img src="https://lh3.googleusercontent.com/ZOrekp-ho-ecWG1TyvuOs0LoB5M4QYWCCLS5lFbAHhp_SklSd06544ENG3uC97zGWes=w300-rw" width="48" height="48" /> | [AbemaTV](https://play.google.com/store/apps/details?id=tv.abema)
<img src="https://lh3.googleusercontent.com/eikxMAKKMU2O-rV-oUg04dGp-O4Aoje91kffDlnCB_3DCIPDzzADxdBOdPCW18Lmqw=w300-rw" width="48" height="48" /> | [TV Time](https://play.google.com/store/apps/details?id=com.tozelabs.tvshowtime)
<img src="https://play-lh.googleusercontent.com/sGt1rxE4naYmO_6sCquGLa5zHeh_3AZQGtBKhU8PGuXDa-MeUK25aSI-iZJlMDUVli9c=s300-rw" width="48" height="48" /> | [Christmas Radio](https://play.google.com/store/apps/details?id=nl.netwaves.christmasradio)



Developed By
-------
Daichi Furiya (Wasabeef) - <dadadada.chop@gmail.com>

<a href="https://twitter.com/wasabeef_jp">
<img alt="Follow me on Twitter"
src="https://raw.githubusercontent.com/wasabeef/art/master/twitter.png" width="75"/>
</a>

Contributions
-------

Any contributions are welcome!

Contributors
-------

* [start141](https://github.com/start141)
* [squeeish](https://github.com/squeeish)

Thanks
-------

* Inspired by `Picasso Transformations` in [TannerPerrien](https://github.com/TannerPerrien).

License
-------

    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.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.


================================================
FILE: build.gradle
================================================
// 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 {
    google()
    jcenter()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:4.2.0-beta04'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    // TODO: Close JCenter on May 1st https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/
//    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
//    classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
  }
}

allprojects {
  repositories {
    google()
    mavenCentral()
    jcenter()
  }
}


================================================
FILE: example/build.gradle
================================================
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
  compileSdkVersion COMPILE_SDK_VERSION as int

  defaultConfig {
    minSdkVersion MIN_SDK_VERSION as int
    targetSdkVersion TARGET_SDK_VERSION as int
    versionCode VERSION_CODE as int
    versionName VERSION_NAME
  }

  // SigningConfigs
  apply from: '../signingConfigs/debug.gradle', to: android

  buildTypes {
    debug {
      debuggable true
      signingConfig signingConfigs.debug
    }
    release {
      debuggable false
      zipAlignEnabled true
      minifyEnabled true
      shrinkResources true
    }
  }
}

repositories {
//     maven { url = "https://oss.sonatype.org/content/repositories/snapshots"}
}

dependencies {
//  implementation project(':transformations')
  implementation 'jp.wasabeef:glide-transformations:4.3.0'
  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-beta01"
  implementation "androidx.recyclerview:recyclerview:1.2.0-beta01"
  implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
}


================================================
FILE: example/proguard-rules.pro
================================================


================================================
FILE: example/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  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">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
  </application>

</manifest>


================================================
FILE: example/src/main/java/jp/wasabeef/example/glide/Ext.kt
================================================
package jp.wasabeef.example.glide

/**
 * 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.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.content.res.Resources

val Float.px: Float get() = (this * Resources.getSystem().displayMetrics.density)

val Int.px: Int get() = ((this * Resources.getSystem().displayMetrics.density).toInt())


================================================
FILE: example/src/main/java/jp/wasabeef/example/glide/MainActivity.kt
================================================
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
      ))
    }
  }
}


================================================
FILE: example/src/main/java/jp/wasabeef/example/glide/MainAdapter.kt
================================================
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)
  }
}


================================================
FILE: example/src/main/res/layout/activity_main.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<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">

  <androidx.recyclerview.widget.RecyclerView
    android:id="@+id/list"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>


================================================
FILE: example/src/main/res/layout/layout_list_item.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<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">

  <ImageView
    android:id="@+id/image"
    android:layout_width="250dp"
    android:layout_height="250dp"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:cropToPadding="false"
    android:scaleType="fitCenter"
    app:layout_constraintBottom_toTopOf="@+id/title"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

  <TextView
    android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>


================================================
FILE: example/src/main/res/values/colors.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>
  <color name="colorPrimary">#3F51B5</color>
  <color name="colorPrimaryDark">#303F9F</color>
  <color name="colorAccent">#FF4081</color>
</resources>


================================================
FILE: example/src/main/res/values/dimens.xml
================================================
<resources>
  <!-- Default screen margins, per the Android Design guidelines. -->
  <dimen name="activity_horizontal_margin">16dp</dimen>
  <dimen name="activity_vertical_margin">16dp</dimen>
</resources>


================================================
FILE: example/src/main/res/values/strings.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<resources>

  <string name="app_name">glide-transformations</string>
  <string name="hello_world">Hello world!</string>
  <string name="action_settings">Settings</string>

</resources>


================================================
FILE: example/src/main/res/values/styles.xml
================================================
<resources>

  <!-- Base application theme. -->
  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
  </style>

</resources>

================================================
FILE: example/src/main/res/values-w820dp/dimens.xml
================================================
<resources>
  <!-- Example customization of dimensions originally defined in res/values/dimens.xml
       (such as screen margins) for screens with more than 820dp of available width. This
       would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
  <dimen name="activity_horizontal_margin">64dp</dimen>
</resources>


================================================
FILE: gradle/wrapper/gradle-wrapper.properties
================================================
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.7.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists


================================================
FILE: gradle.properties
================================================
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
COMPILE_SDK_VERSION=30
TARGET_SDK_VERSION=30
MIN_SDK_VERSION=21


================================================
FILE: gradlew
================================================
#!/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
##
##############################################################################

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
    ls=`ls -ld "$PRG"`
    link=`expr "$ls" : '.*-> \(.*\)$'`
    if expr "$link" : '/.*' > /dev/null; then
        PRG="$link"
    else
        PRG=`dirname "$PRG"`"/$link"
    fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

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='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn () {
    echo "$*"
}

die () {
    echo
    echo "$*"
    echo
    exit 1
}

# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
  CYGWIN* )
    cygwin=true
    ;;
  Darwin* )
    darwin=true
    ;;
  MINGW* )
    msys=true
    ;;
  NONSTOP* )
    nonstop=true
    ;;
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
        # IBM's JDK on AIX uses strange locations for the executables
        JAVACMD="$JAVA_HOME/jre/sh/java"
    else
        JAVACMD="$JAVA_HOME/bin/java"
    fi
    if [ ! -x "$JAVACMD" ] ; then
        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
    fi
else
    JAVACMD="java"
    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
    MAX_FD_LIMIT=`ulimit -H -n`
    if [ $? -eq 0 ] ; then
        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
            MAX_FD="$MAX_FD_LIMIT"
        fi
        ulimit -n $MAX_FD
        if [ $? -ne 0 ] ; then
            warn "Could not set maximum file descriptor limit: $MAX_FD"
        fi
    else
        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
    fi
fi

# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# 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
    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
    SEP=""
    for dir in $ROOTDIRSRAW ; do
        ROOTDIRS="$ROOTDIRS$SEP$dir"
        SEP="|"
    done
    OURCYGPATTERN="(^($ROOTDIRS))"
    # Add a user-defined pattern to the cygpath arguments
    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
    fi
    # Now convert the arguments - kludge to limit ourselves to /bin/sh
    i=0
    for arg in "$@" ; do
        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option

        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
        else
            eval `echo args$i`="\"$arg\""
        fi
        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" ;;
    esac
fi

# Escape application args
save () {
    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
    echo " "
}
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"

exec "$JAVACMD" "$@"


================================================
FILE: gradlew.bat
================================================
@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
@rem  Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
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="-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 execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

: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 %*

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega


================================================
FILE: settings.gradle
================================================
include ':example', ':transformations'


================================================
FILE: signingConfigs/debug.gradle
================================================
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


================================================
FILE: transformations/build.gradle
================================================
apply plugin: 'com.android.library'

android {
  compileSdkVersion COMPILE_SDK_VERSION as int

  defaultConfig {
    minSdkVersion MIN_SDK_VERSION as int
    targetSdkVersion TARGET_SDK_VERSION as int

    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_version"
}

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"]
}

// TODO: Close JCenter on May 1st https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/
// apply from: 'https://gist.githubusercontent.com/wasabeef/cf14805bee509baf7461974582f17d26/raw/bintray-v1.gradle'
// apply from: 'https://gist.githubusercontent.com/wasabeef/cf14805bee509baf7461974582f17d26/raw/install-v1.gradle'

apply from: 'https://gist.githubusercontent.com/wasabeef/2f2ae8d97b429e7d967128125dc47854/raw/maven-central-v1.gradle'


================================================
FILE: transformations/proguard-rules.txt
================================================
-dontwarn jp.co.cyberagent.android.gpuimage.**

-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.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}


================================================
FILE: transformations/src/androidTest/java/jp/wasabeef/glide/transformations/ApplicationTest.java
================================================
package jp.wasabeef.glide.transformations;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
 * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
 */
public class ApplicationTest extends ApplicationTestCase<Application> {

  public ApplicationTest() {
    super(Application.class);
  }
}

================================================
FILE: transformations/src/main/AndroidManifest.xml
================================================
<manifest package="jp.wasabeef.glide.transformations" />


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/BitmapTransformation.java
================================================
package jp.wasabeef.glide.transformations;

/**
 * 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.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.content.Context;
import android.graphics.Bitmap;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.Resource;
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(@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
          + " less than or equal to zero and not Target.SIZE_ORIGINAL");
    }
    BitmapPool bitmapPool = Glide.get(context).getBitmapPool();
    Bitmap toTransform = resource.get();
    int targetWidth = outWidth == Target.SIZE_ORIGINAL ? toTransform.getWidth() : outWidth;
    int targetHeight = outHeight == Target.SIZE_ORIGINAL ? toTransform.getHeight() : outHeight;
    Bitmap transformed = transform(context.getApplicationContext(), bitmapPool, toTransform, targetWidth, targetHeight);

    final Resource<Bitmap> result;
    if (toTransform.equals(transformed)) {
      result = resource;
    } else {
      result = BitmapResource.obtain(transformed, bitmapPool);
    }
    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(@NonNull MessageDigest messageDigest);

  @Override
  public abstract boolean equals(Object o);

  @Override
  public abstract int hashCode();
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/BlurTransformation.java
================================================
package jp.wasabeef.glide.transformations;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.renderscript.RSRuntimeException;

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;

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 int MAX_RADIUS = 25;
  private static final int DEFAULT_DOWN_SAMPLING = 1;

  private final int radius;
  private final int sampling;

  public BlurTransformation() {
    this(MAX_RADIUS, DEFAULT_DOWN_SAMPLING);
  }

  public BlurTransformation(int radius) {
    this(radius, DEFAULT_DOWN_SAMPLING);
  }

  public BlurTransformation(int radius, int sampling) {
    this.radius = radius;
    this.sampling = sampling;
  }

  @Override
  protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
                             @NonNull Bitmap toTransform, int outWidth, int outHeight) {

    int width = toTransform.getWidth();
    int height = toTransform.getHeight();
    int scaledWidth = width / sampling;
    int scaledHeight = height / sampling;

    Bitmap bitmap = pool.get(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);

    setCanvasBitmapDensity(toTransform, bitmap);

    Canvas canvas = new Canvas(bitmap);
    canvas.scale(1 / (float) sampling, 1 / (float) sampling);
    Paint paint = new Paint();
    paint.setFlags(Paint.FILTER_BITMAP_FLAG);
    canvas.drawBitmap(toTransform, 0, 0, paint);

    try {
      bitmap = RSBlur.blur(context, bitmap, radius);
    } catch (RSRuntimeException e) {
      bitmap = FastBlur.blur(bitmap, radius, true);
    }

    return bitmap;
  }

  @Override
  public String toString() {
    return "BlurTransformation(radius=" + radius + ", sampling=" + sampling + ")";
  }

  @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() + radius * 1000 + sampling * 10;
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID + radius + sampling).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/ColorFilterTransformation.java
================================================
package jp.wasabeef.glide.transformations;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;

import androidx.annotation.NonNull;

import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;

import java.security.MessageDigest;

public class ColorFilterTransformation extends BitmapTransformation {

  private static final int VERSION = 1;
  private static final String ID =
    "jp.wasabeef.glide.transformations.ColorFilterTransformation." + VERSION;

  private final int color;

  public ColorFilterTransformation(int color) {
    this.color = color;
  }

  @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();

    Bitmap.Config config =
      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);
    paint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP));
    canvas.drawBitmap(toTransform, 0, 0, paint);

    return bitmap;
  }

  @Override
  public String toString() {
    return "ColorFilterTransformation(color=" + color + ")";
  }

  @Override
  public boolean equals(Object o) {
    return o instanceof ColorFilterTransformation &&
      ((ColorFilterTransformation) o).color == color;
  }

  @Override
  public int hashCode() {
    return ID.hashCode() + color * 10;
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID + color).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/CropCircleTransformation.java
================================================
package jp.wasabeef.glide.transformations;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.content.Context;
import android.graphics.Bitmap;

import 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;

/**
 * @deprecated Use {@link RequestOptions#circleCrop()}.
 */
@Deprecated
public class CropCircleTransformation extends BitmapTransformation {

  private static final int VERSION = 1;
  private static final String ID =
    "jp.wasabeef.glide.transformations.CropCircleTransformation." + VERSION;

  @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() {
    return "CropCircleTransformation()";
  }

  @Override
  public boolean equals(Object o) {
    return o instanceof CropCircleTransformation;
  }

  @Override
  public int hashCode() {
    return ID.hashCode();
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/CropCircleWithBorderTransformation.java
================================================
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;
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/CropSquareTransformation.java
================================================
package jp.wasabeef.glide.transformations;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.content.Context;
import android.graphics.Bitmap;

import 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 {

  private static final int VERSION = 1;
  private static final String ID =
    "jp.wasabeef.glide.transformations.CropSquareTransformation." + VERSION;

  private int size;

  @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() {
    return "CropSquareTransformation(size=" + size + ")";
  }

  @Override
  public boolean equals(Object o) {
    return o instanceof CropSquareTransformation && ((CropSquareTransformation) o).size == size;
  }

  @Override
  public int hashCode() {
    return ID.hashCode() + size * 10;
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID + size).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/CropTransformation.java
================================================
package jp.wasabeef.glide.transformations;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.RectF;

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;

  public enum CropType {
    TOP,
    CENTER,
    BOTTOM
  }

  private int width;
  private int height;

  private CropType cropType = CropType.CENTER;

  public CropTransformation(int width, int height) {
    this(width, height, CropType.CENTER);
  }

  public CropTransformation(int width, int height, CropType cropType) {
    this.width = width;
    this.height = height;
    this.cropType = cropType;
  }

  @Override
  protected Bitmap transform(@NonNull Context context, @NonNull BitmapPool pool,
                             @NonNull Bitmap toTransform, int outWidth, int outHeight) {

    width = width == 0 ? toTransform.getWidth() : width;
    height = height == 0 ? toTransform.getHeight() : height;

    Bitmap.Config config =
      toTransform.getConfig() != null ? toTransform.getConfig() : Bitmap.Config.ARGB_8888;
    Bitmap bitmap = pool.get(width, height, config);

    bitmap.setHasAlpha(true);

    float scaleX = (float) width / toTransform.getWidth();
    float scaleY = (float) height / toTransform.getHeight();
    float scale = Math.max(scaleX, scaleY);

    float scaledWidth = scale * toTransform.getWidth();
    float scaledHeight = scale * toTransform.getHeight();
    float left = (width - scaledWidth) / 2;
    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;
  }

  private float getTop(float scaledHeight) {
    switch (cropType) {
      case TOP:
        return 0;
      case CENTER:
        return (height - scaledHeight) / 2;
      case BOTTOM:
        return height - scaledHeight;
      default:
        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));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/GrayscaleTransformation.java
================================================
package jp.wasabeef.glide.transformations;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;

import androidx.annotation.NonNull;

import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;

import java.security.MessageDigest;

public class GrayscaleTransformation extends BitmapTransformation {

  private static final int VERSION = 1;
  private static final String ID =
    "jp.wasabeef.glide.transformations.GrayscaleTransformation." + VERSION;

  @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();

    Bitmap.Config config =
      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);
    Paint paint = new Paint();
    paint.setColorFilter(new ColorMatrixColorFilter(saturation));
    canvas.drawBitmap(toTransform, 0, 0, paint);

    return bitmap;
  }

  @Override
  public String toString() {
    return "GrayscaleTransformation()";
  }

  @Override
  public boolean equals(Object o) {
    return o instanceof GrayscaleTransformation;
  }

  @Override
  public int hashCode() {
    return ID.hashCode();
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/MaskTransformation.java
================================================
package jp.wasabeef.glide.transformations;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.drawable.Drawable;

import androidx.annotation.NonNull;

import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;

import java.security.MessageDigest;

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 Paint paint = new Paint();
  private final int maskId;

  static {
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
  }

  /**
   * @param maskId If you change the mask file, please also rename the mask file, or Glide will get
   *               the cache with the old mask. Because key() return the same values if using the
   *               same make file name. If you have a good idea please tell us, thanks.
   */
  public MaskTransformation(int maskId) {
    this.maskId = maskId;
  }

  @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();

    Bitmap bitmap = pool.get(width, height, Bitmap.Config.ARGB_8888);
    bitmap.setHasAlpha(true);

    Drawable mask = context.getDrawable(maskId);

    setCanvasBitmapDensity(toTransform, bitmap);

    Canvas canvas = new Canvas(bitmap);
    mask.setBounds(0, 0, width, height);
    mask.draw(canvas);
    canvas.drawBitmap(toTransform, 0, 0, paint);

    return bitmap;
  }

  @Override
  public String toString() {
    return "MaskTransformation(maskId=" + maskId + ")";
  }

  @Override
  public boolean equals(Object o) {
    return o instanceof MaskTransformation &&
      ((MaskTransformation) o).maskId == maskId;
  }

  @Override
  public int hashCode() {
    return ID.hashCode() + maskId * 10;
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID + maskId).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/RoundedCornersTransformation.java
================================================
package jp.wasabeef.glide.transformations;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;

import androidx.annotation.NonNull;

import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;

import java.security.MessageDigest;

public class RoundedCornersTransformation extends BitmapTransformation {

  private static final int VERSION = 1;
  private static final String ID = "jp.wasabeef.glide.transformations.RoundedCornersTransformation." + VERSION;

  public enum CornerType {
    ALL,
    TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT,
    TOP, BOTTOM, LEFT, RIGHT,
    OTHER_TOP_LEFT, OTHER_TOP_RIGHT, OTHER_BOTTOM_LEFT, OTHER_BOTTOM_RIGHT,
    DIAGONAL_FROM_TOP_LEFT, DIAGONAL_FROM_TOP_RIGHT
  }

  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);
  }

  public RoundedCornersTransformation(int radius, int margin, CornerType cornerType) {
    this.radius = radius;
    this.diameter = this.radius * 2;
    this.margin = margin;
    this.cornerType = cornerType;
  }

  @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();

    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);
    paint.setShader(new BitmapShader(toTransform, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
    drawRoundRect(canvas, paint, width, height);
    return bitmap;
  }

  private void drawRoundRect(Canvas canvas, Paint paint, float width, float height) {
    float right = width - margin;
    float bottom = height - margin;

    switch (cornerType) {
      case ALL:
        canvas.drawRoundRect(new RectF(margin, margin, right, bottom), radius, radius, paint);
        break;
      case TOP_LEFT:
        drawTopLeftRoundRect(canvas, paint, right, bottom);
        break;
      case TOP_RIGHT:
        drawTopRightRoundRect(canvas, paint, right, bottom);
        break;
      case BOTTOM_LEFT:
        drawBottomLeftRoundRect(canvas, paint, right, bottom);
        break;
      case BOTTOM_RIGHT:
        drawBottomRightRoundRect(canvas, paint, right, bottom);
        break;
      case TOP:
        drawTopRoundRect(canvas, paint, right, bottom);
        break;
      case BOTTOM:
        drawBottomRoundRect(canvas, paint, right, bottom);
        break;
      case LEFT:
        drawLeftRoundRect(canvas, paint, right, bottom);
        break;
      case RIGHT:
        drawRightRoundRect(canvas, paint, right, bottom);
        break;
      case OTHER_TOP_LEFT:
        drawOtherTopLeftRoundRect(canvas, paint, right, bottom);
        break;
      case OTHER_TOP_RIGHT:
        drawOtherTopRightRoundRect(canvas, paint, right, bottom);
        break;
      case OTHER_BOTTOM_LEFT:
        drawOtherBottomLeftRoundRect(canvas, paint, right, bottom);
        break;
      case OTHER_BOTTOM_RIGHT:
        drawOtherBottomRightRoundRect(canvas, paint, right, bottom);
        break;
      case DIAGONAL_FROM_TOP_LEFT:
        drawDiagonalFromTopLeftRoundRect(canvas, paint, right, bottom);
        break;
      case DIAGONAL_FROM_TOP_RIGHT:
        drawDiagonalFromTopRightRoundRect(canvas, paint, right, bottom);
        break;
      default:
        canvas.drawRoundRect(new RectF(margin, margin, right, bottom), radius, radius, paint);
        break;
    }
  }

  private void drawTopLeftRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
    canvas.drawRoundRect(new RectF(margin, margin, margin + diameter, margin + diameter), radius,
      radius, paint);
    canvas.drawRect(new RectF(margin, margin + radius, margin + radius, bottom), paint);
    canvas.drawRect(new RectF(margin + radius, margin, right, bottom), paint);
  }

  private void drawTopRightRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
    canvas.drawRoundRect(new RectF(right - diameter, margin, right, margin + diameter), radius,
      radius, paint);
    canvas.drawRect(new RectF(margin, margin, right - radius, bottom), paint);
    canvas.drawRect(new RectF(right - radius, margin + radius, right, bottom), paint);
  }

  private void drawBottomLeftRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
    canvas.drawRoundRect(new RectF(margin, bottom - diameter, margin + diameter, bottom), radius,
      radius, paint);
    canvas.drawRect(new RectF(margin, margin, margin + diameter, bottom - radius), paint);
    canvas.drawRect(new RectF(margin + radius, margin, right, bottom), paint);
  }

  private void drawBottomRightRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
    canvas.drawRoundRect(new RectF(right - diameter, bottom - diameter, right, bottom), radius,
      radius, paint);
    canvas.drawRect(new RectF(margin, margin, right - radius, bottom), paint);
    canvas.drawRect(new RectF(right - radius, margin, right, bottom - radius), paint);
  }

  private void drawTopRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
    canvas.drawRoundRect(new RectF(margin, margin, right, margin + diameter), radius, radius,
      paint);
    canvas.drawRect(new RectF(margin, margin + radius, right, bottom), paint);
  }

  private void drawBottomRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
    canvas.drawRoundRect(new RectF(margin, bottom - diameter, right, bottom), radius, radius,
      paint);
    canvas.drawRect(new RectF(margin, margin, right, bottom - radius), paint);
  }

  private void drawLeftRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
    canvas.drawRoundRect(new RectF(margin, margin, margin + diameter, bottom), radius, radius,
      paint);
    canvas.drawRect(new RectF(margin + radius, margin, right, bottom), paint);
  }

  private void drawRightRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
    canvas.drawRoundRect(new RectF(right - diameter, margin, right, bottom), radius, radius, paint);
    canvas.drawRect(new RectF(margin, margin, right - radius, bottom), paint);
  }

  private void drawOtherTopLeftRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
    canvas.drawRoundRect(new RectF(margin, bottom - diameter, right, bottom), radius, radius,
      paint);
    canvas.drawRoundRect(new RectF(right - diameter, margin, right, bottom), radius, radius, paint);
    canvas.drawRect(new RectF(margin, margin, right - radius, bottom - radius), paint);
  }

  private void drawOtherTopRightRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
    canvas.drawRoundRect(new RectF(margin, margin, margin + diameter, bottom), radius, radius,
      paint);
    canvas.drawRoundRect(new RectF(margin, bottom - diameter, right, bottom), radius, radius,
      paint);
    canvas.drawRect(new RectF(margin + radius, margin, right, bottom - radius), paint);
  }

  private void drawOtherBottomLeftRoundRect(Canvas canvas, Paint paint, float right, float bottom) {
    canvas.drawRoundRect(new RectF(margin, margin, right, margin + diameter), radius, radius,
      paint);
    canvas.drawRoundRect(new RectF(right - diameter, margin, right, bottom), radius, radius, paint);
    canvas.drawRect(new RectF(margin, margin + radius, right - radius, bottom), paint);
  }

  private void drawOtherBottomRightRoundRect(Canvas canvas, Paint paint, float right,
                                             float bottom) {
    canvas.drawRoundRect(new RectF(margin, margin, right, margin + diameter), radius, radius,
      paint);
    canvas.drawRoundRect(new RectF(margin, margin, margin + diameter, bottom), radius, radius,
      paint);
    canvas.drawRect(new RectF(margin + radius, margin + radius, right, bottom), paint);
  }

  private void drawDiagonalFromTopLeftRoundRect(Canvas canvas, Paint paint, float right,
                                                float bottom) {
    canvas.drawRoundRect(new RectF(margin, margin, margin + diameter, margin + diameter), radius,
      radius, paint);
    canvas.drawRoundRect(new RectF(right - diameter, bottom - diameter, right, bottom), radius,
      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,
                                                 float bottom) {
    canvas.drawRoundRect(new RectF(right - diameter, margin, right, margin + diameter), radius,
      radius, paint);
    canvas.drawRoundRect(new RectF(margin, bottom - diameter, margin + diameter, bottom), radius,
      radius, paint);
    canvas.drawRect(new RectF(margin, margin, right - radius, bottom - radius), paint);
    canvas.drawRect(new RectF(margin + radius, margin + radius, right, bottom), paint);
  }

  @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 &&
      ((RoundedCornersTransformation) o).radius == radius &&
      ((RoundedCornersTransformation) o).diameter == diameter &&
      ((RoundedCornersTransformation) o).margin == margin &&
      ((RoundedCornersTransformation) o).cornerType == cornerType;
  }

  @Override
  public int hashCode() {
    return ID.hashCode() + radius * 10000 + diameter * 1000 + margin * 100 + cornerType.ordinal() * 10;
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID + radius + diameter + margin + cornerType).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/BrightnessFilterTransformation.java
================================================
package jp.wasabeef.glide.transformations.gpu;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import androidx.annotation.NonNull;

import java.security.MessageDigest;

import jp.co.cyberagent.android.gpuimage.filter.GPUImageBrightnessFilter;

/**
 * brightness value ranges from -1.0 to 1.0, with 0.0 as the normal level
 */
public class BrightnessFilterTransformation extends GPUFilterTransformation {

  private static final int VERSION = 1;
  private static final String ID =
    "jp.wasabeef.glide.transformations.gpu.BrightnessFilterTransformation." + VERSION;

  private final float brightness;

  public BrightnessFilterTransformation() {
    this(0.0f);
  }

  public BrightnessFilterTransformation(float brightness) {
    super(new GPUImageBrightnessFilter());
    this.brightness = brightness;
    GPUImageBrightnessFilter filter = getFilter();
    filter.setBrightness(this.brightness);
  }

  @Override
  public String toString() {
    return "BrightnessFilterTransformation(brightness=" + brightness + ")";
  }

  @Override
  public boolean equals(Object o) {
    return o instanceof BrightnessFilterTransformation &&
      ((BrightnessFilterTransformation) o).brightness == brightness;
  }

  @Override
  public int hashCode() {
    return ID.hashCode() + (int) ((brightness + 1.0f) * 10);
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID + brightness).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/ContrastFilterTransformation.java
================================================
package jp.wasabeef.glide.transformations.gpu;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import androidx.annotation.NonNull;

import java.security.MessageDigest;

import jp.co.cyberagent.android.gpuimage.filter.GPUImageContrastFilter;

/**
 * contrast value ranges from 0.0 to 4.0, with 1.0 as the normal level
 */
public class ContrastFilterTransformation extends GPUFilterTransformation {

  private static final int VERSION = 1;
  private static final String ID =
    "jp.wasabeef.glide.transformations.gpu.ContrastFilterTransformation." + VERSION;

  private final float contrast;

  public ContrastFilterTransformation() {
    this(1.0f);
  }

  public ContrastFilterTransformation(float contrast) {
    super(new GPUImageContrastFilter());
    this.contrast = contrast;
    GPUImageContrastFilter filter = getFilter();
    filter.setContrast(this.contrast);
  }

  @Override
  public String toString() {
    return "ContrastFilterTransformation(contrast=" + contrast + ")";
  }

  @Override
  public boolean equals(Object o) {
    return o instanceof ContrastFilterTransformation;
  }

  @Override
  public int hashCode() {
    return ID.hashCode() + (int) (contrast * 10);
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID + contrast).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/GPUFilterTransformation.java
================================================
package jp.wasabeef.glide.transformations.gpu;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.content.Context;
import android.graphics.Bitmap;

import 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.filter.GPUImageFilter;
import jp.wasabeef.glide.transformations.BitmapTransformation;

public class GPUFilterTransformation extends BitmapTransformation {

  private static final int VERSION = 1;
  private static final String ID =
    "jp.wasabeef.glide.transformations.gpu.GPUFilterTransformation." + VERSION;
  private static final byte[] ID_BYTES = ID.getBytes(CHARSET);

  private final GPUImageFilter gpuImageFilter;

  public GPUFilterTransformation(GPUImageFilter filter) {
    this.gpuImageFilter = filter;
  }

  @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);
    gpuImage.setFilter(gpuImageFilter);

    return gpuImage.getBitmapWithFilterApplied();
  }

  @Override
  public String toString() {
    return getClass().getSimpleName();
  }

  @SuppressWarnings("unchecked")
  public <T> T getFilter() {
    return (T) gpuImageFilter;
  }

  @Override
  public boolean equals(Object o) {
    return o instanceof GPUFilterTransformation;
  }

  @Override
  public int hashCode() {
    return ID.hashCode();
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update(ID_BYTES);
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/InvertFilterTransformation.java
================================================
package jp.wasabeef.glide.transformations.gpu;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import androidx.annotation.NonNull;

import java.security.MessageDigest;

import jp.co.cyberagent.android.gpuimage.filter.GPUImageColorInvertFilter;

/**
 * Invert all the colors in the image.
 */
public class InvertFilterTransformation extends GPUFilterTransformation {

  private static final int VERSION = 1;
  private static final String ID =
    "jp.wasabeef.glide.transformations.gpu.InvertFilterTransformation." + VERSION;

  public InvertFilterTransformation() {
    super(new GPUImageColorInvertFilter());
  }

  @Override
  public String toString() {
    return "InvertFilterTransformation()";
  }

  @Override
  public boolean equals(Object o) {
    return o instanceof InvertFilterTransformation;
  }

  @Override
  public int hashCode() {
    return ID.hashCode();
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/KuwaharaFilterTransformation.java
================================================
package jp.wasabeef.glide.transformations.gpu;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import androidx.annotation.NonNull;

import java.security.MessageDigest;

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.
 */
public class KuwaharaFilterTransformation extends GPUFilterTransformation {

  private static final int VERSION = 1;
  private static final String ID =
    "jp.wasabeef.glide.transformations.gpu.KuwaharaFilterTransformation." + VERSION;

  private final int radius;

  public KuwaharaFilterTransformation() {
    this(25);
  }

  public KuwaharaFilterTransformation(int radius) {
    super(new GPUImageKuwaharaFilter());
    this.radius = radius;
    GPUImageKuwaharaFilter filter = getFilter();
    filter.setRadius(this.radius);
  }

  @Override
  public String toString() {
    return "KuwaharaFilterTransformation(radius=" + radius + ")";
  }

  @Override
  public boolean equals(Object o) {
    return o instanceof KuwaharaFilterTransformation;
  }

  @Override
  public int hashCode() {
    return ID.hashCode() + radius * 10;
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID + radius).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/PixelationFilterTransformation.java
================================================
package jp.wasabeef.glide.transformations.gpu;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import androidx.annotation.NonNull;

import java.security.MessageDigest;

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 {

  private static final int VERSION = 1;
  private static final String ID =
    "jp.wasabeef.glide.transformations.gpu.PixelationFilterTransformation." + VERSION;

  private final float pixel;

  public PixelationFilterTransformation() {
    this(10f);
  }

  public PixelationFilterTransformation(float pixel) {
    super(new GPUImagePixelationFilter());
    this.pixel = pixel;
    GPUImagePixelationFilter filter = getFilter();
    filter.setPixel(this.pixel);
  }

  @Override
  public String toString() {
    return "PixelationFilterTransformation(pixel=" + pixel + ")";
  }

  @Override
  public boolean equals(Object o) {
    return o instanceof PixelationFilterTransformation;
  }

  @Override
  public int hashCode() {
    return ID.hashCode() + (int) (pixel * 10);
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID + pixel).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/SepiaFilterTransformation.java
================================================
package jp.wasabeef.glide.transformations.gpu;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import androidx.annotation.NonNull;

import java.security.MessageDigest;

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 {

  private static final int VERSION = 1;
  private static final String ID =
    "jp.wasabeef.glide.transformations.gpu.SepiaFilterTransformation." + VERSION;

  private final float intensity;

  public SepiaFilterTransformation() {
    this(1.0f);
  }

  public SepiaFilterTransformation(float intensity) {
    super(new GPUImageSepiaToneFilter());
    this.intensity = intensity;
    GPUImageSepiaToneFilter filter = getFilter();
    filter.setIntensity(this.intensity);
  }

  @Override
  public String toString() {
    return "SepiaFilterTransformation(intensity=" + intensity + ")";
  }

  @Override
  public boolean equals(Object o) {
    return o instanceof SepiaFilterTransformation;
  }

  @Override
  public int hashCode() {
    return ID.hashCode() + (int) (intensity * 10);
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID + intensity).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/SketchFilterTransformation.java
================================================
package jp.wasabeef.glide.transformations.gpu;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import androidx.annotation.NonNull;

import java.security.MessageDigest;

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;

  public SketchFilterTransformation() {
    super(new GPUImageSketchFilter());
  }

  @Override
  public String toString() {
    return "SketchFilterTransformation()";
  }

  @Override
  public boolean equals(Object o) {
    return o instanceof SketchFilterTransformation;
  }

  @Override
  public int hashCode() {
    return ID.hashCode();
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/SwirlFilterTransformation.java
================================================
package jp.wasabeef.glide.transformations.gpu;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.graphics.PointF;

import androidx.annotation.NonNull;

import java.security.MessageDigest;

import jp.co.cyberagent.android.gpuimage.filter.GPUImageSwirlFilter;

/**
 * Creates a swirl distortion on the image.
 */
public class SwirlFilterTransformation extends GPUFilterTransformation {

  private static final int VERSION = 1;
  private static final String ID =
    "jp.wasabeef.glide.transformations.gpu.SwirlFilterTransformation." + VERSION;

  private final float radius;
  private final float angle;
  private final PointF center;

  public SwirlFilterTransformation() {
    this(.5f, 1.0f, new PointF(0.5f, 0.5f));
  }

  /**
   * @param radius from 0.0 to 1.0, default 0.5
   * @param angle  minimum 0.0, default 1.0
   * @param center default (0.5, 0.5)
   */
  public SwirlFilterTransformation(float radius, float angle, PointF center) {
    super(new GPUImageSwirlFilter());
    this.radius = radius;
    this.angle = angle;
    this.center = center;
    GPUImageSwirlFilter filter = getFilter();
    filter.setRadius(this.radius);
    filter.setAngle(this.angle);
    filter.setCenter(this.center);
  }

  @Override
  public String toString() {
    return "SwirlFilterTransformation(radius=" + radius + ",angle=" + angle + ",center="
      + center.toString() + ")";
  }

  @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() + (int) (radius * 1000) + (int) (angle * 10) + center.hashCode();
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID + radius + angle + center.hashCode()).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/ToonFilterTransformation.java
================================================
package jp.wasabeef.glide.transformations.gpu;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import androidx.annotation.NonNull;

import java.security.MessageDigest;

import jp.co.cyberagent.android.gpuimage.filter.GPUImageToonFilter;

/**
 * The threshold at which to apply the edges, default of 0.2.
 * The levels of quantization for the posterization of colors within the scene,
 * with a default of 10.0.
 */
public class ToonFilterTransformation extends GPUFilterTransformation {

  private static final int VERSION = 1;
  private static final String ID =
    "jp.wasabeef.glide.transformations.gpu.ToonFilterTransformation." + VERSION;

  private final float threshold;
  private final float quantizationLevels;

  public ToonFilterTransformation() {
    this(.2f, 10.0f);
  }

  public ToonFilterTransformation(float threshold, float quantizationLevels) {
    super(new GPUImageToonFilter());
    this.threshold = threshold;
    this.quantizationLevels = quantizationLevels;
    GPUImageToonFilter filter = getFilter();
    filter.setThreshold(this.threshold);
    filter.setQuantizationLevels(this.quantizationLevels);
  }

  @Override
  public String toString() {
    return "ToonFilterTransformation(threshold=" + threshold + ",quantizationLevels="
      + quantizationLevels + ")";
  }

  @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() + (int) (threshold * 1000) + (int) (quantizationLevels * 10);
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID + threshold + quantizationLevels).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/VignetteFilterTransformation.java
================================================
package jp.wasabeef.glide.transformations.gpu;

/**
 * Copyright (C) 2020 Wasabeef
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import android.graphics.PointF;

import androidx.annotation.NonNull;

import java.security.MessageDigest;
import java.util.Arrays;

import jp.co.cyberagent.android.gpuimage.filter.GPUImageVignetteFilter;

/**
 * Performs a vignetting effect, fading out the image at the edges
 * The directional intensity of the vignetting,
 * with a default of x = 0.5, y = 0.5, start = 0, end = 0.75
 */
public class VignetteFilterTransformation extends GPUFilterTransformation {

  private static final int VERSION = 1;
  private static final String ID =
    "jp.wasabeef.glide.transformations.gpu.VignetteFilterTransformation." + VERSION;

  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);
  }

  public VignetteFilterTransformation(PointF center, float[] color, float start, float end) {
    super(new GPUImageVignetteFilter());
    this.center = center;
    vignetteColor = color;
    vignetteStart = start;
    vignetteEnd = end;
    GPUImageVignetteFilter filter = getFilter();
    filter.setVignetteCenter(this.center);
    filter.setVignetteColor(vignetteColor);
    filter.setVignetteStart(vignetteStart);
    filter.setVignetteEnd(vignetteEnd);
  }

  @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 &&
      ((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() + center.hashCode() + Arrays.hashCode(vignetteColor) +
      (int) (vignetteStart * 100) + (int) (vignetteEnd * 10);
  }

  @Override
  public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
    messageDigest.update((ID + center + Arrays.hashCode(vignetteColor) + vignetteStart + vignetteEnd).getBytes(CHARSET));
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/internal/FastBlur.java
================================================
package jp.wasabeef.glide.transformations.internal;

import android.graphics.Bitmap;

/**
 * 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 FastBlur {

  public static Bitmap blur(Bitmap sentBitmap, int radius, boolean canReuseInBitmap) {

    // Stack Blur v1.0 from
    // http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html
    //
    // Java Author: Mario Klingemann <mario at quasimondo.com>
    // http://incubator.quasimondo.com
    // created Feburary 29, 2004
    // Android port : Yahel Bouaziz <yahel at kayenko.com>
    // http://www.kayenko.com
    // ported april 5th, 2012

    // This is a compromise between Gaussian Blur and Box blur
    // It creates much better looking blurs than Box Blur, but is
    // 7x faster than my Gaussian Blur implementation.
    //
    // I called it Stack Blur because this describes best how this
    // filter works internally: it creates a kind of moving stack
    // of colors whilst scanning through the image. Thereby it
    // just has to add one new block of color to the right side
    // of the stack and remove the leftmost color. The remaining
    // colors on the topmost layer of the stack are either added on
    // or reduced by one, depending on if they are on the right or
    // on the left side of the stack.
    //
    // If you are using this algorithm in your code please add
    // the following line:
    //
    // Stack Blur Algorithm by Mario Klingemann <mario@quasimondo.com>

    Bitmap bitmap;
    if (canReuseInBitmap) {
      bitmap = sentBitmap;
    } else {
      bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);
    }

    if (radius < 1) {
      return (null);
    }

    int w = bitmap.getWidth();
    int h = bitmap.getHeight();

    int[] pix = new int[w * h];
    bitmap.getPixels(pix, 0, w, 0, 0, w, h);

    int wm = w - 1;
    int hm = h - 1;
    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 rsum, gsum, bsum, x, y, i, p, yp, yi, yw;
    int[] vmin = new int[Math.max(w, h)];

    int divsum = (div + 1) >> 1;
    divsum *= divsum;
    int[] dv = new int[256 * divsum];
    for (i = 0; i < 256 * divsum; i++) {
      dv[i] = (i / divsum);
    }

    yw = yi = 0;

    int[][] stack = new int[div][3];
    int stackpointer;
    int stackstart;
    int[] sir;
    int rbs;
    int r1 = radius + 1;
    int routsum, goutsum, boutsum;
    int rinsum, ginsum, binsum;

    for (y = 0; y < h; y++) {
      rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
      for (i = -radius; i <= radius; i++) {
        p = pix[yi + Math.min(wm, Math.max(i, 0))];
        sir = stack[i + radius];
        sir[0] = (p & 0xff0000) >> 16;
        sir[1] = (p & 0x00ff00) >> 8;
        sir[2] = (p & 0x0000ff);
        rbs = r1 - Math.abs(i);
        rsum += sir[0] * rbs;
        gsum += sir[1] * rbs;
        bsum += sir[2] * rbs;
        if (i > 0) {
          rinsum += sir[0];
          ginsum += sir[1];
          binsum += sir[2];
        } else {
          routsum += sir[0];
          goutsum += sir[1];
          boutsum += sir[2];
        }
      }
      stackpointer = radius;

      for (x = 0; x < w; x++) {

        r[yi] = dv[rsum];
        g[yi] = dv[gsum];
        b[yi] = dv[bsum];

        rsum -= routsum;
        gsum -= goutsum;
        bsum -= boutsum;

        stackstart = stackpointer - radius + div;
        sir = stack[stackstart % div];

        routsum -= sir[0];
        goutsum -= sir[1];
        boutsum -= sir[2];

        if (y == 0) {
          vmin[x] = Math.min(x + radius + 1, wm);
        }
        p = pix[yw + vmin[x]];

        sir[0] = (p & 0xff0000) >> 16;
        sir[1] = (p & 0x00ff00) >> 8;
        sir[2] = (p & 0x0000ff);

        rinsum += sir[0];
        ginsum += sir[1];
        binsum += sir[2];

        rsum += rinsum;
        gsum += ginsum;
        bsum += binsum;

        stackpointer = (stackpointer + 1) % div;
        sir = stack[(stackpointer) % div];

        routsum += sir[0];
        goutsum += sir[1];
        boutsum += sir[2];

        rinsum -= sir[0];
        ginsum -= sir[1];
        binsum -= sir[2];

        yi++;
      }
      yw += w;
    }
    for (x = 0; x < w; x++) {
      rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
      yp = -radius * w;
      for (i = -radius; i <= radius; i++) {
        yi = Math.max(0, yp) + x;

        sir = stack[i + radius];

        sir[0] = r[yi];
        sir[1] = g[yi];
        sir[2] = b[yi];

        rbs = r1 - Math.abs(i);

        rsum += r[yi] * rbs;
        gsum += g[yi] * rbs;
        bsum += b[yi] * rbs;

        if (i > 0) {
          rinsum += sir[0];
          ginsum += sir[1];
          binsum += sir[2];
        } else {
          routsum += sir[0];
          goutsum += sir[1];
          boutsum += sir[2];
        }

        if (i < hm) {
          yp += w;
        }
      }
      yi = x;
      stackpointer = radius;
      for (y = 0; y < h; y++) {
        // Preserve alpha channel: ( 0xff000000 & pix[yi] )
        pix[yi] = (0xff000000 & pix[yi]) | (dv[rsum] << 16) | (dv[gsum] << 8) | dv[bsum];

        rsum -= routsum;
        gsum -= goutsum;
        bsum -= boutsum;

        stackstart = stackpointer - radius + div;
        sir = stack[stackstart % div];

        routsum -= sir[0];
        goutsum -= sir[1];
        boutsum -= sir[2];

        if (x == 0) {
          vmin[y] = Math.min(y + r1, hm) * w;
        }
        p = x + vmin[y];

        sir[0] = r[p];
        sir[1] = g[p];
        sir[2] = b[p];

        rinsum += sir[0];
        ginsum += sir[1];
        binsum += sir[2];

        rsum += rinsum;
        gsum += ginsum;
        bsum += binsum;

        stackpointer = (stackpointer + 1) % div;
        sir = stack[stackpointer];

        routsum += sir[0];
        goutsum += sir[1];
        boutsum += sir[2];

        rinsum -= sir[0];
        ginsum -= sir[1];
        binsum -= sir[2];

        yi += w;
      }
    }

    bitmap.setPixels(pix, 0, w, 0, 0, w, h);

    return (bitmap);
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/internal/RSBlur.java
================================================
package jp.wasabeef.glide.transformations.internal;

import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RSRuntimeException;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;

/**
 * Copyright (C) 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 RSBlur {

  public static Bitmap blur(Context context, Bitmap bitmap, int radius) throws RSRuntimeException {
    RenderScript rs = null;
    Allocation input = null;
    Allocation output = null;
    ScriptIntrinsicBlur blur = null;
    try {
      rs = RenderScript.create(context);
      rs.setMessageHandler(new RenderScript.RSMessageHandler());
      input = Allocation.createFromBitmap(rs, bitmap, Allocation.MipmapControl.MIPMAP_NONE,
        Allocation.USAGE_SCRIPT);
      output = Allocation.createTyped(rs, input.getType());
      blur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));

      blur.setInput(input);
      blur.setRadius(radius);
      blur.forEach(output);
      output.copyTo(bitmap);
    } finally {
      if (rs != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
          RenderScript.releaseAllContexts();
        } else {
          rs.destroy();
        }
      }
      if (input != null) {
        input.destroy();
      }
      if (output != null) {
        output.destroy();
      }
      if (blur != null) {
        blur.destroy();
      }
    }

    return bitmap;
  }
}


================================================
FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/internal/Utils.java
================================================
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) 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 final class Utils {

  private Utils() {
    // Utility class.
  }

  public static int toDp(int px) {
    return px * (int) Resources.getSystem().getDisplayMetrics().density;
  }
}
Download .txt
gitextract_94bctmql/

├── .editorconfig
├── .github/
│   ├── FUNDING.yml
│   ├── ISSUE_TEMPLATE.md
│   └── PULL_REQUEST_TEMPLATE.md
├── .gitignore
├── .idea/
│   ├── codeStyles/
│   │   ├── Project.xml
│   │   └── codeStyleConfig.xml
│   ├── encodings.xml
│   ├── runConfigurations.xml
│   └── vcs.xml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── build.gradle
├── example/
│   ├── build.gradle
│   ├── proguard-rules.pro
│   └── src/
│       └── main/
│           ├── AndroidManifest.xml
│           ├── java/
│           │   └── jp/
│           │       └── wasabeef/
│           │           └── example/
│           │               └── glide/
│           │                   ├── Ext.kt
│           │                   ├── MainActivity.kt
│           │                   └── MainAdapter.kt
│           └── res/
│               ├── layout/
│               │   ├── activity_main.xml
│               │   └── layout_list_item.xml
│               ├── values/
│               │   ├── colors.xml
│               │   ├── dimens.xml
│               │   ├── strings.xml
│               │   └── styles.xml
│               └── values-w820dp/
│                   └── dimens.xml
├── gradle/
│   └── wrapper/
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
├── signingConfigs/
│   ├── debug.gradle
│   └── debug.keystore
└── transformations/
    ├── build.gradle
    ├── proguard-rules.txt
    └── src/
        ├── androidTest/
        │   └── java/
        │       └── jp/
        │           └── wasabeef/
        │               └── glide/
        │                   └── transformations/
        │                       └── ApplicationTest.java
        └── main/
            ├── AndroidManifest.xml
            └── java/
                └── jp/
                    └── wasabeef/
                        └── glide/
                            └── transformations/
                                ├── BitmapTransformation.java
                                ├── BlurTransformation.java
                                ├── ColorFilterTransformation.java
                                ├── CropCircleTransformation.java
                                ├── CropCircleWithBorderTransformation.java
                                ├── CropSquareTransformation.java
                                ├── CropTransformation.java
                                ├── GrayscaleTransformation.java
                                ├── MaskTransformation.java
                                ├── RoundedCornersTransformation.java
                                ├── gpu/
                                │   ├── BrightnessFilterTransformation.java
                                │   ├── ContrastFilterTransformation.java
                                │   ├── GPUFilterTransformation.java
                                │   ├── InvertFilterTransformation.java
                                │   ├── KuwaharaFilterTransformation.java
                                │   ├── PixelationFilterTransformation.java
                                │   ├── SepiaFilterTransformation.java
                                │   ├── SketchFilterTransformation.java
                                │   ├── SwirlFilterTransformation.java
                                │   ├── ToonFilterTransformation.java
                                │   └── VignetteFilterTransformation.java
                                └── internal/
                                    ├── FastBlur.java
                                    ├── RSBlur.java
                                    └── Utils.java
Download .txt
SYMBOL INDEX (174 symbols across 25 files)

FILE: transformations/src/androidTest/java/jp/wasabeef/glide/transformations/ApplicationTest.java
  class ApplicationTest (line 9) | public class ApplicationTest extends ApplicationTestCase<Application> {
    method ApplicationTest (line 11) | public ApplicationTest() {

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/BitmapTransformation.java
  class BitmapTransformation (line 35) | public abstract class BitmapTransformation implements Transformation<Bit...
    method transform (line 37) | @NonNull
    method setCanvasBitmapDensity (line 61) | void setCanvasBitmapDensity(@NonNull Bitmap toTransform, @NonNull Bitm...
    method transform (line 65) | protected abstract Bitmap transform(@NonNull Context context, @NonNull...
    method updateDiskCacheKey (line 68) | @Override
    method equals (line 71) | @Override
    method hashCode (line 74) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/BlurTransformation.java
  class BlurTransformation (line 34) | public class BlurTransformation extends BitmapTransformation {
    method BlurTransformation (line 46) | public BlurTransformation() {
    method BlurTransformation (line 50) | public BlurTransformation(int radius) {
    method BlurTransformation (line 54) | public BlurTransformation(int radius, int sampling) {
    method transform (line 59) | @Override
    method toString (line 87) | @Override
    method equals (line 92) | @Override
    method hashCode (line 99) | @Override
    method updateDiskCacheKey (line 104) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/ColorFilterTransformation.java
  class ColorFilterTransformation (line 32) | public class ColorFilterTransformation extends BitmapTransformation {
    method ColorFilterTransformation (line 40) | public ColorFilterTransformation(int color) {
    method transform (line 44) | @Override
    method toString (line 65) | @Override
    method equals (line 70) | @Override
    method hashCode (line 76) | @Override
    method updateDiskCacheKey (line 81) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/CropCircleTransformation.java
  class CropCircleTransformation (line 33) | @Deprecated
    method transform (line 40) | @Override
    method toString (line 46) | @Override
    method equals (line 51) | @Override
    method hashCode (line 56) | @Override
    method updateDiskCacheKey (line 61) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/CropCircleWithBorderTransformation.java
  class CropCircleWithBorderTransformation (line 35) | public class CropCircleWithBorderTransformation extends BitmapTransforma...
    method CropCircleWithBorderTransformation (line 45) | public CropCircleWithBorderTransformation() {
    method CropCircleWithBorderTransformation (line 50) | public CropCircleWithBorderTransformation(int borderSize, @ColorInt in...
    method transform (line 55) | @Override
    method updateDiskCacheKey (line 80) | @Override
    method equals (line 85) | @Override
    method hashCode (line 92) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/CropSquareTransformation.java
  class CropSquareTransformation (line 29) | public class CropSquareTransformation extends BitmapTransformation {
    method transform (line 37) | @Override
    method toString (line 44) | @Override
    method equals (line 49) | @Override
    method hashCode (line 54) | @Override
    method updateDiskCacheKey (line 59) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/CropTransformation.java
  class CropTransformation (line 30) | public class CropTransformation extends BitmapTransformation {
    type CropType (line 35) | public enum CropType {
    method CropTransformation (line 46) | public CropTransformation(int width, int height) {
    method CropTransformation (line 50) | public CropTransformation(int width, int height, CropType cropType) {
    method transform (line 56) | @Override
    method getTop (line 87) | private float getTop(float scaledHeight) {
    method toString (line 100) | @Override
    method equals (line 105) | @Override
    method hashCode (line 113) | @Override
    method updateDiskCacheKey (line 118) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/GrayscaleTransformation.java
  class GrayscaleTransformation (line 32) | public class GrayscaleTransformation extends BitmapTransformation {
    method transform (line 38) | @Override
    method toString (line 60) | @Override
    method equals (line 65) | @Override
    method hashCode (line 70) | @Override
    method updateDiskCacheKey (line 75) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/MaskTransformation.java
  class MaskTransformation (line 33) | public class MaskTransformation extends BitmapTransformation {
    method MaskTransformation (line 51) | public MaskTransformation(int maskId) {
    method transform (line 55) | @Override
    method toString (line 76) | @Override
    method equals (line 81) | @Override
    method hashCode (line 87) | @Override
    method updateDiskCacheKey (line 92) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/RoundedCornersTransformation.java
  class RoundedCornersTransformation (line 33) | public class RoundedCornersTransformation extends BitmapTransformation {
    type CornerType (line 38) | public enum CornerType {
    method RoundedCornersTransformation (line 51) | public RoundedCornersTransformation(int radius, int margin) {
    method RoundedCornersTransformation (line 55) | public RoundedCornersTransformation(int radius, int margin, CornerType...
    method transform (line 62) | @Override
    method drawRoundRect (line 81) | private void drawRoundRect(Canvas canvas, Paint paint, float width, fl...
    method drawTopLeftRoundRect (line 137) | private void drawTopLeftRoundRect(Canvas canvas, Paint paint, float ri...
    method drawTopRightRoundRect (line 144) | private void drawTopRightRoundRect(Canvas canvas, Paint paint, float r...
    method drawBottomLeftRoundRect (line 151) | private void drawBottomLeftRoundRect(Canvas canvas, Paint paint, float...
    method drawBottomRightRoundRect (line 158) | private void drawBottomRightRoundRect(Canvas canvas, Paint paint, floa...
    method drawTopRoundRect (line 165) | private void drawTopRoundRect(Canvas canvas, Paint paint, float right,...
    method drawBottomRoundRect (line 171) | private void drawBottomRoundRect(Canvas canvas, Paint paint, float rig...
    method drawLeftRoundRect (line 177) | private void drawLeftRoundRect(Canvas canvas, Paint paint, float right...
    method drawRightRoundRect (line 183) | private void drawRightRoundRect(Canvas canvas, Paint paint, float righ...
    method drawOtherTopLeftRoundRect (line 188) | private void drawOtherTopLeftRoundRect(Canvas canvas, Paint paint, flo...
    method drawOtherTopRightRoundRect (line 195) | private void drawOtherTopRightRoundRect(Canvas canvas, Paint paint, fl...
    method drawOtherBottomLeftRoundRect (line 203) | private void drawOtherBottomLeftRoundRect(Canvas canvas, Paint paint, ...
    method drawOtherBottomRightRoundRect (line 210) | private void drawOtherBottomRightRoundRect(Canvas canvas, Paint paint,...
    method drawDiagonalFromTopLeftRoundRect (line 219) | private void drawDiagonalFromTopLeftRoundRect(Canvas canvas, Paint pai...
    method drawDiagonalFromTopRightRoundRect (line 229) | private void drawDiagonalFromTopRightRoundRect(Canvas canvas, Paint pa...
    method toString (line 239) | @Override
    method equals (line 245) | @Override
    method hashCode (line 254) | @Override
    method updateDiskCacheKey (line 259) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/BrightnessFilterTransformation.java
  class BrightnessFilterTransformation (line 28) | public class BrightnessFilterTransformation extends GPUFilterTransformat...
    method BrightnessFilterTransformation (line 36) | public BrightnessFilterTransformation() {
    method BrightnessFilterTransformation (line 40) | public BrightnessFilterTransformation(float brightness) {
    method toString (line 47) | @Override
    method equals (line 52) | @Override
    method hashCode (line 58) | @Override
    method updateDiskCacheKey (line 63) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/ContrastFilterTransformation.java
  class ContrastFilterTransformation (line 28) | public class ContrastFilterTransformation extends GPUFilterTransformation {
    method ContrastFilterTransformation (line 36) | public ContrastFilterTransformation() {
    method ContrastFilterTransformation (line 40) | public ContrastFilterTransformation(float contrast) {
    method toString (line 47) | @Override
    method equals (line 52) | @Override
    method hashCode (line 57) | @Override
    method updateDiskCacheKey (line 62) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/GPUFilterTransformation.java
  class GPUFilterTransformation (line 32) | public class GPUFilterTransformation extends BitmapTransformation {
    method GPUFilterTransformation (line 41) | public GPUFilterTransformation(GPUImageFilter filter) {
    method transform (line 45) | @Override
    method toString (line 55) | @Override
    method getFilter (line 60) | @SuppressWarnings("unchecked")
    method equals (line 65) | @Override
    method hashCode (line 70) | @Override
    method updateDiskCacheKey (line 75) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/InvertFilterTransformation.java
  class InvertFilterTransformation (line 28) | public class InvertFilterTransformation extends GPUFilterTransformation {
    method InvertFilterTransformation (line 34) | public InvertFilterTransformation() {
    method toString (line 38) | @Override
    method equals (line 43) | @Override
    method hashCode (line 48) | @Override
    method updateDiskCacheKey (line 53) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/KuwaharaFilterTransformation.java
  class KuwaharaFilterTransformation (line 31) | public class KuwaharaFilterTransformation extends GPUFilterTransformation {
    method KuwaharaFilterTransformation (line 39) | public KuwaharaFilterTransformation() {
    method KuwaharaFilterTransformation (line 43) | public KuwaharaFilterTransformation(int radius) {
    method toString (line 50) | @Override
    method equals (line 55) | @Override
    method hashCode (line 60) | @Override
    method updateDiskCacheKey (line 65) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/PixelationFilterTransformation.java
  class PixelationFilterTransformation (line 30) | public class PixelationFilterTransformation extends GPUFilterTransformat...
    method PixelationFilterTransformation (line 38) | public PixelationFilterTransformation() {
    method PixelationFilterTransformation (line 42) | public PixelationFilterTransformation(float pixel) {
    method toString (line 49) | @Override
    method equals (line 54) | @Override
    method hashCode (line 59) | @Override
    method updateDiskCacheKey (line 64) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/SepiaFilterTransformation.java
  class SepiaFilterTransformation (line 30) | public class SepiaFilterTransformation extends GPUFilterTransformation {
    method SepiaFilterTransformation (line 38) | public SepiaFilterTransformation() {
    method SepiaFilterTransformation (line 42) | public SepiaFilterTransformation(float intensity) {
    method toString (line 49) | @Override
    method equals (line 54) | @Override
    method hashCode (line 59) | @Override
    method updateDiskCacheKey (line 64) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/SketchFilterTransformation.java
  class SketchFilterTransformation (line 25) | public class SketchFilterTransformation extends GPUFilterTransformation {
    method SketchFilterTransformation (line 31) | public SketchFilterTransformation() {
    method toString (line 35) | @Override
    method equals (line 40) | @Override
    method hashCode (line 45) | @Override
    method updateDiskCacheKey (line 50) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/SwirlFilterTransformation.java
  class SwirlFilterTransformation (line 30) | public class SwirlFilterTransformation extends GPUFilterTransformation {
    method SwirlFilterTransformation (line 40) | public SwirlFilterTransformation() {
    method SwirlFilterTransformation (line 49) | public SwirlFilterTransformation(float radius, float angle, PointF cen...
    method toString (line 60) | @Override
    method equals (line 66) | @Override
    method hashCode (line 74) | @Override
    method updateDiskCacheKey (line 79) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/ToonFilterTransformation.java
  class ToonFilterTransformation (line 30) | public class ToonFilterTransformation extends GPUFilterTransformation {
    method ToonFilterTransformation (line 39) | public ToonFilterTransformation() {
    method ToonFilterTransformation (line 43) | public ToonFilterTransformation(float threshold, float quantizationLev...
    method toString (line 52) | @Override
    method equals (line 58) | @Override
    method hashCode (line 65) | @Override
    method updateDiskCacheKey (line 70) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/VignetteFilterTransformation.java
  class VignetteFilterTransformation (line 33) | public class VignetteFilterTransformation extends GPUFilterTransformation {
    method VignetteFilterTransformation (line 44) | public VignetteFilterTransformation() {
    method VignetteFilterTransformation (line 48) | public VignetteFilterTransformation(PointF center, float[] color, floa...
    method toString (line 61) | @Override
    method equals (line 67) | @Override
    method hashCode (line 76) | @Override
    method updateDiskCacheKey (line 82) | @Override

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/internal/FastBlur.java
  class FastBlur (line 21) | public class FastBlur {
    method blur (line 23) | public static Bitmap blur(Bitmap sentBitmap, int radius, boolean canRe...

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/internal/RSBlur.java
  class RSBlur (line 29) | public class RSBlur {
    method blur (line 31) | public static Bitmap blur(Context context, Bitmap bitmap, int radius) ...

FILE: transformations/src/main/java/jp/wasabeef/glide/transformations/internal/Utils.java
  class Utils (line 24) | public final class Utils {
    method Utils (line 26) | private Utils() {
    method toDp (line 30) | public static int toDp(int px) {
Condensed preview — 63 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (133K chars).
[
  {
    "path": ".editorconfig",
    "chars": 116,
    "preview": "[*]\nindent_size = 2\nmax_line_length = off\ninsert_final_newline = true\n\n[*.{kt, kts}]\nkotlin_imports_layout = ascii\n\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "chars": 720,
    "preview": "# These are supported funding model platforms\n\ngithub: wasabeef # Replace with up to 4 GitHub Sponsors-enabled usernames"
  },
  {
    "path": ".github/ISSUE_TEMPLATE.md",
    "chars": 351,
    "preview": "# Future Task\n\n## What is the motivation?\n\n## What kind of solution can be considered?\n\n## What do you want to discuss?\n"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "chars": 102,
    "preview": "## What does this change?\n\n## What is the value of this and can you measure success?\n\n## Screenshots\n\n"
  },
  {
    "path": ".gitignore",
    "chars": 1019,
    "preview": "# Mac OS\n.DS_store\n\n# Built application files\n*.apk\n*.ap_\n\n# Files for the ART/Dalvik VM\n*.dex\n\n# Java class files\n*.cla"
  },
  {
    "path": ".idea/codeStyles/Project.xml",
    "chars": 3309,
    "preview": "<component name=\"ProjectCodeStyleConfiguration\">\n  <code_scheme name=\"Project\" version=\"173\">\n    <codeStyleSettings lan"
  },
  {
    "path": ".idea/codeStyles/codeStyleConfig.xml",
    "chars": 149,
    "preview": "<component name=\"ProjectCodeStyleConfiguration\">\n  <state>\n    <option name=\"PREFERRED_PROJECT_CODE_STYLE\" value=\"Defaul"
  },
  {
    "path": ".idea/encodings.xml",
    "chars": 135,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"Encoding\" addBOMForNewFiles=\"with NO BOM"
  },
  {
    "path": ".idea/runConfigurations.xml",
    "chars": 686,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"RunConfigurationProducerService\">\n    <o"
  },
  {
    "path": ".idea/vcs.xml",
    "chars": 167,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"VcsDirectoryMappings\">\n    <mapping dire"
  },
  {
    "path": "CHANGELOG.md",
    "chars": 5104,
    "preview": "Change Log\n==========\n\nVersion 4.3.0 *(2020-09-27)*\n----------------------------\n\nFeature\n- Remove support v8 renderscri"
  },
  {
    "path": "LICENSE",
    "chars": 11325,
    "preview": "Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licens"
  },
  {
    "path": "README.md",
    "chars": 4745,
    "preview": "Glide Transformations\n======================\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-glide--t"
  },
  {
    "path": "build.gradle",
    "chars": 769,
    "preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n  ext"
  },
  {
    "path": "example/build.gradle",
    "chars": 1328,
    "preview": "apply plugin: 'com.android.application'\napply plugin: 'kotlin-android'\napply plugin: 'kotlin-kapt'\n\nandroid {\n  compileS"
  },
  {
    "path": "example/proguard-rules.pro",
    "chars": 0,
    "preview": ""
  },
  {
    "path": "example/src/main/AndroidManifest.xml",
    "chars": 713,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n  xmlns:tool"
  },
  {
    "path": "example/src/main/java/jp/wasabeef/example/glide/Ext.kt",
    "chars": 838,
    "preview": "package jp.wasabeef.example.glide\n\n/**\n * Copyright (C) 2020 Wasabeef\n *\n * Licensed under the Apache License, Version 2"
  },
  {
    "path": "example/src/main/java/jp/wasabeef/example/glide/MainActivity.kt",
    "chars": 879,
    "preview": "package jp.wasabeef.example.glide\n\nimport android.os.Bundle\nimport androidx.appcompat.app.AppCompatActivity\nimport andro"
  },
  {
    "path": "example/src/main/java/jp/wasabeef/example/glide/MainAdapter.kt",
    "chars": 6469,
    "preview": "package jp.wasabeef.example.glide\n\nimport android.content.Context\nimport android.graphics.Bitmap\nimport android.graphics"
  },
  {
    "path": "example/src/main/res/layout/activity_main.xml",
    "chars": 667,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<androidx.constraintlayout.widget.ConstraintLayout xmlns:android=\"http://schemas."
  },
  {
    "path": "example/src/main/res/layout/layout_list_item.xml",
    "chars": 1237,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<androidx.constraintlayout.widget.ConstraintLayout xmlns:android=\"http://schemas."
  },
  {
    "path": "example/src/main/res/values/colors.xml",
    "chars": 202,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n  <color name=\"colorPrimary\">#3F51B5</color>\n  <color name=\"colorPrim"
  },
  {
    "path": "example/src/main/res/values/dimens.xml",
    "chars": 205,
    "preview": "<resources>\n  <!-- Default screen margins, per the Android Design guidelines. -->\n  <dimen name=\"activity_horizontal_mar"
  },
  {
    "path": "example/src/main/res/values/strings.xml",
    "chars": 225,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n  <string name=\"app_name\">glide-transformations</string>\n  <string n"
  },
  {
    "path": "example/src/main/res/values/styles.xml",
    "chars": 360,
    "preview": "<resources>\n\n  <!-- Base application theme. -->\n  <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\">\n "
  },
  {
    "path": "example/src/main/res/values-w820dp/dimens.xml",
    "chars": 350,
    "preview": "<resources>\n  <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n       (such as scree"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "chars": 201,
    "preview": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https://services.gradle.org/distributio"
  },
  {
    "path": "gradle.properties",
    "chars": 465,
    "preview": "org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8\norg.gradle.para"
  },
  {
    "path": "gradlew",
    "chars": 5766,
    "preview": "#!/usr/bin/env sh\n\n#\n# Copyright 2015 the original author or authors.\n#\n# Licensed under the Apache License, Version 2.0"
  },
  {
    "path": "gradlew.bat",
    "chars": 2763,
    "preview": "@rem\r\n@rem Copyright 2015 the original author or authors.\r\n@rem\r\n@rem Licensed under the Apache License, Version 2.0 (th"
  },
  {
    "path": "settings.gradle",
    "chars": 39,
    "preview": "include ':example', ':transformations'\n"
  },
  {
    "path": "signingConfigs/debug.gradle",
    "chars": 450,
    "preview": "signingConfigs {\n  debug {\n    storeFile file(\"debug.keystore\")\n    storePassword \"android\"\n    keyAlias \"androiddebugke"
  },
  {
    "path": "transformations/build.gradle",
    "chars": 1726,
    "preview": "apply plugin: 'com.android.library'\n\nandroid {\n  compileSdkVersion COMPILE_SDK_VERSION as int\n\n  defaultConfig {\n    min"
  },
  {
    "path": "transformations/proguard-rules.txt",
    "chars": 283,
    "preview": "-dontwarn jp.co.cyberagent.android.gpuimage.**\n\n-keep public class * implements com.bumptech.glide.module.GlideModule\n-k"
  },
  {
    "path": "transformations/src/androidTest/java/jp/wasabeef/glide/transformations/ApplicationTest.java",
    "chars": 357,
    "preview": "package jp.wasabeef.glide.transformations;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\n/*"
  },
  {
    "path": "transformations/src/main/AndroidManifest.xml",
    "chars": 57,
    "preview": "<manifest package=\"jp.wasabeef.glide.transformations\" />\n"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/BitmapTransformation.java",
    "chars": 2892,
    "preview": "package jp.wasabeef.glide.transformations;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * Copyright 2014 Google, Inc. All rights"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/BlurTransformation.java",
    "chars": 3228,
    "preview": "package jp.wasabeef.glide.transformations;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache Licen"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/ColorFilterTransformation.java",
    "chars": 2577,
    "preview": "package jp.wasabeef.glide.transformations;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache Licen"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/CropCircleTransformation.java",
    "chars": 1942,
    "preview": "package jp.wasabeef.glide.transformations;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache Licen"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/CropCircleWithBorderTransformation.java",
    "chars": 2958,
    "preview": "package jp.wasabeef.glide.transformations;\n\nimport android.content.Context;\nimport android.graphics.Bitmap;\nimport andro"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/CropSquareTransformation.java",
    "chars": 1958,
    "preview": "package jp.wasabeef.glide.transformations;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache Licen"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/CropTransformation.java",
    "chars": 3629,
    "preview": "package jp.wasabeef.glide.transformations;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache Licen"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/GrayscaleTransformation.java",
    "chars": 2402,
    "preview": "package jp.wasabeef.glide.transformations;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache Licen"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/MaskTransformation.java",
    "chars": 2916,
    "preview": "package jp.wasabeef.glide.transformations;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache Licen"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/RoundedCornersTransformation.java",
    "chars": 10909,
    "preview": "package jp.wasabeef.glide.transformations;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache Licen"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/BrightnessFilterTransformation.java",
    "chars": 2023,
    "preview": "package jp.wasabeef.glide.transformations.gpu;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache L"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/ContrastFilterTransformation.java",
    "chars": 1902,
    "preview": "package jp.wasabeef.glide.transformations.gpu;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache L"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/GPUFilterTransformation.java",
    "chars": 2313,
    "preview": "package jp.wasabeef.glide.transformations.gpu;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache L"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/InvertFilterTransformation.java",
    "chars": 1578,
    "preview": "package jp.wasabeef.glide.transformations.gpu;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache L"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/KuwaharaFilterTransformation.java",
    "chars": 1984,
    "preview": "package jp.wasabeef.glide.transformations.gpu;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache L"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/PixelationFilterTransformation.java",
    "chars": 1907,
    "preview": "package jp.wasabeef.glide.transformations.gpu;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache L"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/SepiaFilterTransformation.java",
    "chars": 1907,
    "preview": "package jp.wasabeef.glide.transformations.gpu;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache L"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/SketchFilterTransformation.java",
    "chars": 1521,
    "preview": "package jp.wasabeef.glide.transformations.gpu;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache L"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/SwirlFilterTransformation.java",
    "chars": 2558,
    "preview": "package jp.wasabeef.glide.transformations.gpu;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache L"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/ToonFilterTransformation.java",
    "chars": 2410,
    "preview": "package jp.wasabeef.glide.transformations.gpu;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache L"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/gpu/VignetteFilterTransformation.java",
    "chars": 3056,
    "preview": "package jp.wasabeef.glide.transformations.gpu;\n\n/**\n * Copyright (C) 2020 Wasabeef\n * <p>\n * Licensed under the Apache L"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/internal/FastBlur.java",
    "chars": 6683,
    "preview": "package jp.wasabeef.glide.transformations.internal;\n\nimport android.graphics.Bitmap;\n\n/**\n * Copyright (C) 2020 Wasabeef"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/internal/RSBlur.java",
    "chars": 2148,
    "preview": "package jp.wasabeef.glide.transformations.internal;\n\nimport android.annotation.TargetApi;\nimport android.content.Context"
  },
  {
    "path": "transformations/src/main/java/jp/wasabeef/glide/transformations/internal/Utils.java",
    "chars": 987,
    "preview": "package jp.wasabeef.glide.transformations.internal;\n\nimport android.content.Context;\nimport android.content.res.Resource"
  }
]

// ... and 2 more files (download for full content)

About this extraction

This page contains the full source code of the wasabeef/glide-transformations GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 63 files (119.8 KB), approximately 31.7k tokens, and a symbol index with 174 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!