├── .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 |
4 | DEPRECATED5 | 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 | |
8 |
20 |
21 |
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
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
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
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
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
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
--------------------------------------------------------------------------------