├── .editorconfig ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── art ├── demo-org.jpg ├── demo.gif └── logo.png ├── build.gradle ├── example ├── build.gradle └── src │ ├── androidTest │ └── java │ │ └── jp │ │ └── wasabeef │ │ └── example │ │ └── fresco │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── jp │ │ └── wasabeef │ │ └── example │ │ └── fresco │ │ ├── MainActivity.java │ │ └── MainAdapter.java │ └── res │ ├── drawable-xxhdpi │ ├── demo.jpg │ ├── mask_chat_right.9.png │ └── mask_starfish.png │ ├── layout │ ├── activity_main.xml │ └── layout_list_item.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ └── values │ ├── strings.xml │ └── styles.xml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── processors ├── build.gradle ├── proguard-rules.txt └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── jp │ └── wasabeef │ └── fresco │ └── processors │ ├── BlurPostprocessor.java │ ├── ColorFilterPostprocessor.java │ ├── CombinePostProcessors.java │ ├── GrayscalePostprocessor.java │ ├── MaskPostprocessor.java │ ├── gpu │ ├── BrightnessFilterPostprocessor.java │ ├── ContrastFilterPostprocessor.java │ ├── GPUFilterPostprocessor.java │ ├── InvertFilterPostprocessor.java │ ├── KuawaharaFilterPostprocessor.java │ ├── PixelationFilterPostprocessor.java │ ├── SepiaFilterPostprocessor.java │ ├── SketchFilterPostprocessor.java │ ├── SwirlFilterPostprocessor.java │ ├── ToonFilterPostprocessor.java │ └── VignetteFilterPostprocessor.java │ └── internal │ ├── FastBlur.java │ └── RSBlur.java ├── settings.gradle └── signingConfigs ├── debug.gradle └── debug.keystore /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | indent_size = 2 3 | max_line_length = off 4 | insert_final_newline = true 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Thumbs.db 3 | 4 | # gradle files 5 | .gradle 6 | 7 | # Intellij project files 8 | .idea 9 | *.iml 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | obj/ 15 | apk/ 16 | target/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Change Log 2 | ========== 3 | 4 | Version 2.2.1 *(2020-09-27)* 5 | ---------------------------- 6 | 7 | Update: 8 | - GPUImage for Android 2.1.0 9 | 10 | Version 2.2.0 *(2020-09-27)* 11 | ---------------------------- 12 | 13 | Update: 14 | - Compile & Target SDK Version -> 30 15 | - Use AndroidX 16 | - Fresco -> 2.3.0 17 | - GPUImage for Android 2.0.4 18 | - Code cleanup 19 | 20 | Version 2.1.0 *(2017-03-21)* 21 | ---------------------------- 22 | 23 | Update: 24 | - Compile & Target SDK Version 23 -> 25 25 | - Build Tools 23.0.2 -> 25.0.2 26 | - Support Library 23.2.1 -> 25.3.0 27 | - GPUImage for Android 1.3.0 -> 1.4.1 28 | - Fresco 0.9.0 -> 1.1.0 29 | 30 | Bug Fix: 31 | - Additional resource cleanup in RSBlur. 32 | 33 | Version 2.0.0 *(2016-03-04)* 34 | ---------------------------- 35 | 36 | Say v8.RenderScript goodbye 37 | 38 | Version 1.2.0 *(2016-02-28)* 39 | ---------------------------- 40 | 41 | Use FastBlur as a fallback upon RenderScript failure. 42 | 43 | Version 1.1.1 *(2015-11-27)* 44 | ---------------------------- 45 | 46 | Change the renderscriptTargetApi down to 20. 47 | Warning:Renderscript support mode is not currently supported with renderscript target 21+ 48 | 49 | fix: memory leak. 50 | 51 | Version 1.1.0 *(2015-11-12)* 52 | ---------------------------- 53 | 54 | Bug fix [#1](https://github.com/wasabeef/fresco-processors/issues/1) 55 | Add Sampling Property to BlurPostprocessor. 56 | 57 | Version 1.0.0 *(2015-09-21)* 58 | ---------------------------- 59 | 60 | Initial release. 61 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 |
4 |

DEPRECATED

5 | Fresco Processors is deprecated. No more development will be taking place. For an up-to-date version, 6 | please use Transformers. Thanks for all your support! 7 |
10 |

11 | 12 | Fresco Processors 13 | ====================== 14 | [![License](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) 15 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/jp.wasabeef/fresco-processors/badge.svg)](https://search.maven.org/artifact/jp.wasabeef/fresco-processors) 16 | 17 | An Android image processor library providing a variety of transformations for [Fresco](https://github.com/facebook/fresco). 18 | 19 |

20 | 21 |

22 | 23 | #### Are you using Picasso or Glide? 24 | [Picasso Transformations](https://github.com/wasabeef/picasso-transformations) 25 | [Glide Transformations](https://github.com/wasabeef/glide-transformations) 26 | 27 | # Demo 28 | 29 | ### Original Image 30 | 31 | 32 | ### Processors 33 | 34 | 35 | # How do I use it? 36 | 37 | ## Step 1 38 | 39 | #### Gradle 40 | ```groovy 41 | repositories { 42 | mavenCentral() 43 | } 44 | 45 | dependencies { 46 | implementation 'jp.wasabeef:fresco-processors:2.2.1' 47 | // If you want to use the GPU Filters 48 | implementation 'jp.co.cyberagent.android:gpuimage:2.1.0' 49 | } 50 | ``` 51 | 52 | ## Step 2 53 | 54 | Set Fresco Postprocessor. 55 | 56 | ```java 57 | ImageRequest request = 58 | ImageRequestBuilder.newBuilderWithResourceId(R.drawable.demo) 59 | .setPostprocessor(processor) 60 | .build(); 61 | 62 | PipelineDraweeController controller = 63 | (PipelineDraweeController) Fresco.newDraweeControllerBuilder() 64 | .setImageRequest(request) 65 | .setOldController(holder.drawee.getController()) 66 | .build(); 67 | ``` 68 | 69 | ## Processors 70 | 71 | ### Color 72 | `ColorFilterPostprocessor`, `GrayscalePostprocessor` 73 | 74 | ### Blur 75 | `BlurPostprocessor` 76 | 77 | ### Mask 78 | `MaskProcessors` 79 | 80 | ### GPU Filter (use [GPUImage](https://github.com/CyberAgent/android-gpuimage)) 81 | **Will require add dependencies for GPUImage.** 82 | 83 | `ToonFilterPostprocessor`, `SepiaFilterPostprocessor`, `ContrastFilterPostprocessor` 84 | `InvertFilterPostprocessor`, `PixelationFilterPostprocessor`, `SketchFilterPostprocessor` 85 | `SwirlFilterPostprocessor`, `BrightnessFilterPostprocessor`, `KuawaharaFilterPostprocessor` 86 | `VignetteFilterPostprocessor` 87 | 88 | ## Combine Processors 89 | ```java 90 | processor = new CombinePostProcessors.Builder() 91 | .add(new BlurPostprocessor(context)) 92 | .add(new GrayscalePostprocessor()) 93 | .build(); 94 | ``` 95 | 96 | Developed By 97 | ------- 98 | Daichi Furiya (Wasabeef) - 99 | 100 | 101 | Follow me on Twitter 103 | 104 | 105 | Contributions 106 | ------- 107 | 108 | Any contributions are welcome! 109 | 110 | License 111 | ------- 112 | 113 | Copyright (C) 2020 Wasabeef 114 | 115 | Licensed under the Apache License, Version 2.0 (the "License"); 116 | you may not use this file except in compliance with the License. 117 | You may obtain a copy of the License at 118 | 119 | http://www.apache.org/licenses/LICENSE-2.0 120 | 121 | Unless required by applicable law or agreed to in writing, software 122 | distributed under the License is distributed on an "AS IS" BASIS, 123 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124 | See the License for the specific language governing permissions and 125 | limitations under the License. 126 | -------------------------------------------------------------------------------- /art/demo-org.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/fresco-processors/465c39b2f0454e38f473bf9dbcbb6e0a0d8d1b53/art/demo-org.jpg -------------------------------------------------------------------------------- /art/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/fresco-processors/465c39b2f0454e38f473bf9dbcbb6e0a0d8d1b53/art/demo.gif -------------------------------------------------------------------------------- /art/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/fresco-processors/465c39b2f0454e38f473bf9dbcbb6e0a0d8d1b53/art/logo.png -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | google() 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.2.0-beta04' 10 | 11 | // TODO: Close JCenter on May 1st https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/ 12 | // classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5' 13 | // classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | mavenCentral() 21 | jcenter() 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion COMPILE_SDK_VERSION as int 5 | 6 | defaultConfig { 7 | minSdkVersion MIN_SDK_VERSION as int 8 | targetSdkVersion TARGET_SDK_VERSION as int 9 | versionCode VERSION_CODE as int 10 | versionName VERSION_NAME 11 | } 12 | 13 | // SigningConfigs 14 | apply from: '../signingConfigs/debug.gradle', to: android 15 | 16 | buildTypes { 17 | debug { 18 | debuggable true 19 | signingConfig signingConfigs.debug 20 | } 21 | release { 22 | debuggable false 23 | zipAlignEnabled true 24 | minifyEnabled true 25 | shrinkResources true 26 | } 27 | } 28 | } 29 | 30 | repositories { 31 | // maven { url = "https://oss.sonatype.org/content/repositories/snapshots"} 32 | } 33 | 34 | dependencies { 35 | implementation project(':processors') 36 | implementation "com.facebook.fresco:fresco:${FRESCO_VERSION}" 37 | implementation "jp.co.cyberagent.android:gpuimage:${GPUIMAGE_VERSION}" 38 | implementation "androidx.appcompat:appcompat:1.3.0-beta01" 39 | implementation "androidx.recyclerview:recyclerview:1.2.0-beta01" 40 | } 41 | -------------------------------------------------------------------------------- /example/src/androidTest/java/jp/wasabeef/example/fresco/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.example.fresco; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | 11 | public ApplicationTest() { 12 | super(Application.class); 13 | } 14 | } -------------------------------------------------------------------------------- /example/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 15 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /example/src/main/java/jp/wasabeef/example/fresco/MainActivity.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.example.fresco; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.os.Bundle; 20 | 21 | import androidx.appcompat.app.AppCompatActivity; 22 | import androidx.recyclerview.widget.GridLayoutManager; 23 | import androidx.recyclerview.widget.RecyclerView; 24 | 25 | import com.facebook.drawee.backends.pipeline.Fresco; 26 | 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | 30 | import jp.wasabeef.example.fresco.MainAdapter.Type; 31 | 32 | public class MainActivity extends AppCompatActivity { 33 | 34 | @Override 35 | protected void onCreate(Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | Fresco.initialize(this); 38 | setContentView(R.layout.activity_main); 39 | 40 | RecyclerView recyclerView = findViewById(R.id.list); 41 | recyclerView.setLayoutManager(new GridLayoutManager(this, 2)); 42 | recyclerView.setHasFixedSize(true); 43 | 44 | List dataSet = new ArrayList<>(); 45 | dataSet.add(Type.BlurAndGrayscale); 46 | dataSet.add(Type.Blur); 47 | dataSet.add(Type.Grayscale); 48 | dataSet.add(Type.ColorFilter); 49 | dataSet.add(Type.Mask); 50 | dataSet.add(Type.NinePatchMask); 51 | dataSet.add(Type.Pixel); 52 | dataSet.add(Type.Vignette); 53 | dataSet.add(Type.Kuawahara); 54 | dataSet.add(Type.Brightness); 55 | dataSet.add(Type.Swirl); 56 | dataSet.add(Type.Sketch); 57 | dataSet.add(Type.Invert); 58 | dataSet.add(Type.Contrast); 59 | dataSet.add(Type.Sepia); 60 | dataSet.add(Type.Toon); 61 | 62 | recyclerView.setAdapter(new MainAdapter(this, dataSet)); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /example/src/main/java/jp/wasabeef/example/fresco/MainAdapter.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.example.fresco; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.content.Context; 20 | import android.graphics.Color; 21 | import android.graphics.PointF; 22 | import android.view.LayoutInflater; 23 | import android.view.View; 24 | import android.view.ViewGroup; 25 | import android.widget.TextView; 26 | 27 | import androidx.annotation.NonNull; 28 | import androidx.recyclerview.widget.RecyclerView; 29 | 30 | import com.facebook.drawee.backends.pipeline.Fresco; 31 | import com.facebook.drawee.backends.pipeline.PipelineDraweeController; 32 | import com.facebook.drawee.drawable.ScalingUtils; 33 | import com.facebook.drawee.view.SimpleDraweeView; 34 | import com.facebook.imagepipeline.request.ImageRequest; 35 | import com.facebook.imagepipeline.request.ImageRequestBuilder; 36 | import com.facebook.imagepipeline.request.Postprocessor; 37 | 38 | import java.util.List; 39 | 40 | import jp.wasabeef.fresco.processors.BlurPostprocessor; 41 | import jp.wasabeef.fresco.processors.ColorFilterPostprocessor; 42 | import jp.wasabeef.fresco.processors.CombinePostProcessors; 43 | import jp.wasabeef.fresco.processors.GrayscalePostprocessor; 44 | import jp.wasabeef.fresco.processors.MaskPostprocessor; 45 | import jp.wasabeef.fresco.processors.gpu.BrightnessFilterPostprocessor; 46 | import jp.wasabeef.fresco.processors.gpu.ContrastFilterPostprocessor; 47 | import jp.wasabeef.fresco.processors.gpu.InvertFilterPostprocessor; 48 | import jp.wasabeef.fresco.processors.gpu.KuawaharaFilterPostprocessor; 49 | import jp.wasabeef.fresco.processors.gpu.PixelationFilterPostprocessor; 50 | import jp.wasabeef.fresco.processors.gpu.SepiaFilterPostprocessor; 51 | import jp.wasabeef.fresco.processors.gpu.SketchFilterPostprocessor; 52 | import jp.wasabeef.fresco.processors.gpu.SwirlFilterPostprocessor; 53 | import jp.wasabeef.fresco.processors.gpu.ToonFilterPostprocessor; 54 | import jp.wasabeef.fresco.processors.gpu.VignetteFilterPostprocessor; 55 | 56 | public class MainAdapter extends RecyclerView.Adapter { 57 | 58 | private final Context context; 59 | private final List dataSet; 60 | 61 | enum Type { 62 | Mask, 63 | NinePatchMask, 64 | ColorFilter, 65 | Grayscale, 66 | Blur, 67 | Toon, 68 | Sepia, 69 | Contrast, 70 | Invert, 71 | Pixel, 72 | Sketch, 73 | Swirl, 74 | Brightness, 75 | Kuawahara, 76 | Vignette, 77 | BlurAndGrayscale 78 | } 79 | 80 | public MainAdapter(Context context, List dataSet) { 81 | this.context = context; 82 | this.dataSet = dataSet; 83 | } 84 | 85 | @NonNull 86 | @Override 87 | public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 88 | View v = LayoutInflater.from(context).inflate(R.layout.layout_list_item, parent, false); 89 | return new ViewHolder(v); 90 | } 91 | 92 | @Override 93 | public void onBindViewHolder(MainAdapter.ViewHolder holder, int position) { 94 | Context context = holder.itemView.getContext(); 95 | Postprocessor processor = null; 96 | 97 | holder.drawee.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP); 98 | 99 | switch (dataSet.get(position)) { 100 | case Mask: { 101 | processor = new MaskPostprocessor(context, R.drawable.mask_starfish); 102 | holder.drawee.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER); 103 | break; 104 | } 105 | case NinePatchMask: { 106 | processor = new MaskPostprocessor(context, R.drawable.mask_chat_right); 107 | holder.drawee.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.CENTER_INSIDE); 108 | break; 109 | } 110 | case ColorFilter: 111 | processor = new ColorFilterPostprocessor(Color.argb(80, 255, 0, 0)); 112 | break; 113 | case Grayscale: 114 | processor = new GrayscalePostprocessor(); 115 | break; 116 | case Blur: 117 | processor = new BlurPostprocessor(context, 25, 4); 118 | break; 119 | case BlurAndGrayscale: 120 | processor = new CombinePostProcessors.Builder() 121 | .add(new BlurPostprocessor(context, 25)) 122 | .add(new GrayscalePostprocessor()) 123 | .build(); 124 | break; 125 | case Toon: 126 | processor = new ToonFilterPostprocessor(context); 127 | break; 128 | case Sepia: 129 | processor = new SepiaFilterPostprocessor(context); 130 | break; 131 | case Contrast: 132 | processor = new ContrastFilterPostprocessor(context, 2.0f); 133 | break; 134 | case Invert: 135 | processor = new InvertFilterPostprocessor(context); 136 | break; 137 | case Pixel: 138 | processor = new PixelationFilterPostprocessor(context, 30f); 139 | break; 140 | case Sketch: 141 | processor = new SketchFilterPostprocessor(context); 142 | break; 143 | case Swirl: 144 | processor = new SwirlFilterPostprocessor(context, 0.5f, 1.0f, new PointF(0.5f, 0.5f)); 145 | break; 146 | case Brightness: 147 | processor = new BrightnessFilterPostprocessor(context, 0.5f); 148 | break; 149 | case Kuawahara: 150 | processor = new KuawaharaFilterPostprocessor(context, 25); 151 | break; 152 | case Vignette: 153 | processor = new VignetteFilterPostprocessor(context, new PointF(0.5f, 0.5f), 154 | new float[]{0.0f, 0.0f, 0.0f}, 0f, 0.75f); 155 | break; 156 | } 157 | ImageRequest request = ImageRequestBuilder.newBuilderWithResourceId(R.drawable.demo) 158 | .setPostprocessor(processor) 159 | .build(); 160 | 161 | PipelineDraweeController controller = 162 | (PipelineDraweeController) Fresco.newDraweeControllerBuilder() 163 | .setImageRequest(request) 164 | .setOldController(holder.drawee.getController()) 165 | .build(); 166 | holder.drawee.setController(controller); 167 | holder.title.setText(dataSet.get(position).name()); 168 | } 169 | 170 | @Override 171 | public int getItemCount() { 172 | return dataSet.size(); 173 | } 174 | 175 | static class ViewHolder extends RecyclerView.ViewHolder { 176 | 177 | public SimpleDraweeView drawee; 178 | public TextView title; 179 | 180 | ViewHolder(View itemView) { 181 | super(itemView); 182 | drawee = (SimpleDraweeView) itemView.findViewById(R.id.image); 183 | title = (TextView) itemView.findViewById(R.id.title); 184 | } 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/demo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/fresco-processors/465c39b2f0454e38f473bf9dbcbb6e0a0d8d1b53/example/src/main/res/drawable-xxhdpi/demo.jpg -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/mask_chat_right.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/fresco-processors/465c39b2f0454e38f473bf9dbcbb6e0a0d8d1b53/example/src/main/res/drawable-xxhdpi/mask_chat_right.9.png -------------------------------------------------------------------------------- /example/src/main/res/drawable-xxhdpi/mask_starfish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/fresco-processors/465c39b2f0454e38f473bf9dbcbb6e0a0d8d1b53/example/src/main/res/drawable-xxhdpi/mask_starfish.png -------------------------------------------------------------------------------- /example/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /example/src/main/res/layout/layout_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 27 | 28 | -------------------------------------------------------------------------------- /example/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/fresco-processors/465c39b2f0454e38f473bf9dbcbb6e0a0d8d1b53/example/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/fresco-processors/465c39b2f0454e38f473bf9dbcbb6e0a0d8d1b53/example/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/fresco-processors/465c39b2f0454e38f473bf9dbcbb6e0a0d8d1b53/example/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/fresco-processors/465c39b2f0454e38f473bf9dbcbb6e0a0d8d1b53/example/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | fresco-processors 3 | 4 | -------------------------------------------------------------------------------- /example/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 2 | org.gradle.parallel=true 3 | org.gradle.daemon=true 4 | org.gradle.configureondemand=true 5 | org.gradle.caching=true 6 | android.enableBuildCache=true 7 | android.useAndroidX=true 8 | 9 | VERSION_NAME=2.2.1 10 | VERSION_CODE=211 11 | 12 | COMPILE_SDK_VERSION=30 13 | TARGET_SDK_VERSION=30 14 | MIN_SDK_VERSION=21 15 | 16 | FRESCO_VERSION=2.3.0 17 | GPUIMAGE_VERSION=2.1.0 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/fresco-processors/465c39b2f0454e38f473bf9dbcbb6e0a0d8d1b53/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https://services.gradle.org/distributions/gradle-6.7.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /processors/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion COMPILE_SDK_VERSION as int 5 | 6 | defaultConfig { 7 | minSdkVersion MIN_SDK_VERSION as int 8 | targetSdkVersion TARGET_SDK_VERSION as int 9 | 10 | consumerProguardFiles 'proguard-rules.txt' 11 | } 12 | } 13 | 14 | dependencies { 15 | implementation "com.facebook.fresco:fresco:${FRESCO_VERSION}" 16 | compileOnly "jp.co.cyberagent.android:gpuimage:${GPUIMAGE_VERSION}" 17 | } 18 | 19 | ext { 20 | bintrayRepo = 'maven' 21 | bintrayName = 'fresco-processors' 22 | bintrayUserOrg = 'wasabeef' 23 | publishedGroupId = 'jp.wasabeef' 24 | libraryName = 'fresco-processors' 25 | artifact = 'fresco-processors' 26 | libraryDescription = 'which provides simple Prosessors to Fresco' 27 | siteUrl = 'https://github.com/wasabeef/fresco-processors' 28 | gitUrl = 'https://github.com/wasabeef/fresco-processors.git' 29 | issueUrl = 'https://github.com/wasabeef/fresco-processors/issues' 30 | libraryVersion = VERSION_NAME 31 | developerId = 'wasabeef' 32 | developerName = 'Wasabeef' 33 | developerEmail = 'dadadada.chop@gmail.com' 34 | licenseName = 'The Apache Software License, Version 2.0' 35 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' 36 | allLicenses = ["Apache-2.0"] 37 | } 38 | // TODO: Close JCenter on May 1st https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/ 39 | // apply from: 'https://gist.githubusercontent.com/wasabeef/cf14805bee509baf7461974582f17d26/raw/bintray-v1.gradle' 40 | // apply from: 'https://gist.githubusercontent.com/wasabeef/cf14805bee509baf7461974582f17d26/raw/install-v1.gradle' 41 | 42 | apply from: 'https://gist.githubusercontent.com/wasabeef/2f2ae8d97b429e7d967128125dc47854/raw/maven-central-v1.gradle' 43 | -------------------------------------------------------------------------------- /processors/proguard-rules.txt: -------------------------------------------------------------------------------- 1 | -keepclasseswithmembernames class * { 2 | native ; 3 | } 4 | 5 | -dontwarn jp.co.cyberagent.android.gpuimage.** -------------------------------------------------------------------------------- /processors/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/BlurPostprocessor.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.content.Context; 20 | import android.graphics.Bitmap; 21 | import android.graphics.Canvas; 22 | import android.graphics.Paint; 23 | 24 | import com.facebook.cache.common.CacheKey; 25 | import com.facebook.cache.common.SimpleCacheKey; 26 | import com.facebook.imagepipeline.request.BasePostprocessor; 27 | 28 | import jp.wasabeef.fresco.processors.internal.FastBlur; 29 | import jp.wasabeef.fresco.processors.internal.RSBlur; 30 | 31 | public class BlurPostprocessor extends BasePostprocessor { 32 | 33 | private static final int MAX_RADIUS = 25; 34 | private static final int DEFAULT_DOWN_SAMPLING = 1; 35 | 36 | private final Context context; 37 | private final int radius; 38 | private final int sampling; 39 | 40 | public BlurPostprocessor(Context context) { 41 | this(context, MAX_RADIUS, DEFAULT_DOWN_SAMPLING); 42 | } 43 | 44 | public BlurPostprocessor(Context context, int radius) { 45 | this(context, radius, DEFAULT_DOWN_SAMPLING); 46 | } 47 | 48 | public BlurPostprocessor(Context context, int radius, int sampling) { 49 | this.context = context.getApplicationContext(); 50 | this.radius = radius; 51 | this.sampling = sampling; 52 | } 53 | 54 | @Override 55 | public void process(Bitmap dest, Bitmap source) { 56 | 57 | int width = source.getWidth(); 58 | int height = source.getHeight(); 59 | int scaledWidth = width / sampling; 60 | int scaledHeight = height / sampling; 61 | 62 | Bitmap blurredBitmap = Bitmap.createBitmap(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888); 63 | 64 | Canvas canvas = new Canvas(blurredBitmap); 65 | canvas.scale(1 / (float) sampling, 1 / (float) sampling); 66 | Paint paint = new Paint(); 67 | paint.setFlags(Paint.FILTER_BITMAP_FLAG); 68 | canvas.drawBitmap(source, 0, 0, paint); 69 | 70 | try { 71 | blurredBitmap = RSBlur.blur(context, blurredBitmap, radius); 72 | } catch (android.renderscript.RSRuntimeException e) { 73 | blurredBitmap = FastBlur.blur(blurredBitmap, radius, true); 74 | } 75 | 76 | Bitmap scaledBitmap = 77 | Bitmap.createScaledBitmap(blurredBitmap, dest.getWidth(), dest.getHeight(), true); 78 | blurredBitmap.recycle(); 79 | 80 | super.process(dest, scaledBitmap); 81 | } 82 | 83 | @Override 84 | public String getName() { 85 | return getClass().getSimpleName(); 86 | } 87 | 88 | @Override 89 | public CacheKey getPostprocessorCacheKey() { 90 | return new SimpleCacheKey("radius=" + radius + ",sampling=" + sampling); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/ColorFilterPostprocessor.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.graphics.Bitmap; 20 | import android.graphics.Canvas; 21 | import android.graphics.Paint; 22 | import android.graphics.PorterDuff; 23 | import android.graphics.PorterDuffColorFilter; 24 | 25 | import com.facebook.cache.common.CacheKey; 26 | import com.facebook.cache.common.SimpleCacheKey; 27 | import com.facebook.imagepipeline.request.BasePostprocessor; 28 | 29 | public class ColorFilterPostprocessor extends BasePostprocessor { 30 | 31 | private final int color; 32 | 33 | public ColorFilterPostprocessor(int color) { 34 | this.color = color; 35 | } 36 | 37 | @Override 38 | public void process(Bitmap dest, Bitmap source) { 39 | super.process(dest, source); 40 | 41 | Canvas canvas = new Canvas(dest); 42 | Paint paint = new Paint(); 43 | paint.setAntiAlias(true); 44 | paint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); 45 | canvas.drawBitmap(source, 0, 0, paint); 46 | } 47 | 48 | @Override 49 | public String getName() { 50 | return getClass().getSimpleName(); 51 | } 52 | 53 | @Override 54 | public CacheKey getPostprocessorCacheKey() { 55 | return new SimpleCacheKey("color=" + color); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/CombinePostProcessors.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Canvas; 5 | import android.graphics.Paint; 6 | 7 | import com.facebook.imagepipeline.request.BasePostprocessor; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | 13 | public class CombinePostProcessors extends BasePostprocessor { 14 | 15 | private final List mProcessors; 16 | 17 | private CombinePostProcessors(List processors) { 18 | super(); 19 | mProcessors = processors; 20 | } 21 | 22 | @Override 23 | public void process(Bitmap dest, Bitmap src) { 24 | Canvas canvas = new Canvas(dest); 25 | Paint paint = new Paint(); 26 | canvas.drawBitmap(src, 0, 0, paint); 27 | 28 | for (BasePostprocessor processor : mProcessors) { 29 | processor.process(dest, dest); 30 | } 31 | } 32 | 33 | public static class Builder { 34 | 35 | private final List processors; 36 | 37 | public Builder() { 38 | processors = new ArrayList(); 39 | } 40 | 41 | public Builder add(BasePostprocessor processor) { 42 | processors.add(processor); 43 | return this; 44 | } 45 | 46 | public CombinePostProcessors build() { 47 | return new CombinePostProcessors(processors); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/GrayscalePostprocessor.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.graphics.Bitmap; 20 | import android.graphics.Canvas; 21 | import android.graphics.ColorMatrix; 22 | import android.graphics.ColorMatrixColorFilter; 23 | import android.graphics.Paint; 24 | 25 | import com.facebook.cache.common.CacheKey; 26 | import com.facebook.cache.common.SimpleCacheKey; 27 | import com.facebook.imagepipeline.request.BasePostprocessor; 28 | 29 | public class GrayscalePostprocessor extends BasePostprocessor { 30 | 31 | @Override 32 | public void process(Bitmap dest, Bitmap source) { 33 | super.process(dest, source); 34 | 35 | Canvas canvas = new Canvas(dest); 36 | ColorMatrix saturation = new ColorMatrix(); 37 | saturation.setSaturation(0f); 38 | Paint paint = new Paint(); 39 | paint.setColorFilter(new ColorMatrixColorFilter(saturation)); 40 | canvas.drawBitmap(source, 0, 0, paint); 41 | } 42 | 43 | @Override 44 | public String getName() { 45 | return getClass().getSimpleName(); 46 | } 47 | 48 | @Override 49 | public CacheKey getPostprocessorCacheKey() { 50 | return new SimpleCacheKey("gray"); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/MaskPostprocessor.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.content.Context; 20 | import android.graphics.Bitmap; 21 | import android.graphics.Canvas; 22 | import android.graphics.Paint; 23 | import android.graphics.PorterDuff; 24 | import android.graphics.PorterDuffXfermode; 25 | import android.graphics.drawable.Drawable; 26 | 27 | import com.facebook.cache.common.CacheKey; 28 | import com.facebook.cache.common.SimpleCacheKey; 29 | import com.facebook.imagepipeline.request.BasePostprocessor; 30 | 31 | public class MaskPostprocessor extends BasePostprocessor { 32 | 33 | private static final Paint paint = new Paint(); 34 | private final Context context; 35 | private final int maskId; 36 | 37 | static { 38 | paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); 39 | } 40 | 41 | /** 42 | * @param maskId If you change the mask file, please also rename the mask file, or Glide will get 43 | * the cache with the old mask. Because getId() return the same values if using the 44 | * same make file name. If you have a good idea please tell us, thanks. 45 | */ 46 | public MaskPostprocessor(Context context, int maskId) { 47 | this.context = context.getApplicationContext(); 48 | this.maskId = maskId; 49 | } 50 | 51 | @Override 52 | public void process(Bitmap dest, Bitmap source) { 53 | 54 | Bitmap result = 55 | Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); 56 | 57 | Drawable mask = context.getDrawable(maskId); 58 | 59 | Canvas canvas = new Canvas(result); 60 | mask.setBounds(0, 0, source.getWidth(), source.getHeight()); 61 | mask.draw(canvas); 62 | canvas.drawBitmap(source, 0, 0, paint); 63 | 64 | super.process(dest, result); 65 | } 66 | 67 | @Override 68 | public String getName() { 69 | return getClass().getSimpleName(); 70 | } 71 | 72 | @Override 73 | public CacheKey getPostprocessorCacheKey() { 74 | return new SimpleCacheKey("mask=" + context.getResources().getResourceEntryName(maskId)); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/gpu/BrightnessFilterPostprocessor.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors.gpu; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.content.Context; 20 | 21 | import com.facebook.cache.common.CacheKey; 22 | import com.facebook.cache.common.SimpleCacheKey; 23 | 24 | import jp.co.cyberagent.android.gpuimage.filter.GPUImageBrightnessFilter; 25 | 26 | /** 27 | * brightness value ranges from -1.0 to 1.0, with 0.0 as the normal level 28 | */ 29 | public class BrightnessFilterPostprocessor extends GPUFilterPostprocessor { 30 | 31 | private final float brightness; 32 | 33 | public BrightnessFilterPostprocessor(Context context) { 34 | this(context, 0.0f); 35 | } 36 | 37 | public BrightnessFilterPostprocessor(Context context, float brightness) { 38 | super(context, new GPUImageBrightnessFilter()); 39 | this.brightness = brightness; 40 | 41 | GPUImageBrightnessFilter filter = getFilter(); 42 | filter.setBrightness(brightness); 43 | } 44 | 45 | @Override 46 | public CacheKey getPostprocessorCacheKey() { 47 | return new SimpleCacheKey("brightness=" + brightness); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/gpu/ContrastFilterPostprocessor.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors.gpu; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.content.Context; 20 | 21 | import com.facebook.cache.common.CacheKey; 22 | import com.facebook.cache.common.SimpleCacheKey; 23 | 24 | import jp.co.cyberagent.android.gpuimage.filter.GPUImageContrastFilter; 25 | 26 | /** 27 | * contrast value ranges from 0.0 to 4.0, with 1.0 as the normal level 28 | */ 29 | public class ContrastFilterPostprocessor extends GPUFilterPostprocessor { 30 | 31 | private final float contrast; 32 | 33 | public ContrastFilterPostprocessor(Context context) { 34 | this(context, 1.0f); 35 | } 36 | 37 | public ContrastFilterPostprocessor(Context context, float contrast) { 38 | super(context, new GPUImageContrastFilter()); 39 | this.contrast = contrast; 40 | 41 | GPUImageContrastFilter filter = getFilter(); 42 | filter.setContrast(contrast); 43 | } 44 | 45 | @Override 46 | public CacheKey getPostprocessorCacheKey() { 47 | return new SimpleCacheKey("contrast=" + contrast); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/gpu/GPUFilterPostprocessor.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors.gpu; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.content.Context; 20 | import android.graphics.Bitmap; 21 | 22 | import com.facebook.imagepipeline.request.BasePostprocessor; 23 | 24 | import jp.co.cyberagent.android.gpuimage.GPUImage; 25 | import jp.co.cyberagent.android.gpuimage.filter.GPUImageFilter; 26 | 27 | public abstract class GPUFilterPostprocessor extends BasePostprocessor { 28 | 29 | private final Context context; 30 | private final GPUImageFilter filter; 31 | 32 | public GPUFilterPostprocessor(Context context, GPUImageFilter filter) { 33 | this.context = context.getApplicationContext(); 34 | this.filter = filter; 35 | } 36 | 37 | @Override 38 | public void process(Bitmap dest, Bitmap source) { 39 | GPUImage gpuImage = new GPUImage(context); 40 | gpuImage.setImage(source); 41 | gpuImage.setFilter(filter); 42 | Bitmap bitmap = gpuImage.getBitmapWithFilterApplied(); 43 | 44 | super.process(dest, bitmap); 45 | } 46 | 47 | @Override 48 | public String getName() { 49 | return getClass().getSimpleName(); 50 | } 51 | 52 | @SuppressWarnings("unchecked") 53 | public T getFilter() { 54 | return (T) filter; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/gpu/InvertFilterPostprocessor.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors.gpu; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.content.Context; 20 | 21 | import com.facebook.cache.common.CacheKey; 22 | import com.facebook.cache.common.SimpleCacheKey; 23 | 24 | import jp.co.cyberagent.android.gpuimage.filter.GPUImageColorInvertFilter; 25 | 26 | public class InvertFilterPostprocessor extends GPUFilterPostprocessor { 27 | 28 | public InvertFilterPostprocessor(Context context) { 29 | super(context, new GPUImageColorInvertFilter()); 30 | } 31 | 32 | @Override 33 | public CacheKey getPostprocessorCacheKey() { 34 | return new SimpleCacheKey("invert"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/gpu/KuawaharaFilterPostprocessor.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors.gpu; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.content.Context; 20 | 21 | import com.facebook.cache.common.CacheKey; 22 | import com.facebook.cache.common.SimpleCacheKey; 23 | 24 | import jp.co.cyberagent.android.gpuimage.filter.GPUImageKuwaharaFilter; 25 | 26 | /** 27 | * Kuwahara all the colors in the image. 28 | *

29 | * The radius to sample from when creating the brush-stroke effect, with a default of 25. 30 | * The larger the radius, the slower the filter. 31 | */ 32 | public class KuawaharaFilterPostprocessor extends GPUFilterPostprocessor { 33 | 34 | private final int radius; 35 | 36 | public KuawaharaFilterPostprocessor(Context context) { 37 | this(context, 25); 38 | } 39 | 40 | public KuawaharaFilterPostprocessor(Context context, int radius) { 41 | super(context, new GPUImageKuwaharaFilter()); 42 | this.radius = radius; 43 | 44 | GPUImageKuwaharaFilter filter = getFilter(); 45 | filter.setRadius(radius); 46 | } 47 | 48 | @Override 49 | public CacheKey getPostprocessorCacheKey() { 50 | return new SimpleCacheKey("radius=" + radius); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/gpu/PixelationFilterPostprocessor.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors.gpu; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.content.Context; 20 | 21 | import com.facebook.cache.common.CacheKey; 22 | import com.facebook.cache.common.SimpleCacheKey; 23 | 24 | import jp.co.cyberagent.android.gpuimage.filter.GPUImagePixelationFilter; 25 | 26 | /** 27 | * Applies a Pixelation effect to the image. 28 | *

29 | * The pixel with a default of 10.0. 30 | */ 31 | public class PixelationFilterPostprocessor extends GPUFilterPostprocessor { 32 | 33 | private final float pixel; 34 | 35 | public PixelationFilterPostprocessor(Context context) { 36 | this(context, 10f); 37 | } 38 | 39 | public PixelationFilterPostprocessor(Context context, float pixel) { 40 | super(context, new GPUImagePixelationFilter()); 41 | this.pixel = pixel; 42 | 43 | GPUImagePixelationFilter filter = getFilter(); 44 | filter.setPixel(pixel); 45 | } 46 | 47 | @Override 48 | public CacheKey getPostprocessorCacheKey() { 49 | return new SimpleCacheKey("pixel=" + pixel); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/gpu/SepiaFilterPostprocessor.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors.gpu; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.content.Context; 20 | 21 | import com.facebook.cache.common.CacheKey; 22 | import com.facebook.cache.common.SimpleCacheKey; 23 | 24 | import jp.co.cyberagent.android.gpuimage.filter.GPUImageSepiaToneFilter; 25 | 26 | /** 27 | * Applies a simple sepia effect. 28 | *

29 | * The intensity with a default of 1.0. 30 | */ 31 | public class SepiaFilterPostprocessor extends GPUFilterPostprocessor { 32 | 33 | private final float intensity; 34 | 35 | public SepiaFilterPostprocessor(Context context) { 36 | this(context, 1.0f); 37 | } 38 | 39 | public SepiaFilterPostprocessor(Context context, float intensity) { 40 | super(context, new GPUImageSepiaToneFilter()); 41 | this.intensity = intensity; 42 | 43 | GPUImageSepiaToneFilter filter = getFilter(); 44 | filter.setIntensity(intensity); 45 | } 46 | 47 | @Override 48 | public CacheKey getPostprocessorCacheKey() { 49 | return new SimpleCacheKey("intensity=" + intensity); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/gpu/SketchFilterPostprocessor.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors.gpu; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.content.Context; 20 | 21 | import com.facebook.cache.common.CacheKey; 22 | import com.facebook.cache.common.SimpleCacheKey; 23 | 24 | import jp.co.cyberagent.android.gpuimage.filter.GPUImageSketchFilter; 25 | 26 | public class SketchFilterPostprocessor extends GPUFilterPostprocessor { 27 | 28 | public SketchFilterPostprocessor(Context context) { 29 | super(context, new GPUImageSketchFilter()); 30 | } 31 | 32 | @Override 33 | public CacheKey getPostprocessorCacheKey() { 34 | return new SimpleCacheKey("sketch"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/gpu/SwirlFilterPostprocessor.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors.gpu; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.content.Context; 20 | import android.graphics.PointF; 21 | 22 | import com.facebook.cache.common.CacheKey; 23 | import com.facebook.cache.common.SimpleCacheKey; 24 | 25 | import jp.co.cyberagent.android.gpuimage.filter.GPUImageSwirlFilter; 26 | 27 | /** 28 | * Creates a swirl distortion on the image. 29 | */ 30 | public class SwirlFilterPostprocessor extends GPUFilterPostprocessor { 31 | 32 | private final float radius; 33 | private final float angle; 34 | private final PointF center; 35 | 36 | public SwirlFilterPostprocessor(Context context) { 37 | this(context, 0.5f, 1.0f, new PointF(0.5f, 0.5f)); 38 | } 39 | 40 | /** 41 | * @param radius from 0.0 to 1.0, default 0.5 42 | * @param angle minimum 0.0, default 1.0 43 | * @param center default (0.5, 0.5) 44 | */ 45 | public SwirlFilterPostprocessor(Context context, float radius, float angle, PointF center) { 46 | super(context, new GPUImageSwirlFilter()); 47 | this.radius = radius; 48 | this.angle = angle; 49 | this.center = center; 50 | 51 | GPUImageSwirlFilter filter = getFilter(); 52 | filter.setRadius(this.radius); 53 | filter.setAngle(this.angle); 54 | filter.setCenter(this.center); 55 | } 56 | 57 | @Override 58 | public CacheKey getPostprocessorCacheKey() { 59 | return new SimpleCacheKey( 60 | "radius=" + radius + ",angle=" + angle + ",center=" + center.toString()); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/gpu/ToonFilterPostprocessor.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors.gpu; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.content.Context; 20 | 21 | import com.facebook.cache.common.CacheKey; 22 | import com.facebook.cache.common.SimpleCacheKey; 23 | 24 | import jp.co.cyberagent.android.gpuimage.filter.GPUImageToonFilter; 25 | 26 | /** 27 | * The threshold at which to apply the edges, default of 0.2. 28 | * The levels of quantization for the posterization of colors within the scene, 29 | * with a default of 10.0. 30 | */ 31 | public class ToonFilterPostprocessor extends GPUFilterPostprocessor { 32 | 33 | private final float threshold; 34 | private final float quantizationLevels; 35 | 36 | public ToonFilterPostprocessor(Context context) { 37 | this(context, .2f, 10.0f); 38 | } 39 | 40 | public ToonFilterPostprocessor(Context context, float threshold, float quantizationLevels) { 41 | super(context, new GPUImageToonFilter()); 42 | 43 | this.threshold = threshold; 44 | this.quantizationLevels = quantizationLevels; 45 | 46 | GPUImageToonFilter filter = getFilter(); 47 | filter.setThreshold(this.threshold); 48 | filter.setQuantizationLevels(this.quantizationLevels); 49 | } 50 | 51 | @Override 52 | public CacheKey getPostprocessorCacheKey() { 53 | return new SimpleCacheKey( 54 | "threshold=" + threshold + ",quantizationLevels=" + quantizationLevels); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/gpu/VignetteFilterPostprocessor.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors.gpu; 2 | 3 | /** 4 | * Copyright (C) 2020 Wasabeef 5 | *

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

10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | *

12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | import android.content.Context; 20 | import android.graphics.PointF; 21 | 22 | import com.facebook.cache.common.CacheKey; 23 | import com.facebook.cache.common.SimpleCacheKey; 24 | 25 | import java.util.Arrays; 26 | 27 | import jp.co.cyberagent.android.gpuimage.filter.GPUImageVignetteFilter; 28 | 29 | /** 30 | * Performs a vignetting effect, fading out the image at the edges 31 | * The directional intensity of the vignetting, 32 | * with a default of x = 0.5, y = 0.5, start = 0, end = 0.75 33 | */ 34 | public class VignetteFilterPostprocessor extends GPUFilterPostprocessor { 35 | 36 | private final PointF center; 37 | private final float[] vignetteColor; 38 | private final float vignetteStart; 39 | private final float vignetteEnd; 40 | 41 | public VignetteFilterPostprocessor(Context context) { 42 | this(context, new PointF(0.5f, 0.5f), new float[]{0.0f, 0.0f, 0.0f}, 0.0f, 0.75f); 43 | } 44 | 45 | public VignetteFilterPostprocessor(Context context, PointF center, float[] color, float start, 46 | float end) { 47 | super(context, new GPUImageVignetteFilter()); 48 | 49 | this.center = center; 50 | this.vignetteColor = color; 51 | this.vignetteStart = start; 52 | this.vignetteEnd = end; 53 | 54 | GPUImageVignetteFilter filter = getFilter(); 55 | filter.setVignetteCenter(this.center); 56 | filter.setVignetteColor(this.vignetteColor); 57 | filter.setVignetteStart(this.vignetteStart); 58 | filter.setVignetteEnd(this.vignetteEnd); 59 | } 60 | 61 | @Override 62 | public CacheKey getPostprocessorCacheKey() { 63 | return new SimpleCacheKey("center=" + center.toString() + 64 | ",color=" + Arrays.toString(vignetteColor) + 65 | ",start=" + vignetteStart + ",end=" + vignetteEnd); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/internal/FastBlur.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors.internal; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | /** 6 | * Copyright (C) 2020 Wasabeef 7 | *

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

12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | *

14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | public class FastBlur { 22 | 23 | public static Bitmap blur(Bitmap sentBitmap, int radius, boolean canReuseInBitmap) { 24 | 25 | // Stack Blur v1.0 from 26 | // http://www.quasimondo.com/StackBlurForCanvas/StackBlurDemo.html 27 | // 28 | // Java Author: Mario Klingemann 29 | // http://incubator.quasimondo.com 30 | // created Feburary 29, 2004 31 | // Android port : Yahel Bouaziz 32 | // http://www.kayenko.com 33 | // ported april 5th, 2012 34 | 35 | // This is a compromise between Gaussian Blur and Box blur 36 | // It creates much better looking blurs than Box Blur, but is 37 | // 7x faster than my Gaussian Blur implementation. 38 | // 39 | // I called it Stack Blur because this describes best how this 40 | // filter works internally: it creates a kind of moving stack 41 | // of colors whilst scanning through the image. Thereby it 42 | // just has to add one new block of color to the right side 43 | // of the stack and remove the leftmost color. The remaining 44 | // colors on the topmost layer of the stack are either added on 45 | // or reduced by one, depending on if they are on the right or 46 | // on the left side of the stack. 47 | // 48 | // If you are using this algorithm in your code please add 49 | // the following line: 50 | // 51 | // Stack Blur Algorithm by Mario Klingemann 52 | 53 | Bitmap bitmap; 54 | if (canReuseInBitmap) { 55 | bitmap = sentBitmap; 56 | } else { 57 | bitmap = sentBitmap.copy(sentBitmap.getConfig(), true); 58 | } 59 | 60 | if (radius < 1) { 61 | return (null); 62 | } 63 | 64 | int w = bitmap.getWidth(); 65 | int h = bitmap.getHeight(); 66 | 67 | int[] pix = new int[w * h]; 68 | bitmap.getPixels(pix, 0, w, 0, 0, w, h); 69 | 70 | int wm = w - 1; 71 | int hm = h - 1; 72 | int wh = w * h; 73 | int div = radius + radius + 1; 74 | 75 | int[] r = new int[wh]; 76 | int[] g = new int[wh]; 77 | int[] b = new int[wh]; 78 | int rsum, gsum, bsum, x, y, i, p, yp, yi, yw; 79 | int[] vmin = new int[Math.max(w, h)]; 80 | 81 | int divsum = (div + 1) >> 1; 82 | divsum *= divsum; 83 | int[] dv = new int[256 * divsum]; 84 | for (i = 0; i < 256 * divsum; i++) { 85 | dv[i] = (i / divsum); 86 | } 87 | 88 | yw = yi = 0; 89 | 90 | int[][] stack = new int[div][3]; 91 | int stackpointer; 92 | int stackstart; 93 | int[] sir; 94 | int rbs; 95 | int r1 = radius + 1; 96 | int routsum, goutsum, boutsum; 97 | int rinsum, ginsum, binsum; 98 | 99 | for (y = 0; y < h; y++) { 100 | rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0; 101 | for (i = -radius; i <= radius; i++) { 102 | p = pix[yi + Math.min(wm, Math.max(i, 0))]; 103 | sir = stack[i + radius]; 104 | sir[0] = (p & 0xff0000) >> 16; 105 | sir[1] = (p & 0x00ff00) >> 8; 106 | sir[2] = (p & 0x0000ff); 107 | rbs = r1 - Math.abs(i); 108 | rsum += sir[0] * rbs; 109 | gsum += sir[1] * rbs; 110 | bsum += sir[2] * rbs; 111 | if (i > 0) { 112 | rinsum += sir[0]; 113 | ginsum += sir[1]; 114 | binsum += sir[2]; 115 | } else { 116 | routsum += sir[0]; 117 | goutsum += sir[1]; 118 | boutsum += sir[2]; 119 | } 120 | } 121 | stackpointer = radius; 122 | 123 | for (x = 0; x < w; x++) { 124 | 125 | r[yi] = dv[rsum]; 126 | g[yi] = dv[gsum]; 127 | b[yi] = dv[bsum]; 128 | 129 | rsum -= routsum; 130 | gsum -= goutsum; 131 | bsum -= boutsum; 132 | 133 | stackstart = stackpointer - radius + div; 134 | sir = stack[stackstart % div]; 135 | 136 | routsum -= sir[0]; 137 | goutsum -= sir[1]; 138 | boutsum -= sir[2]; 139 | 140 | if (y == 0) { 141 | vmin[x] = Math.min(x + radius + 1, wm); 142 | } 143 | p = pix[yw + vmin[x]]; 144 | 145 | sir[0] = (p & 0xff0000) >> 16; 146 | sir[1] = (p & 0x00ff00) >> 8; 147 | sir[2] = (p & 0x0000ff); 148 | 149 | rinsum += sir[0]; 150 | ginsum += sir[1]; 151 | binsum += sir[2]; 152 | 153 | rsum += rinsum; 154 | gsum += ginsum; 155 | bsum += binsum; 156 | 157 | stackpointer = (stackpointer + 1) % div; 158 | sir = stack[(stackpointer) % div]; 159 | 160 | routsum += sir[0]; 161 | goutsum += sir[1]; 162 | boutsum += sir[2]; 163 | 164 | rinsum -= sir[0]; 165 | ginsum -= sir[1]; 166 | binsum -= sir[2]; 167 | 168 | yi++; 169 | } 170 | yw += w; 171 | } 172 | for (x = 0; x < w; x++) { 173 | rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0; 174 | yp = -radius * w; 175 | for (i = -radius; i <= radius; i++) { 176 | yi = Math.max(0, yp) + x; 177 | 178 | sir = stack[i + radius]; 179 | 180 | sir[0] = r[yi]; 181 | sir[1] = g[yi]; 182 | sir[2] = b[yi]; 183 | 184 | rbs = r1 - Math.abs(i); 185 | 186 | rsum += r[yi] * rbs; 187 | gsum += g[yi] * rbs; 188 | bsum += b[yi] * rbs; 189 | 190 | if (i > 0) { 191 | rinsum += sir[0]; 192 | ginsum += sir[1]; 193 | binsum += sir[2]; 194 | } else { 195 | routsum += sir[0]; 196 | goutsum += sir[1]; 197 | boutsum += sir[2]; 198 | } 199 | 200 | if (i < hm) { 201 | yp += w; 202 | } 203 | } 204 | yi = x; 205 | stackpointer = radius; 206 | for (y = 0; y < h; y++) { 207 | // Preserve alpha channel: ( 0xff000000 & pix[yi] ) 208 | pix[yi] = (0xff000000 & pix[yi]) | (dv[rsum] << 16) | (dv[gsum] << 8) | dv[bsum]; 209 | 210 | rsum -= routsum; 211 | gsum -= goutsum; 212 | bsum -= boutsum; 213 | 214 | stackstart = stackpointer - radius + div; 215 | sir = stack[stackstart % div]; 216 | 217 | routsum -= sir[0]; 218 | goutsum -= sir[1]; 219 | boutsum -= sir[2]; 220 | 221 | if (x == 0) { 222 | vmin[y] = Math.min(y + r1, hm) * w; 223 | } 224 | p = x + vmin[y]; 225 | 226 | sir[0] = r[p]; 227 | sir[1] = g[p]; 228 | sir[2] = b[p]; 229 | 230 | rinsum += sir[0]; 231 | ginsum += sir[1]; 232 | binsum += sir[2]; 233 | 234 | rsum += rinsum; 235 | gsum += ginsum; 236 | bsum += binsum; 237 | 238 | stackpointer = (stackpointer + 1) % div; 239 | sir = stack[stackpointer]; 240 | 241 | routsum += sir[0]; 242 | goutsum += sir[1]; 243 | boutsum += sir[2]; 244 | 245 | rinsum -= sir[0]; 246 | ginsum -= sir[1]; 247 | binsum -= sir[2]; 248 | 249 | yi += w; 250 | } 251 | } 252 | 253 | bitmap.setPixels(pix, 0, w, 0, 0, w, h); 254 | 255 | return (bitmap); 256 | } 257 | } 258 | -------------------------------------------------------------------------------- /processors/src/main/java/jp/wasabeef/fresco/processors/internal/RSBlur.java: -------------------------------------------------------------------------------- 1 | package jp.wasabeef.fresco.processors.internal; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.renderscript.Allocation; 6 | import android.renderscript.Element; 7 | import android.renderscript.RSRuntimeException; 8 | import android.renderscript.RenderScript; 9 | import android.renderscript.ScriptIntrinsicBlur; 10 | 11 | /** 12 | * Copyright (C) 2020 Wasabeef 13 | *

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

18 | * http://www.apache.org/licenses/LICENSE-2.0 19 | *

20 | * Unless required by applicable law or agreed to in writing, software 21 | * distributed under the License is distributed on an "AS IS" BASIS, 22 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 | * See the License for the specific language governing permissions and 24 | * limitations under the License. 25 | */ 26 | 27 | public class RSBlur { 28 | 29 | public static Bitmap blur(Context context, Bitmap bitmap, int radius) throws RSRuntimeException { 30 | RenderScript rs = null; 31 | Allocation input = null; 32 | Allocation output = null; 33 | ScriptIntrinsicBlur blur = null; 34 | try { 35 | rs = RenderScript.create(context); 36 | rs.setMessageHandler(new RenderScript.RSMessageHandler()); 37 | input = Allocation.createFromBitmap(rs, bitmap, Allocation.MipmapControl.MIPMAP_NONE, 38 | Allocation.USAGE_SCRIPT); 39 | output = Allocation.createTyped(rs, input.getType()); 40 | blur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); 41 | 42 | blur.setInput(input); 43 | blur.setRadius(radius); 44 | blur.forEach(output); 45 | output.copyTo(bitmap); 46 | } finally { 47 | if (rs != null) { 48 | rs.destroy(); 49 | } 50 | if (input != null) { 51 | input.destroy(); 52 | } 53 | if (output != null) { 54 | output.destroy(); 55 | } 56 | if (blur != null) { 57 | blur.destroy(); 58 | } 59 | } 60 | 61 | return bitmap; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':example', ':processors' 2 | -------------------------------------------------------------------------------- /signingConfigs/debug.gradle: -------------------------------------------------------------------------------- 1 | signingConfigs { 2 | debug { 3 | storeFile file("debug.keystore") 4 | storePassword "android" 5 | keyAlias "androiddebugkey" 6 | keyPassword "android" 7 | } 8 | } 9 | 10 | // $ keytool -v -list -keystore 11 | // Certificate fingerprints: 12 | // MD5: 28:22:7C:A4:B9:2F:6E:C7:D5:58:62:48:EB:7E:82:C3 13 | // SHA1: 94:25:A9:50:9C:0E:AE:AA:00:37:5E:D6:71:E3:BC:ED:17:E5:0C:A3 14 | // 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 15 | -------------------------------------------------------------------------------- /signingConfigs/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wasabeef/fresco-processors/465c39b2f0454e38f473bf9dbcbb6e0a0d8d1b53/signingConfigs/debug.keystore --------------------------------------------------------------------------------