├── ImageProcessingLib ├── .classpath ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── AndroidManifest.xml ├── assets │ └── Android-BitmapCache-2.1.jar ├── bin │ ├── AndroidManifest.xml │ ├── R.txt │ ├── classes │ │ └── com │ │ │ └── jcmore2 │ │ │ ├── imageprocessing │ │ │ ├── ConvolutionMatrix.class │ │ │ ├── ImageProcessing.class │ │ │ ├── filesystem │ │ │ │ └── ImageFilesystemManager.class │ │ │ ├── model │ │ │ │ └── ImageProcessingModel.class │ │ │ └── utils │ │ │ │ └── Utils.class │ │ │ └── imageprocessinglibrary │ │ │ ├── BuildConfig.class │ │ │ ├── R$attr.class │ │ │ ├── R$drawable.class │ │ │ ├── R$string.class │ │ │ ├── R$style.class │ │ │ └── R.class │ ├── imageprocessinglib.jar │ ├── imageprocessinglibrary.jar │ ├── jarlist.cache │ └── res │ │ ├── drawable-hdpi │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ └── ic_launcher.png │ │ └── drawable-xhdpi │ │ └── ic_launcher.png ├── gen │ └── com │ │ └── jcmore2 │ │ └── imageprocessinglibrary │ │ ├── BuildConfig.java │ │ └── R.java ├── libs │ └── android-support-v4.jar ├── proguard-project.txt ├── project.properties ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── values-v11 │ │ └── styles.xml │ ├── values-v14 │ │ └── styles.xml │ └── values │ │ ├── strings.xml │ │ └── styles.xml └── src │ └── com │ └── jcmore2 │ └── imageprocessing │ ├── ConvolutionMatrix.java │ ├── ImageProcessing.java │ ├── filesystem │ └── ImageFilesystemManager.java │ ├── model │ └── ImageProcessingModel.java │ └── utils │ └── Utils.java ├── README.md ├── TestImageProcessingLib ├── .classpath ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs ├── AndroidManifest.xml ├── bin │ ├── AndroidManifest.xml │ ├── R.txt │ ├── TestImageProcessingLibrary.apk │ ├── classes.dex │ ├── classes │ │ └── com │ │ │ └── jcmore2 │ │ │ ├── imageprocessinglibrary │ │ │ ├── R$drawable.class │ │ │ ├── R$string.class │ │ │ ├── R$style.class │ │ │ └── R.class │ │ │ └── testimageprocessinglibrary │ │ │ ├── BuildConfig.class │ │ │ ├── HorizontalListView$1.class │ │ │ ├── HorizontalListView$2.class │ │ │ ├── HorizontalListView$3.class │ │ │ ├── HorizontalListView.class │ │ │ ├── ListEffectAdapter$1.class │ │ │ ├── ListEffectAdapter$ViewHolder.class │ │ │ ├── ListEffectAdapter.class │ │ │ ├── ProcessingAsyncTask$ProcessingListener.class │ │ │ ├── ProcessingAsyncTask.class │ │ │ ├── R$attr.class │ │ │ ├── R$dimen.class │ │ │ ├── R$drawable.class │ │ │ ├── R$id.class │ │ │ ├── R$layout.class │ │ │ ├── R$menu.class │ │ │ ├── R$string.class │ │ │ ├── R$style.class │ │ │ ├── R.class │ │ │ ├── TestActivity$1$1.class │ │ │ ├── TestActivity$1.class │ │ │ ├── TestActivity$2.class │ │ │ ├── TestActivity$3.class │ │ │ ├── TestActivity$4.class │ │ │ └── TestActivity.class │ ├── dexedLibs │ │ ├── android-support-v4-15157426f1975f099af003680737fd21.jar │ │ └── imageprocessinglibrary-de120e7c8cc49977742f0d0a79651b29.jar │ ├── jarlist.cache │ ├── res │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ └── drawable-xhdpi │ │ │ └── ic_launcher.png │ └── resources.ap_ ├── gen │ └── com │ │ └── jcmore2 │ │ ├── imageprocessinglibrary │ │ └── R.java │ │ └── testimageprocessinglibrary │ │ ├── BuildConfig.java │ │ └── R.java ├── proguard-project.txt ├── project.properties ├── res │ ├── drawable-hdpi │ │ ├── ic_launcher.png │ │ ├── icon.jpeg │ │ └── imagen.jpg │ ├── drawable-mdpi │ │ ├── ic_launcher.png │ │ └── icon.jpeg │ ├── drawable-xhdpi │ │ ├── ic_launcher.png │ │ └── icon.jpeg │ ├── layout │ │ ├── activity_test.xml │ │ └── effect_view.xml │ ├── menu │ │ └── test.xml │ ├── values-sw600dp │ │ └── dimens.xml │ ├── values-sw720dp-land │ │ └── dimens.xml │ ├── values-v11 │ │ └── styles.xml │ ├── values-v14 │ │ └── styles.xml │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml └── src │ └── com │ └── jcmore2 │ └── testimageprocessinglibrary │ ├── HorizontalListView.java │ ├── ListEffectAdapter.java │ ├── ProcessingAsyncTask.java │ └── TestActivity.java └── raw └── demo_image.png /ImageProcessingLib/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ImageProcessingLib/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ImageProcessingLib 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /ImageProcessingLib/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /ImageProcessingLib/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 9 | 10 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /ImageProcessingLib/assets/Android-BitmapCache-2.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/assets/Android-BitmapCache-2.1.jar -------------------------------------------------------------------------------- /ImageProcessingLib/bin/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 9 | 10 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /ImageProcessingLib/bin/R.txt: -------------------------------------------------------------------------------- 1 | int drawable ic_launcher 0x7f020000 2 | int string app_name 0x7f030000 3 | int style AppBaseTheme 0x7f040000 4 | int style AppTheme 0x7f040001 5 | -------------------------------------------------------------------------------- /ImageProcessingLib/bin/classes/com/jcmore2/imageprocessing/ConvolutionMatrix.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/bin/classes/com/jcmore2/imageprocessing/ConvolutionMatrix.class -------------------------------------------------------------------------------- /ImageProcessingLib/bin/classes/com/jcmore2/imageprocessing/ImageProcessing.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/bin/classes/com/jcmore2/imageprocessing/ImageProcessing.class -------------------------------------------------------------------------------- /ImageProcessingLib/bin/classes/com/jcmore2/imageprocessing/filesystem/ImageFilesystemManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/bin/classes/com/jcmore2/imageprocessing/filesystem/ImageFilesystemManager.class -------------------------------------------------------------------------------- /ImageProcessingLib/bin/classes/com/jcmore2/imageprocessing/model/ImageProcessingModel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/bin/classes/com/jcmore2/imageprocessing/model/ImageProcessingModel.class -------------------------------------------------------------------------------- /ImageProcessingLib/bin/classes/com/jcmore2/imageprocessing/utils/Utils.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/bin/classes/com/jcmore2/imageprocessing/utils/Utils.class -------------------------------------------------------------------------------- /ImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/BuildConfig.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/BuildConfig.class -------------------------------------------------------------------------------- /ImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R$attr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R$attr.class -------------------------------------------------------------------------------- /ImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R$drawable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R$drawable.class -------------------------------------------------------------------------------- /ImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R$string.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R$string.class -------------------------------------------------------------------------------- /ImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R$style.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R$style.class -------------------------------------------------------------------------------- /ImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R.class -------------------------------------------------------------------------------- /ImageProcessingLib/bin/imageprocessinglib.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/bin/imageprocessinglib.jar -------------------------------------------------------------------------------- /ImageProcessingLib/bin/imageprocessinglibrary.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/bin/imageprocessinglibrary.jar -------------------------------------------------------------------------------- /ImageProcessingLib/bin/jarlist.cache: -------------------------------------------------------------------------------- 1 | # cache for current jar dependecy. DO NOT EDIT. 2 | # format is 3 | # Encoding is UTF-8 4 | -------------------------------------------------------------------------------- /ImageProcessingLib/bin/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/bin/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /ImageProcessingLib/bin/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/bin/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /ImageProcessingLib/bin/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/bin/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ImageProcessingLib/gen/com/jcmore2/imageprocessinglibrary/BuildConfig.java: -------------------------------------------------------------------------------- 1 | /** Automatically generated file. DO NOT MODIFY */ 2 | package com.jcmore2.imageprocessinglibrary; 3 | 4 | public final class BuildConfig { 5 | public final static boolean DEBUG = true; 6 | } -------------------------------------------------------------------------------- /ImageProcessingLib/gen/com/jcmore2/imageprocessinglibrary/R.java: -------------------------------------------------------------------------------- 1 | /* AUTO-GENERATED FILE. DO NOT MODIFY. 2 | * 3 | * This class was automatically generated by the 4 | * aapt tool from the resource data it found. It 5 | * should not be modified by hand. 6 | */ 7 | 8 | package com.jcmore2.imageprocessinglibrary; 9 | 10 | public final class R { 11 | public static final class attr { 12 | } 13 | public static final class drawable { 14 | public static int ic_launcher=0x7f020000; 15 | } 16 | public static final class string { 17 | public static int app_name=0x7f030000; 18 | } 19 | public static final class style { 20 | /** 21 | Base application theme, dependent on API level. This theme is replaced 22 | by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 23 | 24 | 25 | Theme customizations available in newer API levels can go in 26 | res/values-vXX/styles.xml, while customizations related to 27 | backward-compatibility can go here. 28 | 29 | 30 | Base application theme for API 11+. This theme completely replaces 31 | AppBaseTheme from res/values/styles.xml on API 11+ devices. 32 | 33 | API 11 theme customizations can go here. 34 | 35 | Base application theme for API 14+. This theme completely replaces 36 | AppBaseTheme from BOTH res/values/styles.xml and 37 | res/values-v11/styles.xml on API 14+ devices. 38 | 39 | API 14 theme customizations can go here. 40 | */ 41 | public static int AppBaseTheme=0x7f040000; 42 | /** Application theme. 43 | All customizations that are NOT specific to a particular API-level can go here. 44 | */ 45 | public static int AppTheme=0x7f040001; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ImageProcessingLib/libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/libs/android-support-v4.jar -------------------------------------------------------------------------------- /ImageProcessingLib/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /ImageProcessingLib/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-17 15 | android.library=true 16 | -------------------------------------------------------------------------------- /ImageProcessingLib/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /ImageProcessingLib/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /ImageProcessingLib/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/ImageProcessingLib/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ImageProcessingLib/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /ImageProcessingLib/res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /ImageProcessingLib/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ImageProcessingLibrary 4 | 5 | -------------------------------------------------------------------------------- /ImageProcessingLib/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | -------------------------------------------------------------------------------- /ImageProcessingLib/src/com/jcmore2/imageprocessing/ConvolutionMatrix.java: -------------------------------------------------------------------------------- 1 | package com.jcmore2.imageprocessing; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.Color; 5 | 6 | /** 7 | * Class to apply convolution matrix 8 | * 9 | * @author jcmore2 jcmore2@gmail.com 10 | * 11 | */ 12 | public class ConvolutionMatrix { 13 | public static final int SIZE = 3; 14 | 15 | public double[][] Matrix; 16 | public double Factor = 1; 17 | public double Offset = 1; 18 | 19 | public ConvolutionMatrix(int size) { 20 | Matrix = new double[size][size]; 21 | } 22 | 23 | public void setAll(double value) { 24 | for (int x = 0; x < SIZE; ++x) { 25 | for (int y = 0; y < SIZE; ++y) { 26 | Matrix[x][y] = value; 27 | } 28 | } 29 | } 30 | 31 | public void applyConfig(double[][] config) { 32 | for (int x = 0; x < SIZE; ++x) { 33 | for (int y = 0; y < SIZE; ++y) { 34 | Matrix[x][y] = config[x][y]; 35 | } 36 | } 37 | } 38 | 39 | public static Bitmap computeConvolution3x3(Bitmap src, 40 | ConvolutionMatrix matrix) { 41 | int width = src.getWidth(); 42 | int height = src.getHeight(); 43 | Bitmap result = Bitmap.createBitmap(width, height, src.getConfig()); 44 | 45 | int A, R, G, B; 46 | int sumR, sumG, sumB; 47 | int[][] pixels = new int[SIZE][SIZE]; 48 | 49 | for (int y = 0; y < height - 2; ++y) { 50 | for (int x = 0; x < width - 2; ++x) { 51 | 52 | // get pixel matrix 53 | for (int i = 0; i < SIZE; ++i) { 54 | for (int j = 0; j < SIZE; ++j) { 55 | pixels[i][j] = src.getPixel(x + i, y + j); 56 | } 57 | } 58 | 59 | // get alpha of center pixel 60 | A = Color.alpha(pixels[1][1]); 61 | 62 | // init color sum 63 | sumR = sumG = sumB = 0; 64 | 65 | // get sum of RGB on matrix 66 | for (int i = 0; i < SIZE; ++i) { 67 | for (int j = 0; j < SIZE; ++j) { 68 | sumR += (Color.red(pixels[i][j]) * matrix.Matrix[i][j]); 69 | sumG += (Color.green(pixels[i][j]) * matrix.Matrix[i][j]); 70 | sumB += (Color.blue(pixels[i][j]) * matrix.Matrix[i][j]); 71 | } 72 | } 73 | 74 | // get final Red 75 | R = (int) (sumR / matrix.Factor + matrix.Offset); 76 | if (R < 0) { 77 | R = 0; 78 | } else if (R > 255) { 79 | R = 255; 80 | } 81 | 82 | // get final Green 83 | G = (int) (sumG / matrix.Factor + matrix.Offset); 84 | if (G < 0) { 85 | G = 0; 86 | } else if (G > 255) { 87 | G = 255; 88 | } 89 | 90 | // get final Blue 91 | B = (int) (sumB / matrix.Factor + matrix.Offset); 92 | if (B < 0) { 93 | B = 0; 94 | } else if (B > 255) { 95 | B = 255; 96 | } 97 | 98 | // apply new pixel 99 | result.setPixel(x + 1, y + 1, Color.argb(A, R, G, B)); 100 | } 101 | } 102 | 103 | // final image 104 | return result; 105 | } 106 | } -------------------------------------------------------------------------------- /ImageProcessingLib/src/com/jcmore2/imageprocessing/ImageProcessing.java: -------------------------------------------------------------------------------- 1 | package com.jcmore2.imageprocessing; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Random; 5 | 6 | import com.jcmore2.imageprocessing.model.ImageProcessingModel; 7 | 8 | import android.graphics.Bitmap; 9 | import android.graphics.Bitmap.Config; 10 | import android.graphics.BlurMaskFilter; 11 | import android.graphics.BlurMaskFilter.Blur; 12 | import android.graphics.Canvas; 13 | import android.graphics.Color; 14 | import android.graphics.LinearGradient; 15 | import android.graphics.Matrix; 16 | import android.graphics.Paint; 17 | import android.graphics.Point; 18 | import android.graphics.PorterDuff; 19 | import android.graphics.PorterDuff.Mode; 20 | import android.graphics.PorterDuffXfermode; 21 | import android.graphics.Rect; 22 | import android.graphics.RectF; 23 | import android.graphics.Shader.TileMode; 24 | 25 | /** 26 | * Class to manage the image processing and filters 27 | * 28 | * @author jcmore2 jcmore2@gmail.com 29 | * 30 | */ 31 | public class ImageProcessing { 32 | 33 | 34 | /** 35 | * Constantes para identificar el nombre de los procesos 36 | */ 37 | public static final String NORMAL = "Normal"; 38 | public static final String HIGHLIGHT = "Highlight"; 39 | public static final String INVERT = "Invert"; 40 | public static final String GREY = "Grey"; 41 | public static final String GAMMA = "Gamma"; 42 | public static final String COLOR_FILTER = "Color Filter"; 43 | public static final String SEPIA = "Sepia"; 44 | public static final String COLOR_DEPTH = "Color Depth"; 45 | public static final String CONTRAST = "Contrast"; 46 | public static final String ROTATE = "Rotate"; 47 | public static final String BRIGHTNESS = "Brightness"; 48 | public static final String BLUR = "Blur"; 49 | public static final String SHARPEN = "Sharpen"; 50 | public static final String MEAN = "Mean"; 51 | public static final String SMOOTH = "Smooth"; 52 | public static final String EMBOSS = "Emboss"; 53 | public static final String ENGRAVE = "Engrave"; 54 | public static final String BOOST = "Boost"; 55 | public static final String ROUND = "Round"; 56 | public static final String MARK = "Mark"; 57 | public static final String FLIP = "Flip"; 58 | public static final String COLOR_REPLACE = "Color Replace"; 59 | public static final String TINT = "Tint"; 60 | public static final String FLEA = "Flea"; 61 | public static final String BLACK = "Black"; 62 | public static final String SNOW = "Snow"; 63 | public static final String SHADDING = "Shadding"; 64 | public static final String SATURATION = "Saturation"; 65 | public static final String HUE = "Hue"; 66 | public static final String REFLECTION = "Reflection"; 67 | 68 | /** 69 | * Constantes para identificar cada tipo de procesado 70 | */ 71 | public static final int PROCESSING_NORMAL = 0; 72 | public static final int PROCESSING_HIGHLIGHT = 1; 73 | public static final int PROCESSING_INVERT = 2; 74 | public static final int PROCESSING_GREY = 3; 75 | public static final int PROCESSING_GAMMA = 4; 76 | public static final int PROCESSING_COLOR_FILTER = 5; 77 | public static final int PROCESSING_SEPIA = 6; 78 | public static final int PROCESSING_COLOR_DEPTH = 7; 79 | public static final int PROCESSING_CONTRAST = 8; 80 | public static final int PROCESSING_ROTATE = 9; 81 | public static final int PROCESSING_BRIGHTNESS = 10; 82 | public static final int PROCESSING_GAUSSIAN_BLUR = 11; 83 | public static final int PROCESSING_SHARPEN = 12; 84 | public static final int PROCESSING_MEAN = 13; 85 | public static final int PROCESSING_SMOOTH = 14; 86 | public static final int PROCESSING_EMBOSS = 15; 87 | public static final int PROCESSING_ENGRAVE = 16; 88 | public static final int PROCESSING_BOOST = 17; 89 | public static final int PROCESSING_ROUND = 18; 90 | public static final int PROCESSING_MARK = 19; 91 | public static final int PROCESSING_FLIP = 20; 92 | public static final int PROCESSING_COLOR_REPLACE = 21; 93 | public static final int PROCESSING_TINT = 22; 94 | public static final int PROCESSING_FLEA = 23; 95 | public static final int PROCESSING_BLACK = 24; 96 | public static final int PROCESSING_SNOW = 25; 97 | public static final int PROCESSING_SHADDING = 26; 98 | public static final int PROCESSING_SATURATION = 27; 99 | public static final int PROCESSING_HUE = 28; 100 | public static final int PROCESSING_REFLECTION = 29; 101 | 102 | public static ArrayList effectList = new ArrayList(); 103 | 104 | static { 105 | effectList.add(PROCESSING_NORMAL); 106 | effectList.add(PROCESSING_HIGHLIGHT); 107 | effectList.add(PROCESSING_INVERT); 108 | effectList.add(PROCESSING_GREY); 109 | effectList.add(PROCESSING_GAMMA); 110 | effectList.add(PROCESSING_COLOR_FILTER); 111 | effectList.add(PROCESSING_SEPIA); 112 | effectList.add(PROCESSING_COLOR_DEPTH); 113 | effectList.add(PROCESSING_CONTRAST); 114 | effectList.add(PROCESSING_ROTATE); 115 | effectList.add(PROCESSING_BRIGHTNESS); 116 | effectList.add(PROCESSING_GAUSSIAN_BLUR); 117 | effectList.add(PROCESSING_SHARPEN); 118 | effectList.add(PROCESSING_MEAN); 119 | effectList.add(PROCESSING_SMOOTH); 120 | effectList.add(PROCESSING_EMBOSS); 121 | effectList.add(PROCESSING_ENGRAVE); 122 | effectList.add(PROCESSING_BOOST); 123 | effectList.add(PROCESSING_ROUND); 124 | effectList.add(PROCESSING_MARK); 125 | effectList.add(PROCESSING_FLIP); 126 | effectList.add(PROCESSING_COLOR_REPLACE); 127 | effectList.add(PROCESSING_TINT); 128 | effectList.add(PROCESSING_FLEA); 129 | effectList.add(PROCESSING_BLACK); 130 | effectList.add(PROCESSING_SNOW); 131 | effectList.add(PROCESSING_SHADDING); 132 | effectList.add(PROCESSING_SATURATION); 133 | effectList.add(PROCESSING_HUE); 134 | effectList.add(PROCESSING_REFLECTION); 135 | 136 | } 137 | 138 | 139 | public static ArrayList imageProcessedList = new ArrayList(); 140 | 141 | static { 142 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_NORMAL, NORMAL, null)); 143 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_HIGHLIGHT, HIGHLIGHT, null)); 144 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_INVERT, INVERT, null)); 145 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_GREY, GREY, null)); 146 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_GAMMA, GAMMA, null)); 147 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_COLOR_FILTER, COLOR_FILTER, null)); 148 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_SEPIA, SEPIA, null)); 149 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_COLOR_DEPTH, COLOR_DEPTH, null)); 150 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_CONTRAST, CONTRAST, null)); 151 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_ROTATE, ROTATE, null)); 152 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_BRIGHTNESS, BRIGHTNESS, null)); 153 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_GAUSSIAN_BLUR, BLUR, null)); 154 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_SHARPEN, SHARPEN, null)); 155 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_MEAN, MEAN, null)); 156 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_SMOOTH, SMOOTH, null)); 157 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_EMBOSS, EMBOSS, null)); 158 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_ENGRAVE, ENGRAVE, null)); 159 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_BOOST, BOOST, null)); 160 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_ROUND, ROUND, null)); 161 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_MARK, MARK, null)); 162 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_FLIP, FLIP, null)); 163 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_COLOR_REPLACE, COLOR_REPLACE, null)); 164 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_TINT, TINT, null)); 165 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_FLEA, FLEA, null)); 166 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_BLACK, BLACK, null)); 167 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_SNOW, SNOW, null)); 168 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_SHADDING, SHADDING, null)); 169 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_SATURATION, SATURATION, null)); 170 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_HUE, HUE, null)); 171 | imageProcessedList.add(new ImageProcessingModel(PROCESSING_REFLECTION, REFLECTION, null)); 172 | 173 | } 174 | 175 | 176 | /** 177 | * Devuelve la misma imagen 178 | * 179 | * @param src 180 | * @return 181 | */ 182 | public static Bitmap applyNormalImage(Bitmap bm) { 183 | // return out final image 184 | return bm; 185 | } 186 | 187 | 188 | /** 189 | * Crea un aura en torno a la imagen 190 | * 191 | * @param src 192 | * @return 193 | */ 194 | public static Bitmap applyHighlightImage(Bitmap src) { 195 | // create new bitmap, which will be painted and becomes result image 196 | Bitmap bmOut = Bitmap.createBitmap(src.getWidth() + 96, 197 | src.getHeight() + 96, Bitmap.Config.ARGB_8888); 198 | // setup canvas for painting 199 | Canvas canvas = new Canvas(bmOut); 200 | // setup default color 201 | canvas.drawColor(0, PorterDuff.Mode.CLEAR); 202 | 203 | // create a blur paint for capturing alpha 204 | Paint ptBlur = new Paint(); 205 | ptBlur.setMaskFilter(new BlurMaskFilter(15, Blur.NORMAL)); 206 | int[] offsetXY = new int[2]; 207 | // capture alpha into a bitmap 208 | Bitmap bmAlpha = src.extractAlpha(ptBlur, offsetXY); 209 | // create a color paint 210 | Paint ptAlphaColor = new Paint(); 211 | ptAlphaColor.setColor(0xFFFFFFFF); 212 | // paint color for captured alpha region (bitmap) 213 | canvas.drawBitmap(bmAlpha, offsetXY[0], offsetXY[1], ptAlphaColor); 214 | // free memory 215 | bmAlpha.recycle(); 216 | 217 | // paint the image source 218 | canvas.drawBitmap(src, 0, 0, null); 219 | 220 | // return out final image 221 | return bmOut; 222 | } 223 | 224 | /** 225 | * Invierte el color de la imagen 226 | * 227 | * @param src 228 | * @return 229 | */ 230 | public static Bitmap applyInvert(Bitmap src) { 231 | // create new bitmap with the same settings as source bitmap 232 | Bitmap bmOut = Bitmap.createBitmap(src.getWidth(), src.getHeight(), 233 | src.getConfig()); 234 | // color info 235 | int A, R, G, B; 236 | int pixelColor; 237 | // image size 238 | int height = src.getHeight(); 239 | int width = src.getWidth(); 240 | 241 | // scan through every pixel 242 | for (int y = 0; y < height; y++) { 243 | for (int x = 0; x < width; x++) { 244 | // get one pixel 245 | pixelColor = src.getPixel(x, y); 246 | // saving alpha channel 247 | A = Color.alpha(pixelColor); 248 | // inverting byte for each R/G/B channel 249 | R = 255 - Color.red(pixelColor); 250 | G = 255 - Color.green(pixelColor); 251 | B = 255 - Color.blue(pixelColor); 252 | // set newly-inverted pixel to output image 253 | bmOut.setPixel(x, y, Color.argb(A, R, G, B)); 254 | } 255 | } 256 | 257 | // return final bitmap 258 | return bmOut; 259 | } 260 | 261 | /** 262 | * Convierte la imagen a grises 263 | * 264 | * @param src 265 | * @return 266 | */ 267 | public static Bitmap applyGreyscale(Bitmap src) { 268 | // constant factors 269 | final double GS_RED = 0.299; 270 | final double GS_GREEN = 0.587; 271 | final double GS_BLUE = 0.114; 272 | 273 | // create output bitmap 274 | Bitmap bmOut = Bitmap.createBitmap(src.getWidth(), src.getHeight(), 275 | src.getConfig()); 276 | // pixel information 277 | int A, R, G, B; 278 | int pixel; 279 | 280 | // get image size 281 | int width = src.getWidth(); 282 | int height = src.getHeight(); 283 | 284 | // scan through every single pixel 285 | for (int x = 0; x < width; ++x) { 286 | for (int y = 0; y < height; ++y) { 287 | // get one pixel color 288 | pixel = src.getPixel(x, y); 289 | // retrieve color of all channels 290 | A = Color.alpha(pixel); 291 | R = Color.red(pixel); 292 | G = Color.green(pixel); 293 | B = Color.blue(pixel); 294 | // take conversion up to one single value 295 | R = G = B = (int) (GS_RED * R + GS_GREEN * G + GS_BLUE * B); 296 | // set new pixel color to output bitmap 297 | bmOut.setPixel(x, y, Color.argb(A, R, G, B)); 298 | } 299 | } 300 | 301 | // return final image 302 | return bmOut; 303 | } 304 | 305 | /** 306 | * Modifica el gamma de los colores de la imagen 307 | * 308 | * @param src 309 | * @param red 310 | * (0.6, 1.8) 311 | * @param green 312 | * (0.6, 1.8) 313 | * @param blue 314 | * (0.6, 1.8) 315 | * @return 316 | */ 317 | public static Bitmap applyGamma(Bitmap src, double red, double green, 318 | double blue) { 319 | // create output image 320 | Bitmap bmOut = Bitmap.createBitmap(src.getWidth(), src.getHeight(), 321 | src.getConfig()); 322 | // get image size 323 | int width = src.getWidth(); 324 | int height = src.getHeight(); 325 | // color information 326 | int A, R, G, B; 327 | int pixel; 328 | // constant value curve 329 | final int MAX_SIZE = 256; 330 | final double MAX_VALUE_DBL = 255.0; 331 | final int MAX_VALUE_INT = 255; 332 | final double REVERSE = 1.0; 333 | 334 | // gamma arrays 335 | int[] gammaR = new int[MAX_SIZE]; 336 | int[] gammaG = new int[MAX_SIZE]; 337 | int[] gammaB = new int[MAX_SIZE]; 338 | 339 | // setting values for every gamma channels 340 | for (int i = 0; i < MAX_SIZE; ++i) { 341 | gammaR[i] = (int) Math.min( 342 | MAX_VALUE_INT, 343 | (int) ((MAX_VALUE_DBL * Math.pow(i / MAX_VALUE_DBL, REVERSE 344 | / red)) + 0.5)); 345 | gammaG[i] = (int) Math.min( 346 | MAX_VALUE_INT, 347 | (int) ((MAX_VALUE_DBL * Math.pow(i / MAX_VALUE_DBL, REVERSE 348 | / green)) + 0.5)); 349 | gammaB[i] = (int) Math.min( 350 | MAX_VALUE_INT, 351 | (int) ((MAX_VALUE_DBL * Math.pow(i / MAX_VALUE_DBL, REVERSE 352 | / blue)) + 0.5)); 353 | } 354 | 355 | // apply gamma table 356 | for (int x = 0; x < width; ++x) { 357 | for (int y = 0; y < height; ++y) { 358 | // get pixel color 359 | pixel = src.getPixel(x, y); 360 | A = Color.alpha(pixel); 361 | // look up gamma 362 | R = gammaR[Color.red(pixel)]; 363 | G = gammaG[Color.green(pixel)]; 364 | B = gammaB[Color.blue(pixel)]; 365 | // set new color to output bitmap 366 | bmOut.setPixel(x, y, Color.argb(A, R, G, B)); 367 | } 368 | } 369 | 370 | // return final image 371 | return bmOut; 372 | } 373 | 374 | /** 375 | * Filtrar la imagen por color 376 | * 377 | * @param src 378 | * @param red 379 | * (100) (0) (0) (150) 380 | * @param green 381 | * (0) (100) (0) (150) 382 | * @param blue 383 | * (0) (0) (100) (150) 384 | * @return 385 | */ 386 | public static Bitmap applyColorFilter(Bitmap src, double red, double green, 387 | double blue) { 388 | // image size 389 | int width = src.getWidth(); 390 | int height = src.getHeight(); 391 | // create output bitmap 392 | Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig()); 393 | // color information 394 | int A, R, G, B; 395 | int pixel; 396 | 397 | // scan through all pixels 398 | for (int x = 0; x < width; ++x) { 399 | for (int y = 0; y < height; ++y) { 400 | // get pixel color 401 | pixel = src.getPixel(x, y); 402 | // apply filtering on each channel R, G, B 403 | A = Color.alpha(pixel); 404 | R = (int) (Color.red(pixel) * red); 405 | G = (int) (Color.green(pixel) * green); 406 | B = (int) (Color.blue(pixel) * blue); 407 | // set new color pixel to output bitmap 408 | bmOut.setPixel(x, y, Color.argb(A, R, G, B)); 409 | } 410 | } 411 | 412 | // return final image 413 | return bmOut; 414 | } 415 | 416 | /** 417 | * Imagen en tono sepia 418 | * 419 | * @param src 420 | * @param depth 421 | * @param red 422 | * @param green 423 | * @param blue 424 | * @return 425 | */ 426 | public static Bitmap applySepiaToningEffect(Bitmap src, int depth, 427 | double red, double green, double blue) { 428 | // image size 429 | int width = src.getWidth(); 430 | int height = src.getHeight(); 431 | // create output bitmap 432 | Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig()); 433 | // constant grayscale 434 | final double GS_RED = 0.3; 435 | final double GS_GREEN = 0.59; 436 | final double GS_BLUE = 0.11; 437 | // color information 438 | int A, R, G, B; 439 | int pixel; 440 | 441 | // scan through all pixels 442 | for (int x = 0; x < width; ++x) { 443 | for (int y = 0; y < height; ++y) { 444 | // get pixel color 445 | pixel = src.getPixel(x, y); 446 | // get color on each channel 447 | A = Color.alpha(pixel); 448 | R = Color.red(pixel); 449 | G = Color.green(pixel); 450 | B = Color.blue(pixel); 451 | // apply grayscale sample 452 | B = G = R = (int) (GS_RED * R + GS_GREEN * G + GS_BLUE * B); 453 | 454 | // apply intensity level for sepid-toning on each channel 455 | R += (depth * red); 456 | if (R > 255) { 457 | R = 255; 458 | } 459 | 460 | G += (depth * green); 461 | if (G > 255) { 462 | G = 255; 463 | } 464 | 465 | B += (depth * blue); 466 | if (B > 255) { 467 | B = 255; 468 | } 469 | 470 | // set new pixel color to output image 471 | bmOut.setPixel(x, y, Color.argb(A, R, G, B)); 472 | } 473 | } 474 | 475 | // return final image 476 | return bmOut; 477 | } 478 | 479 | /** 480 | * Imagen con menos pixeles de profundidad 481 | * 482 | * @param src 483 | * @param bitOffset 484 | * (32,64,128) 485 | * @return 486 | */ 487 | public static Bitmap applyColorDepth(Bitmap src, int bitOffset) { 488 | // get image size 489 | int width = src.getWidth(); 490 | int height = src.getHeight(); 491 | // create output bitmap 492 | Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig()); 493 | // color information 494 | int A, R, G, B; 495 | int pixel; 496 | 497 | // scan through all pixels 498 | for (int x = 0; x < width; ++x) { 499 | for (int y = 0; y < height; ++y) { 500 | // get pixel color 501 | pixel = src.getPixel(x, y); 502 | A = Color.alpha(pixel); 503 | R = Color.red(pixel); 504 | G = Color.green(pixel); 505 | B = Color.blue(pixel); 506 | 507 | // round-off color offset 508 | R = ((R + (bitOffset / 2)) 509 | - ((R + (bitOffset / 2)) % bitOffset) - 1); 510 | if (R < 0) { 511 | R = 0; 512 | } 513 | G = ((G + (bitOffset / 2)) 514 | - ((G + (bitOffset / 2)) % bitOffset) - 1); 515 | if (G < 0) { 516 | G = 0; 517 | } 518 | B = ((B + (bitOffset / 2)) 519 | - ((B + (bitOffset / 2)) % bitOffset) - 1); 520 | if (B < 0) { 521 | B = 0; 522 | } 523 | 524 | // set pixel color to output bitmap 525 | bmOut.setPixel(x, y, Color.argb(A, R, G, B)); 526 | } 527 | } 528 | 529 | // return final image 530 | return bmOut; 531 | } 532 | 533 | /** 534 | * Imagen con contraste a negro 535 | * 536 | * @param src 537 | * @param value 538 | * (50,100) 539 | * @return 540 | */ 541 | public static Bitmap applyContrast(Bitmap src, double value) { 542 | // image size 543 | int width = src.getWidth(); 544 | int height = src.getHeight(); 545 | // create output bitmap 546 | Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig()); 547 | // color information 548 | int A, R, G, B; 549 | int pixel; 550 | // get contrast value 551 | double contrast = Math.pow((100 + value) / 100, 2); 552 | 553 | // scan through all pixels 554 | for (int x = 0; x < width; ++x) { 555 | for (int y = 0; y < height; ++y) { 556 | // get pixel color 557 | pixel = src.getPixel(x, y); 558 | A = Color.alpha(pixel); 559 | // apply filter contrast for every channel R, G, B 560 | R = Color.red(pixel); 561 | R = (int) (((((R / 255.0) - 0.5) * contrast) + 0.5) * 255.0); 562 | if (R < 0) { 563 | R = 0; 564 | } else if (R > 255) { 565 | R = 255; 566 | } 567 | 568 | G = Color.red(pixel); 569 | G = (int) (((((G / 255.0) - 0.5) * contrast) + 0.5) * 255.0); 570 | if (G < 0) { 571 | G = 0; 572 | } else if (G > 255) { 573 | G = 255; 574 | } 575 | 576 | B = Color.red(pixel); 577 | B = (int) (((((B / 255.0) - 0.5) * contrast) + 0.5) * 255.0); 578 | if (B < 0) { 579 | B = 0; 580 | } else if (B > 255) { 581 | B = 255; 582 | } 583 | 584 | // set new pixel color to output bitmap 585 | bmOut.setPixel(x, y, Color.argb(A, R, G, B)); 586 | } 587 | } 588 | 589 | // return final image 590 | return bmOut; 591 | } 592 | 593 | /** 594 | * Imagen rotada 595 | * 596 | * @param src 597 | * @param degree 598 | * (45, 90,180) 599 | * @return 600 | */ 601 | public static Bitmap applyRotate(Bitmap src, float degree) { 602 | // create new matrix 603 | Matrix matrix = new Matrix(); 604 | // setup rotation degree 605 | matrix.postRotate(degree); 606 | 607 | // return new bitmap rotated using matrix 608 | return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), 609 | matrix, true); 610 | } 611 | 612 | /** 613 | * Imagen con mas (valores positivos) o menos brillo (valores negativos) 614 | * 615 | * @param src 616 | * @param value 617 | * (40, -60) 618 | * @return 619 | */ 620 | public static Bitmap applyBrightness(Bitmap src, int value) { 621 | // image size 622 | int width = src.getWidth(); 623 | int height = src.getHeight(); 624 | // create output bitmap 625 | Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig()); 626 | // color information 627 | int A, R, G, B; 628 | int pixel; 629 | 630 | // scan through all pixels 631 | for (int x = 0; x < width; ++x) { 632 | for (int y = 0; y < height; ++y) { 633 | // get pixel color 634 | pixel = src.getPixel(x, y); 635 | A = Color.alpha(pixel); 636 | R = Color.red(pixel); 637 | G = Color.green(pixel); 638 | B = Color.blue(pixel); 639 | 640 | // increase/decrease each channel 641 | R += value; 642 | if (R > 255) { 643 | R = 255; 644 | } else if (R < 0) { 645 | R = 0; 646 | } 647 | 648 | G += value; 649 | if (G > 255) { 650 | G = 255; 651 | } else if (G < 0) { 652 | G = 0; 653 | } 654 | 655 | B += value; 656 | if (B > 255) { 657 | B = 255; 658 | } else if (B < 0) { 659 | B = 0; 660 | } 661 | 662 | // apply new pixel color to output bitmap 663 | bmOut.setPixel(x, y, Color.argb(A, R, G, B)); 664 | } 665 | } 666 | 667 | // return final image 668 | return bmOut; 669 | } 670 | 671 | /** 672 | * Aplica una funcion Gausiana a la imagen 673 | * 674 | * @param src 675 | * @return 676 | */ 677 | public static Bitmap applyGaussianBlur(Bitmap src) { 678 | double[][] GaussianBlurConfig = new double[][] { { 1, 2, 1 }, 679 | { 2, 4, 2 }, { 1, 2, 1 } }; 680 | ConvolutionMatrix convMatrix = new ConvolutionMatrix(3); 681 | convMatrix.applyConfig(GaussianBlurConfig); 682 | convMatrix.Factor = 16; 683 | convMatrix.Offset = 0; 684 | return ConvolutionMatrix.computeConvolution3x3(src, convMatrix); 685 | } 686 | 687 | /** 688 | * Imagen con los bordes mas afilados 689 | * 690 | * @param src 691 | * @param weight 692 | * @return 693 | */ 694 | public static Bitmap applySharpen(Bitmap src, double weight) { 695 | double[][] SharpConfig = new double[][] { { 0, -2, 0 }, 696 | { -2, weight, -2 }, { 0, -2, 0 } }; 697 | ConvolutionMatrix convMatrix = new ConvolutionMatrix(3); 698 | convMatrix.applyConfig(SharpConfig); 699 | convMatrix.Factor = weight - 8; 700 | return ConvolutionMatrix.computeConvolution3x3(src, convMatrix); 701 | } 702 | 703 | /** 704 | * Imagen con la Media eliminada 705 | * 706 | * @param src 707 | * @return 708 | */ 709 | public static Bitmap applyMeanRemoval(Bitmap src) { 710 | double[][] MeanRemovalConfig = new double[][] { { -1, -1, -1 }, 711 | { -1, 9, -1 }, { -1, -1, -1 } }; 712 | ConvolutionMatrix convMatrix = new ConvolutionMatrix(3); 713 | convMatrix.applyConfig(MeanRemovalConfig); 714 | convMatrix.Factor = 1; 715 | convMatrix.Offset = 0; 716 | return ConvolutionMatrix.computeConvolution3x3(src, convMatrix); 717 | } 718 | 719 | /** 720 | * Imagen suavizada 721 | * 722 | * @param src 723 | * @param value 724 | * (13) 725 | * @return 726 | */ 727 | public static Bitmap applySmooth(Bitmap src, double value) { 728 | ConvolutionMatrix convMatrix = new ConvolutionMatrix(3); 729 | convMatrix.setAll(1); 730 | convMatrix.Matrix[1][1] = value; 731 | convMatrix.Factor = value + 8; 732 | convMatrix.Offset = 1; 733 | return ConvolutionMatrix.computeConvolution3x3(src, convMatrix); 734 | } 735 | 736 | /** 737 | * Imagen realzada 738 | * 739 | * @param src 740 | * @return 741 | */ 742 | public static Bitmap applyEmboss(Bitmap src) { 743 | double[][] EmbossConfig = new double[][] { { -1, 0, -1 }, { 0, 4, 0 }, 744 | { -1, 0, -1 } }; 745 | ConvolutionMatrix convMatrix = new ConvolutionMatrix(3); 746 | convMatrix.applyConfig(EmbossConfig); 747 | convMatrix.Factor = 1; 748 | convMatrix.Offset = 127; 749 | return ConvolutionMatrix.computeConvolution3x3(src, convMatrix); 750 | } 751 | 752 | /** 753 | * Imagen en gris con bordes marcados 754 | * 755 | * @param src 756 | * @return 757 | */ 758 | public static Bitmap applyEngrave(Bitmap src) { 759 | ConvolutionMatrix convMatrix = new ConvolutionMatrix(3); 760 | convMatrix.setAll(0); 761 | convMatrix.Matrix[0][0] = -2; 762 | convMatrix.Matrix[1][1] = 2; 763 | convMatrix.Factor = 1; 764 | convMatrix.Offset = 95; 765 | return ConvolutionMatrix.computeConvolution3x3(src, convMatrix); 766 | } 767 | 768 | // type definition 769 | public static final int BOOST_RED = 1; 770 | public static final int BOOST_GREEN = 2; 771 | public static final int BOOST_BLUE = 3; 772 | 773 | /** 774 | * Imagen con los colores marcados 775 | * 776 | * @param src 777 | * @param type 778 | * (1-rojo, 2-verde, 3-azul) 779 | * @param percent 780 | * @return 781 | */ 782 | public static Bitmap applyBoost(Bitmap src, int type, float percent) { 783 | int width = src.getWidth(); 784 | int height = src.getHeight(); 785 | Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig()); 786 | 787 | int A, R, G, B; 788 | int pixel; 789 | 790 | for (int x = 0; x < width; ++x) { 791 | for (int y = 0; y < height; ++y) { 792 | pixel = src.getPixel(x, y); 793 | A = Color.alpha(pixel); 794 | R = Color.red(pixel); 795 | G = Color.green(pixel); 796 | B = Color.blue(pixel); 797 | if (type == 1) { 798 | R = (int) (R * (1 + percent)); 799 | if (R > 255) 800 | R = 255; 801 | } else if (type == 2) { 802 | G = (int) (G * (1 + percent)); 803 | if (G > 255) 804 | G = 255; 805 | } else if (type == 3) { 806 | B = (int) (B * (1 + percent)); 807 | if (B > 255) 808 | B = 255; 809 | } 810 | bmOut.setPixel(x, y, Color.argb(A, R, G, B)); 811 | } 812 | } 813 | return bmOut; 814 | } 815 | 816 | /** 817 | * Imagen con bordes redondeados 818 | * 819 | * @param src 820 | * @param round 821 | * (5,10,...) 822 | * @return 823 | */ 824 | public static Bitmap applyRoundCorner(Bitmap src, float round) { 825 | // image size 826 | int width = src.getWidth(); 827 | int height = src.getHeight(); 828 | // create bitmap output 829 | Bitmap result = Bitmap.createBitmap(width, height, Config.ARGB_8888); 830 | // set canvas for painting 831 | Canvas canvas = new Canvas(result); 832 | canvas.drawARGB(0, 0, 0, 0); 833 | 834 | // config paint 835 | final Paint paint = new Paint(); 836 | paint.setAntiAlias(true); 837 | paint.setColor(Color.BLACK); 838 | 839 | // config rectangle for embedding 840 | final Rect rect = new Rect(0, 0, width, height); 841 | final RectF rectF = new RectF(rect); 842 | 843 | // draw rect to canvas 844 | canvas.drawRoundRect(rectF, round, round, paint); 845 | 846 | // create Xfer mode 847 | paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); 848 | // draw source image to canvas 849 | canvas.drawBitmap(src, rect, rect, paint); 850 | 851 | // return final image 852 | return result; 853 | } 854 | 855 | /** 856 | * Imagen con una marca de agua 857 | * 858 | * @param src 859 | * @param watermark 860 | * (Texto de la marca) 861 | * @param location 862 | * (Localizacion) 863 | * @param color 864 | * @param alpha 865 | * @param size 866 | * @param underline 867 | * @return 868 | */ 869 | public static Bitmap applyMark(Bitmap src, String watermark, 870 | Point location, int color, int alpha, int size, boolean underline) { 871 | int w = src.getWidth(); 872 | int h = src.getHeight(); 873 | Bitmap result = Bitmap.createBitmap(w, h, src.getConfig()); 874 | 875 | Canvas canvas = new Canvas(result); 876 | canvas.drawBitmap(src, 0, 0, null); 877 | 878 | Paint paint = new Paint(); 879 | paint.setColor(color); 880 | paint.setAlpha(alpha); 881 | paint.setTextSize(size); 882 | paint.setAntiAlias(true); 883 | paint.setUnderlineText(underline); 884 | canvas.drawText(watermark, location.x, location.y, paint); 885 | 886 | return result; 887 | } 888 | 889 | // type definition 890 | public static final int FLIP_VERTICAL = 1; 891 | public static final int FLIP_HORIZONTAL = 2; 892 | 893 | /** 894 | * Imagen en modo espejo (vertical horizontal) 895 | * 896 | * @param src 897 | * @param type 898 | * @return 899 | */ 900 | public static Bitmap applyFlip(Bitmap src, int type) { 901 | // create new matrix for transformation 902 | Matrix matrix = new Matrix(); 903 | // if vertical 904 | if (type == FLIP_VERTICAL) { 905 | // y = y * -1 906 | matrix.preScale(1.0f, -1.0f); 907 | } 908 | // if horizonal 909 | else if (type == FLIP_HORIZONTAL) { 910 | // x = x * -1 911 | matrix.preScale(-1.0f, 1.0f); 912 | // unknown type 913 | } else { 914 | return null; 915 | } 916 | 917 | // return transformed image 918 | return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), 919 | matrix, true); 920 | } 921 | 922 | /** 923 | * Imagen con los colores reemplazados 924 | * 925 | * @param bitmap 926 | * @param fromColor 927 | * @param targetColor 928 | * @return 929 | */ 930 | public static Bitmap applyReplaceColor(Bitmap bitmap, int fromColor, 931 | int targetColor) { 932 | if (bitmap == null) { 933 | return null; 934 | } 935 | 936 | int width = bitmap.getWidth(); 937 | int height = bitmap.getHeight(); 938 | int[] pixels = new int[width * height]; 939 | bitmap.getPixels(pixels, 0, width, 0, 0, width, height); 940 | 941 | for (int x = 0; x < pixels.length; ++x) { 942 | pixels[x] = (pixels[x] == fromColor) ? targetColor : pixels[x]; 943 | } 944 | 945 | Bitmap newImage = Bitmap 946 | .createBitmap(width, height, bitmap.getConfig()); 947 | newImage.setPixels(pixels, 0, width, 0, 0, width, height); 948 | 949 | return newImage; 950 | } 951 | 952 | private static final double PI = 3.14159d; 953 | private static final double FULL_CIRCLE_DEGREE = 360d; 954 | private static final double HALF_CIRCLE_DEGREE = 180d; 955 | private static final double RANGE = 256d; 956 | 957 | /** 958 | * Imagen tintada 959 | * 960 | * @param src 961 | * @param degree 962 | * @return 963 | */ 964 | public static Bitmap applyTintImage(Bitmap src, int degree) { 965 | 966 | int width = src.getWidth(); 967 | int height = src.getHeight(); 968 | 969 | int[] pix = new int[width * height]; 970 | src.getPixels(pix, 0, width, 0, 0, width, height); 971 | 972 | int RY, GY, BY, RYY, GYY, BYY, R, G, B, Y; 973 | double angle = (PI * (double) degree) / HALF_CIRCLE_DEGREE; 974 | 975 | int S = (int) (RANGE * Math.sin(angle)); 976 | int C = (int) (RANGE * Math.cos(angle)); 977 | 978 | for (int y = 0; y < height; y++) 979 | for (int x = 0; x < width; x++) { 980 | int index = y * width + x; 981 | int r = (pix[index] >> 16) & 0xff; 982 | int g = (pix[index] >> 8) & 0xff; 983 | int b = pix[index] & 0xff; 984 | RY = (70 * r - 59 * g - 11 * b) / 100; 985 | GY = (-30 * r + 41 * g - 11 * b) / 100; 986 | BY = (-30 * r - 59 * g + 89 * b) / 100; 987 | Y = (30 * r + 59 * g + 11 * b) / 100; 988 | RYY = (S * BY + C * RY) / 256; 989 | BYY = (C * BY - S * RY) / 256; 990 | GYY = (-51 * RYY - 19 * BYY) / 100; 991 | R = Y + RYY; 992 | R = (R < 0) ? 0 : ((R > 255) ? 255 : R); 993 | G = Y + GYY; 994 | G = (G < 0) ? 0 : ((G > 255) ? 255 : G); 995 | B = Y + BYY; 996 | B = (B < 0) ? 0 : ((B > 255) ? 255 : B); 997 | pix[index] = 0xff000000 | (R << 16) | (G << 8) | B; 998 | } 999 | 1000 | Bitmap outBitmap = Bitmap.createBitmap(width, height, src.getConfig()); 1001 | outBitmap.setPixels(pix, 0, width, 0, 0, width, height); 1002 | 1003 | pix = null; 1004 | 1005 | return outBitmap; 1006 | } 1007 | 1008 | private static final int COLOR_MIN = 0x00; 1009 | private static final int COLOR_MAX = 0xFF; 1010 | 1011 | /** 1012 | * Imagen con efecto granulado 1013 | * 1014 | * @param source 1015 | * @return 1016 | */ 1017 | public static Bitmap applyFleaEffect(Bitmap source) { 1018 | // get image size 1019 | int width = source.getWidth(); 1020 | int height = source.getHeight(); 1021 | int[] pixels = new int[width * height]; 1022 | // get pixel array from source 1023 | source.getPixels(pixels, 0, width, 0, 0, width, height); 1024 | // a random object 1025 | Random random = new Random(); 1026 | 1027 | int index = 0; 1028 | // iteration through pixels 1029 | for (int y = 0; y < height; ++y) { 1030 | for (int x = 0; x < width; ++x) { 1031 | // get current index in 2D-matrix 1032 | index = y * width + x; 1033 | // get random color 1034 | int randColor = Color.rgb(random.nextInt(COLOR_MAX), 1035 | random.nextInt(COLOR_MAX), random.nextInt(COLOR_MAX)); 1036 | // OR 1037 | pixels[index] |= randColor; 1038 | } 1039 | } 1040 | // output bitmap 1041 | Bitmap bmOut = Bitmap.createBitmap(width, height, source.getConfig()); 1042 | bmOut.setPixels(pixels, 0, width, 0, 0, width, height); 1043 | return bmOut; 1044 | } 1045 | 1046 | /** 1047 | * Imagen con efecto granulado negro 1048 | * 1049 | * @param source 1050 | * @return 1051 | */ 1052 | public static Bitmap applyBlackFilter(Bitmap source) { 1053 | // get image size 1054 | int width = source.getWidth(); 1055 | int height = source.getHeight(); 1056 | int[] pixels = new int[width * height]; 1057 | // get pixel array from source 1058 | source.getPixels(pixels, 0, width, 0, 0, width, height); 1059 | // random object 1060 | Random random = new Random(); 1061 | 1062 | int R, G, B, index = 0, thresHold = 0; 1063 | // iteration through pixels 1064 | for (int y = 0; y < height; ++y) { 1065 | for (int x = 0; x < width; ++x) { 1066 | // get current index in 2D-matrix 1067 | index = y * width + x; 1068 | // get color 1069 | R = Color.red(pixels[index]); 1070 | G = Color.green(pixels[index]); 1071 | B = Color.blue(pixels[index]); 1072 | // generate threshold 1073 | thresHold = random.nextInt(COLOR_MAX); 1074 | if (R < thresHold && G < thresHold && B < thresHold) { 1075 | pixels[index] = Color.rgb(COLOR_MIN, COLOR_MIN, COLOR_MIN); 1076 | } 1077 | } 1078 | } 1079 | // output bitmap 1080 | Bitmap bmOut = Bitmap.createBitmap(width, height, 1081 | Bitmap.Config.ARGB_8888); 1082 | bmOut.setPixels(pixels, 0, width, 0, 0, width, height); 1083 | return bmOut; 1084 | } 1085 | 1086 | /** 1087 | * Imagen con efecto nieve 1088 | * 1089 | * @param source 1090 | * @return 1091 | */ 1092 | public static Bitmap applySnowEffect(Bitmap source) { 1093 | // get image size 1094 | int width = source.getWidth(); 1095 | int height = source.getHeight(); 1096 | int[] pixels = new int[width * height]; 1097 | // get pixel array from source 1098 | source.getPixels(pixels, 0, width, 0, 0, width, height); 1099 | // random object 1100 | Random random = new Random(); 1101 | 1102 | int R, G, B, index = 0, thresHold = 50; 1103 | // iteration through pixels 1104 | for (int y = 0; y < height; ++y) { 1105 | for (int x = 0; x < width; ++x) { 1106 | // get current index in 2D-matrix 1107 | index = y * width + x; 1108 | // get color 1109 | R = Color.red(pixels[index]); 1110 | G = Color.green(pixels[index]); 1111 | B = Color.blue(pixels[index]); 1112 | // generate threshold 1113 | thresHold = random.nextInt(COLOR_MAX); 1114 | if (R > thresHold && G > thresHold && B > thresHold) { 1115 | pixels[index] = Color.rgb(COLOR_MAX, COLOR_MAX, COLOR_MAX); 1116 | } 1117 | } 1118 | } 1119 | // output bitmap 1120 | Bitmap bmOut = Bitmap 1121 | .createBitmap(width, height, Bitmap.Config.RGB_565); 1122 | bmOut.setPixels(pixels, 0, width, 0, 0, width, height); 1123 | return bmOut; 1124 | } 1125 | 1126 | /** 1127 | * Imagen con sombreado del color especificado 1128 | * 1129 | * @param source 1130 | * @param shadingColor 1131 | * @return 1132 | */ 1133 | public static Bitmap applyShadingFilter(Bitmap source, int shadingColor) { 1134 | // get image size 1135 | int width = source.getWidth(); 1136 | int height = source.getHeight(); 1137 | int[] pixels = new int[width * height]; 1138 | // get pixel array from source 1139 | source.getPixels(pixels, 0, width, 0, 0, width, height); 1140 | 1141 | int index = 0; 1142 | // iteration through pixels 1143 | for (int y = 0; y < height; ++y) { 1144 | for (int x = 0; x < width; ++x) { 1145 | // get current index in 2D-matrix 1146 | index = y * width + x; 1147 | // AND 1148 | pixels[index] &= shadingColor; 1149 | } 1150 | } 1151 | // output bitmap 1152 | Bitmap bmOut = Bitmap.createBitmap(width, height, 1153 | Bitmap.Config.ARGB_8888); 1154 | bmOut.setPixels(pixels, 0, width, 0, 0, width, height); 1155 | return bmOut; 1156 | } 1157 | 1158 | /** 1159 | * Imagen con un filtro de saturacion 1160 | * 1161 | * @param source 1162 | * @param level 1163 | * (3,9...) 1164 | * @return 1165 | */ 1166 | public static Bitmap applySaturationFilter(Bitmap source, int level) { 1167 | // get image size 1168 | int width = source.getWidth(); 1169 | int height = source.getHeight(); 1170 | int[] pixels = new int[width * height]; 1171 | float[] HSV = new float[3]; 1172 | // get pixel array from source 1173 | source.getPixels(pixels, 0, width, 0, 0, width, height); 1174 | 1175 | int index = 0; 1176 | // iteration through pixels 1177 | for (int y = 0; y < height; ++y) { 1178 | for (int x = 0; x < width; ++x) { 1179 | // get current index in 2D-matrix 1180 | index = y * width + x; 1181 | // convert to HSV 1182 | Color.colorToHSV(pixels[index], HSV); 1183 | // increase Saturation level 1184 | HSV[1] *= level; 1185 | HSV[1] = (float) Math.max(0.0, Math.min(HSV[1], 1.0)); 1186 | // take color back 1187 | pixels[index] |= Color.HSVToColor(HSV); 1188 | } 1189 | } 1190 | // output bitmap 1191 | Bitmap bmOut = Bitmap.createBitmap(width, height, 1192 | Bitmap.Config.ARGB_8888); 1193 | bmOut.setPixels(pixels, 0, width, 0, 0, width, height); 1194 | return bmOut; 1195 | } 1196 | 1197 | /** 1198 | * Imagen con un filtro de saturacion mas pronunciado 1199 | * 1200 | * @param source 1201 | * @param level 1202 | * (3,9...) 1203 | * @return 1204 | */ 1205 | public static Bitmap applyHueFilter(Bitmap source, int level) { 1206 | // get image size 1207 | int width = source.getWidth(); 1208 | int height = source.getHeight(); 1209 | int[] pixels = new int[width * height]; 1210 | float[] HSV = new float[3]; 1211 | // get pixel array from source 1212 | source.getPixels(pixels, 0, width, 0, 0, width, height); 1213 | 1214 | int index = 0; 1215 | // iteration through pixels 1216 | for (int y = 0; y < height; ++y) { 1217 | for (int x = 0; x < width; ++x) { 1218 | // get current index in 2D-matrix 1219 | index = y * width + x; 1220 | // convert to HSV 1221 | Color.colorToHSV(pixels[index], HSV); 1222 | // increase Saturation level 1223 | HSV[0] *= level; 1224 | HSV[0] = (float) Math.max(0.0, Math.min(HSV[0], 360.0)); 1225 | // take color back 1226 | pixels[index] |= Color.HSVToColor(HSV); 1227 | } 1228 | } 1229 | // output bitmap 1230 | Bitmap bmOut = Bitmap.createBitmap(width, height, 1231 | Bitmap.Config.ARGB_8888); 1232 | bmOut.setPixels(pixels, 0, width, 0, 0, width, height); 1233 | return bmOut; 1234 | } 1235 | 1236 | /** 1237 | * Imagen con reflejo 1238 | * 1239 | * @param originalImage 1240 | * @return 1241 | */ 1242 | public static Bitmap applyReflection(Bitmap originalImage) { 1243 | // gap space between original and reflected 1244 | final int reflectionGap = 4; 1245 | // get image size 1246 | int width = originalImage.getWidth(); 1247 | int height = originalImage.getHeight(); 1248 | 1249 | // this will not scale but will flip on the Y axis 1250 | Matrix matrix = new Matrix(); 1251 | matrix.preScale(1, -1); 1252 | 1253 | // create a Bitmap with the flip matrix applied to it. 1254 | // we only want the bottom half of the image 1255 | Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0, 1256 | height / 2, width, height / 2, matrix, false); 1257 | 1258 | // create a new bitmap with same width but taller to fit reflection 1259 | Bitmap bitmapWithReflection = Bitmap.createBitmap(width, 1260 | (height + height / 2), Config.ARGB_8888); 1261 | 1262 | // create a new Canvas with the bitmap that's big enough for 1263 | // the image plus gap plus reflection 1264 | Canvas canvas = new Canvas(bitmapWithReflection); 1265 | // draw in the original image 1266 | canvas.drawBitmap(originalImage, 0, 0, null); 1267 | // draw in the gap 1268 | Paint defaultPaint = new Paint(); 1269 | canvas.drawRect(0, height, width, height + reflectionGap, defaultPaint); 1270 | // draw in the reflection 1271 | canvas.drawBitmap(reflectionImage, 0, height + reflectionGap, null); 1272 | 1273 | // create a shader that is a linear gradient that covers the reflection 1274 | Paint paint = new Paint(); 1275 | LinearGradient shader = new LinearGradient(0, 1276 | originalImage.getHeight(), 0, bitmapWithReflection.getHeight() 1277 | + reflectionGap, 0x70ffffff, 0x00ffffff, TileMode.CLAMP); 1278 | // set the paint to use this shader (linear gradient) 1279 | paint.setShader(shader); 1280 | // set the Transfer mode to be porter duff and destination in 1281 | paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN)); 1282 | // draw a rectangle using the paint with our linear gradient 1283 | canvas.drawRect(0, height, width, bitmapWithReflection.getHeight() 1284 | + reflectionGap, paint); 1285 | 1286 | return bitmapWithReflection; 1287 | } 1288 | 1289 | /** 1290 | * Le aplica una mascara a un bitmap para hacer transparente todo lo que no 1291 | * sea negro 1292 | * 1293 | * @param bitmap 1294 | * Bitmap al que aplicar la mascara 1295 | * @return bitmap con la mascara aplicada 1296 | */ 1297 | public static Bitmap applyTransparency(Bitmap bitmap) { 1298 | 1299 | int width = bitmap.getWidth(); 1300 | int height = bitmap.getHeight(); 1301 | 1302 | Bitmap result = Bitmap.createBitmap(width, height, Config.ARGB_8888); 1303 | result.eraseColor(Color.BLACK); 1304 | 1305 | Canvas c = new Canvas(result); 1306 | 1307 | Bitmap alpha = Bitmap.createBitmap(width, height, Config.ARGB_8888); 1308 | int[] alphaPix = new int[width * height]; 1309 | bitmap.getPixels(alphaPix, 0, width, 0, 0, width, height); 1310 | 1311 | int count = width * height; 1312 | for (int i = 0; i < count; ++i) { 1313 | // Usamos el canal rojo como alpha 1314 | alphaPix[i] = alphaPix[i] << 8; // Realizamos desplazamiento a la 1315 | // izquierda con signo 1316 | } 1317 | 1318 | alpha.setPixels(alphaPix, 0, width, 0, 0, width, height); 1319 | 1320 | Paint alphaP = new Paint(); 1321 | alphaP.setAntiAlias(true); 1322 | alphaP.setXfermode(new PorterDuffXfermode(Mode.DST_OUT)); 1323 | 1324 | c.drawBitmap(alpha, 0, 0, alphaP); 1325 | 1326 | bitmap.recycle(); 1327 | alpha.recycle(); 1328 | 1329 | return result; 1330 | 1331 | } 1332 | 1333 | } 1334 | -------------------------------------------------------------------------------- /ImageProcessingLib/src/com/jcmore2/imageprocessing/filesystem/ImageFilesystemManager.java: -------------------------------------------------------------------------------- 1 | package com.jcmore2.imageprocessing.filesystem; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.FileOutputStream; 6 | import java.io.OutputStream; 7 | import java.util.Date; 8 | 9 | import android.app.Activity; 10 | import android.support.v4.app.Fragment; 11 | import android.content.ContentResolver; 12 | import android.content.ContentValues; 13 | import android.content.Context; 14 | import android.content.Intent; 15 | import android.database.Cursor; 16 | import android.graphics.Bitmap; 17 | import android.graphics.BitmapFactory; 18 | import android.net.Uri; 19 | import android.os.Environment; 20 | import android.provider.MediaStore; 21 | import android.provider.MediaStore.Images; 22 | import android.util.Log; 23 | 24 | import com.jcmore2.imageprocessing.utils.Utils; 25 | 26 | /** 27 | * This class manage filesystem to save to SD, pick from gallery and save in gallery. 28 | * @author jcmore2 jcmore2@gmail.com 29 | * 30 | */ 31 | public class ImageFilesystemManager { 32 | 33 | private static int RESULT_LOAD_IMAGE = 1; 34 | 35 | public static void pickImageFromGallery(Activity activity) { 36 | Intent i = new Intent(Intent.ACTION_PICK, 37 | android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); 38 | 39 | activity.startActivityForResult(i, RESULT_LOAD_IMAGE); 40 | 41 | } 42 | 43 | public static void pickImageFromGallery(Fragment fragment) { 44 | Intent i = new Intent(Intent.ACTION_PICK, 45 | android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); 46 | 47 | fragment.startActivityForResult(i, RESULT_LOAD_IMAGE); 48 | 49 | } 50 | 51 | public static Bitmap onPickImageResult(Activity activity, int requestCode, 52 | int resultCode, Intent data) { 53 | 54 | Bitmap bitmap = null; 55 | if (requestCode == RESULT_LOAD_IMAGE 56 | && resultCode == Activity.RESULT_OK && null != data) { 57 | Uri selectedImage = data.getData(); 58 | String[] filePathColumn = { MediaStore.Images.Media.DATA }; 59 | 60 | Cursor cursor = activity.getContentResolver().query(selectedImage, 61 | filePathColumn, null, null, null); 62 | cursor.moveToFirst(); 63 | 64 | int columnIndex = cursor.getColumnIndex(filePathColumn[0]); 65 | String picturePath = cursor.getString(columnIndex); 66 | cursor.close(); 67 | 68 | bitmap = BitmapFactory.decodeFile(picturePath); 69 | 70 | } 71 | return bitmap; 72 | } 73 | 74 | private final static String APP_PATH_SD_CARD = "/App_foo/"; 75 | private final static String APP_THUMBNAIL_PATH_SD_CARD = "foo"; 76 | 77 | public static File saveImageToExternalStorage(Context context, 78 | Bitmap image, String parentPath, String childPath, String filename) { 79 | 80 | String fullPath = ""; 81 | if (parentPath != null && !parentPath.equalsIgnoreCase("") 82 | && childPath != null && !childPath.equalsIgnoreCase("")) { 83 | fullPath = Environment.getExternalStorageDirectory() 84 | .getAbsolutePath() + "/" + parentPath + "/" + childPath; 85 | } else { 86 | fullPath = Environment.getExternalStorageDirectory() 87 | .getAbsolutePath() 88 | + APP_PATH_SD_CARD 89 | + APP_THUMBNAIL_PATH_SD_CARD; 90 | } 91 | 92 | try { 93 | File dir = new File(fullPath); 94 | if (!dir.exists()) { 95 | dir.mkdirs(); 96 | } 97 | 98 | if (filename == null || filename.equalsIgnoreCase("")) 99 | filename = "imagen" + new Date().getTime(); 100 | 101 | OutputStream fOut = null; 102 | File file = new File(fullPath, filename + ".jpg"); 103 | file.createNewFile(); 104 | fOut = new FileOutputStream(file); 105 | 106 | // 100 means no compression, the lower you go, the stronger the 107 | // compression 108 | image.compress(Bitmap.CompressFormat.JPEG, 90, fOut); 109 | fOut.flush(); 110 | fOut.close(); 111 | 112 | saveMediaEntry(context, file.getAbsolutePath());; 113 | 114 | return file; 115 | 116 | } catch (Exception e) { 117 | Log.e("saveToExternalStorage()", e.getMessage()); 118 | return null; 119 | } 120 | } 121 | 122 | public static boolean saveImageToInternalStorage(Context context, 123 | Bitmap image, String filename) { 124 | 125 | if (filename == null || filename.equalsIgnoreCase("")) 126 | filename = "imagen" + new Date().getTime(); 127 | try { 128 | // Use the compress method on the Bitmap object to write image to 129 | // the OutputStream 130 | FileOutputStream fos = context.openFileOutput(filename + ".jpg", 131 | Context.MODE_PRIVATE); 132 | 133 | // Writing the bitmap to the output stream 134 | image.compress(Bitmap.CompressFormat.JPEG, 90, fos); 135 | fos.close(); 136 | 137 | return true; 138 | } catch (Exception e) { 139 | Log.e("saveToInternalStorage()", e.getMessage()); 140 | return false; 141 | } 142 | } 143 | 144 | public static Bitmap getImageFromExternalStorage(Context context, String parentPath, 145 | String childPath, String filename) { 146 | 147 | String fullPath = ""; 148 | if (parentPath != null && !parentPath.equalsIgnoreCase("") 149 | && childPath != null && !childPath.equalsIgnoreCase("")) { 150 | fullPath = Environment.getExternalStorageDirectory() 151 | .getAbsolutePath() + "/" + parentPath + "/" + childPath; 152 | } else { 153 | fullPath = Environment.getExternalStorageDirectory() 154 | .getAbsolutePath() 155 | + APP_PATH_SD_CARD 156 | + APP_THUMBNAIL_PATH_SD_CARD; 157 | } 158 | Bitmap thumbnail = null; 159 | 160 | // Look for the file on the external storage 161 | try { 162 | if (Utils.isSdReadable() == true) { 163 | thumbnail = BitmapFactory.decodeFile(fullPath + "/" + filename); 164 | } 165 | } catch (Exception e) { 166 | Log.e("getThumbnail() on external storage", e.getMessage()); 167 | } 168 | 169 | // If no file on external storage, look in internal storage 170 | if (thumbnail == null) { 171 | try { 172 | File filePath = context.getFileStreamPath(filename); 173 | FileInputStream fi = new FileInputStream(filePath); 174 | thumbnail = BitmapFactory.decodeStream(fi); 175 | } catch (Exception ex) { 176 | Log.e("getThumbnail() on internal storage", ex.getMessage()); 177 | } 178 | } 179 | return thumbnail; 180 | } 181 | 182 | 183 | /** 184 | * Copia una imagen a la galeria de fotos 185 | * @param imagePath Ruta a la imagen 186 | * @return la url creada 187 | */ 188 | public static Uri saveMediaEntry(Context context, String imagePath) { 189 | 190 | File imageFile = new File(imagePath); 191 | 192 | ContentValues v = new ContentValues(); 193 | v.put(Images.Media.TITLE, imageFile.getName()); 194 | v.put(Images.Media.DISPLAY_NAME, imageFile.getName()); 195 | v.put(Images.Media.MIME_TYPE, "image/jpeg"); 196 | 197 | 198 | File f = new File(imagePath) ; 199 | File parent = f.getParentFile() ; 200 | String path = parent.toString().toLowerCase() ; 201 | String name = parent.getName().toLowerCase() ; 202 | v.put(Images.ImageColumns.BUCKET_ID, path.hashCode()); 203 | v.put(Images.ImageColumns.BUCKET_DISPLAY_NAME, name); 204 | v.put(Images.Media.SIZE,f.length()) ; 205 | f = null ; 206 | 207 | v.put("_data",imagePath) ; 208 | ContentResolver c = context.getContentResolver() ; 209 | Uri uri= null; 210 | try{ 211 | uri = c.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, v); 212 | }catch (Exception e) { 213 | // TODO: handle exception 214 | Log.e("Utils", "Error al guardar la foto " + e.getMessage()); 215 | } 216 | return uri; 217 | } 218 | 219 | 220 | 221 | 222 | public static Uri getFileContentUri(Context context, File imageFile) { 223 | String filePath = imageFile.getAbsolutePath(); 224 | Cursor cursor = context.getContentResolver().query( 225 | MediaStore.Video.Media.EXTERNAL_CONTENT_URI, 226 | new String[] { MediaStore.Video.Media._ID }, 227 | MediaStore.Video.Media.DATA + "=? ", 228 | new String[] { filePath }, null); 229 | 230 | if (cursor != null && cursor.moveToFirst()) { 231 | int id = cursor.getInt(cursor 232 | .getColumnIndex(MediaStore.MediaColumns._ID)); 233 | Uri baseUri = Uri.parse("content://media/external/video/media"); 234 | return Uri.withAppendedPath(baseUri, "" + id); 235 | } else { 236 | if (imageFile.exists()) { 237 | ContentValues values = new ContentValues(); 238 | values.put(MediaStore.Video.Media.DATA, filePath); 239 | return context.getContentResolver().insert( 240 | MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values); 241 | } else { 242 | return null; 243 | } 244 | } 245 | } 246 | 247 | public static boolean deleteFileContentUri(Context context, Uri uri) { 248 | 249 | if(context.getContentResolver().delete( 250 | uri, null,null)>0){ 251 | return true; 252 | }else{ 253 | return false; 254 | } 255 | 256 | } 257 | 258 | } 259 | -------------------------------------------------------------------------------- /ImageProcessingLib/src/com/jcmore2/imageprocessing/model/ImageProcessingModel.java: -------------------------------------------------------------------------------- 1 | package com.jcmore2.imageprocessing.model; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | /** 6 | * Image Processing Model 7 | * @author jcmore2 jcmore2@gmail.com 8 | * 9 | */ 10 | public class ImageProcessingModel { 11 | 12 | public int process; 13 | public String processName; 14 | public Bitmap processedBitmap; 15 | 16 | public ImageProcessingModel(int process, String processName, Bitmap processedBitmap){ 17 | this.process = process; 18 | this.processName = processName; 19 | this.processedBitmap = processedBitmap; 20 | } 21 | 22 | public ImageProcessingModel(){ 23 | 24 | } 25 | 26 | public int getProcess() { 27 | return process; 28 | } 29 | public void setProcess(int process) { 30 | this.process = process; 31 | } 32 | public String getProcessName() { 33 | return processName; 34 | } 35 | public void setProcessName(String processName) { 36 | this.processName = processName; 37 | } 38 | public Bitmap getProcessedBitmap() { 39 | return processedBitmap; 40 | } 41 | public void setProcessedBitmap(Bitmap processedBitmap) { 42 | this.processedBitmap = processedBitmap; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /ImageProcessingLib/src/com/jcmore2/imageprocessing/utils/Utils.java: -------------------------------------------------------------------------------- 1 | package com.jcmore2.imageprocessing.utils; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | 5 | import android.content.Context; 6 | import android.content.res.Resources; 7 | import android.graphics.Bitmap; 8 | import android.graphics.Bitmap.CompressFormat; 9 | import android.graphics.BitmapFactory; 10 | import android.graphics.drawable.BitmapDrawable; 11 | import android.graphics.drawable.Drawable; 12 | import android.os.Environment; 13 | import android.util.Log; 14 | import android.view.Display; 15 | import android.view.WindowManager; 16 | 17 | /** 18 | * Utils 19 | * @author jcmore2 jcmore2@gmail.com 20 | * 21 | */ 22 | public class Utils { 23 | public static byte[] getBytes(Bitmap bitmap) { 24 | ByteArrayOutputStream stream = new ByteArrayOutputStream(); 25 | bitmap.compress(CompressFormat.PNG, 0, stream); 26 | return stream.toByteArray(); 27 | } 28 | 29 | public static Bitmap getImage(byte[] image) { 30 | return BitmapFactory.decodeByteArray(image, 0, image.length); 31 | } 32 | 33 | public static boolean isSdReadable() { 34 | 35 | boolean mExternalStorageAvailable = false; 36 | String state = Environment.getExternalStorageState(); 37 | 38 | if (Environment.MEDIA_MOUNTED.equals(state)) { 39 | // We can read and write the media 40 | mExternalStorageAvailable = true; 41 | Log.i("isSdReadable", "External storage card is readable."); 42 | } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { 43 | // We can only read the media 44 | Log.i("isSdReadable", "External storage card is readable."); 45 | mExternalStorageAvailable = true; 46 | } else { 47 | // Something else is wrong. It may be one of many other 48 | // states, but all we need to know is we can neither read nor write 49 | mExternalStorageAvailable = false; 50 | } 51 | 52 | return mExternalStorageAvailable; 53 | } 54 | 55 | public static Bitmap getBitmapFromDrawable(Drawable d) { 56 | 57 | Bitmap bitmap = ((BitmapDrawable) d).getBitmap(); 58 | 59 | return bitmap; 60 | } 61 | 62 | public static Drawable getDrawableFromBitmap(Context context, Bitmap bm) { 63 | 64 | Drawable d = new BitmapDrawable(context.getResources(), bm); 65 | 66 | return d; 67 | 68 | } 69 | 70 | 71 | 72 | public static int getAltoPantalla(Context context) { 73 | 74 | WindowManager wm = (WindowManager) context 75 | .getSystemService(Context.WINDOW_SERVICE); 76 | Display display = wm.getDefaultDisplay(); 77 | return display.getHeight(); 78 | 79 | } 80 | 81 | public static int getAnchoPantalla(Context context) { 82 | 83 | WindowManager wm = (WindowManager) context 84 | .getSystemService(Context.WINDOW_SERVICE); 85 | Display display = wm.getDefaultDisplay(); 86 | return display.getWidth(); 87 | 88 | } 89 | 90 | private static int calculateInSampleSize(BitmapFactory.Options options, 91 | int reqWidth, int reqHeight) { 92 | // Raw height and width of image 93 | final int height = options.outHeight; 94 | final int width = options.outWidth; 95 | int inSampleSize = 1; 96 | 97 | if (height > reqHeight || width > reqWidth) { 98 | if (width > height) { 99 | inSampleSize = Math.round((float) height / (float) reqHeight); 100 | } else { 101 | inSampleSize = Math.round((float) width / (float) reqWidth); 102 | } 103 | } 104 | return inSampleSize; 105 | } 106 | 107 | public static Bitmap decodeSampledBitmapFromResource(Resources res, 108 | int resId, int reqWidth, int reqHeight) { 109 | 110 | // First decode with inJustDecodeBounds=true to check dimensions 111 | final BitmapFactory.Options options = new BitmapFactory.Options(); 112 | options.inJustDecodeBounds = true; 113 | BitmapFactory.decodeResource(res, resId, options); 114 | 115 | // Calculate inSampleSize 116 | options.inSampleSize = calculateInSampleSize(options, reqWidth, 117 | reqHeight); 118 | 119 | // Decode bitmap with inSampleSize set 120 | options.inJustDecodeBounds = false; 121 | return BitmapFactory.decodeResource(res, resId, options); 122 | } 123 | 124 | public static Bitmap decodeSampledBitmapFromFile(String filePath, int reqWidth, int reqHeight) { 125 | 126 | // First decode with inJustDecodeBounds=true to check dimensions 127 | final BitmapFactory.Options options = new BitmapFactory.Options(); 128 | options.inJustDecodeBounds = true; 129 | BitmapFactory.decodeFile(filePath, options); 130 | 131 | // Calculate inSampleSize 132 | options.inSampleSize = calculateInSampleSize(options, reqWidth, 133 | reqHeight); 134 | 135 | // Decode bitmap with inSampleSize set 136 | options.inJustDecodeBounds = false; 137 | return BitmapFactory.decodeFile(filePath, options); 138 | } 139 | 140 | } 141 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ImageProcessingLib 2 | ================== 3 | 4 | Android Image Processing Library 5 | 6 | This library apply filters to images and can pick an image from gallery and save it. 7 | 8 | ![Screenshot](https://github.com/jcmore2/ImageProcessingLib/raw/master/raw/demo_image.png) 9 | 10 | 11 | Contains 12 | ================== 13 | 14 | * ImageProcessingLib: Library 15 | * TestImageProcessingLib: Demo tu use the library 16 | 17 | 18 | Licence 19 | ------- 20 | Copyright 2013 Juan Carlos Moreno (jcmore2) 21 | 22 | Licensed under the Apache License, Version 2.0 (the "License"); 23 | you may not use this file except in compliance with the License. 24 | You may obtain a copy of the License at 25 | 26 | http://www.apache.org/licenses/LICENSE-2.0 27 | 28 | Unless required by applicable law or agreed to in writing, software 29 | distributed under the License is distributed on an "AS IS" BASIS, 30 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 31 | See the License for the specific language governing permissions and 32 | limitations under the License. -------------------------------------------------------------------------------- /TestImageProcessingLib/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /TestImageProcessingLib/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | TestImageProcessingLib 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /TestImageProcessingLib/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /TestImageProcessingLib/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/R.txt: -------------------------------------------------------------------------------- 1 | int dimen activity_horizontal_margin 0x7f060000 2 | int dimen activity_vertical_margin 0x7f060001 3 | int drawable ic_launcher 0x7f020000 4 | int drawable icon 0x7f020001 5 | int drawable imagen 0x7f020002 6 | int id action_settings 0x7f08000c 7 | int id botonera 0x7f080001 8 | int id file 0x7f080004 9 | int id first_view 0x7f080008 10 | int id image_effect 0x7f08000a 11 | int id imagen 0x7f080005 12 | int id layoutDibujosFull 0x7f080006 13 | int id listaDibujosFull 0x7f080007 14 | int id name_effect 0x7f08000b 15 | int id normal 0x7f080003 16 | int id parent 0x7f080000 17 | int id progBar 0x7f080009 18 | int id save 0x7f080002 19 | int layout activity_test 0x7f030000 20 | int layout effect_view 0x7f030001 21 | int menu test 0x7f070000 22 | int string action_settings 0x7f040001 23 | int string app_name 0x7f040000 24 | int string hello_world 0x7f040002 25 | int style AppBaseTheme 0x7f050000 26 | int style AppTheme 0x7f050001 27 | -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/TestImageProcessingLibrary.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/TestImageProcessingLibrary.apk -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes.dex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes.dex -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R$drawable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R$drawable.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R$string.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R$string.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R$style.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R$style.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/imageprocessinglibrary/R.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/BuildConfig.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/BuildConfig.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/HorizontalListView$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/HorizontalListView$1.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/HorizontalListView$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/HorizontalListView$2.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/HorizontalListView$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/HorizontalListView$3.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/HorizontalListView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/HorizontalListView.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/ListEffectAdapter$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/ListEffectAdapter$1.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/ListEffectAdapter$ViewHolder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/ListEffectAdapter$ViewHolder.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/ListEffectAdapter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/ListEffectAdapter.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/ProcessingAsyncTask$ProcessingListener.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/ProcessingAsyncTask$ProcessingListener.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/ProcessingAsyncTask.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/ProcessingAsyncTask.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R$attr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R$attr.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R$dimen.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R$dimen.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R$drawable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R$drawable.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R$id.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R$id.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R$layout.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R$layout.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R$menu.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R$menu.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R$string.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R$string.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R$style.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R$style.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/R.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/TestActivity$1$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/TestActivity$1$1.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/TestActivity$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/TestActivity$1.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/TestActivity$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/TestActivity$2.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/TestActivity$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/TestActivity$3.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/TestActivity$4.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/TestActivity$4.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/TestActivity.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/classes/com/jcmore2/testimageprocessinglibrary/TestActivity.class -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/dexedLibs/android-support-v4-15157426f1975f099af003680737fd21.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/dexedLibs/android-support-v4-15157426f1975f099af003680737fd21.jar -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/dexedLibs/imageprocessinglibrary-de120e7c8cc49977742f0d0a79651b29.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/dexedLibs/imageprocessinglibrary-de120e7c8cc49977742f0d0a79651b29.jar -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/jarlist.cache: -------------------------------------------------------------------------------- 1 | # cache for current jar dependecy. DO NOT EDIT. 2 | # format is 3 | # Encoding is UTF-8 4 | -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /TestImageProcessingLib/bin/resources.ap_: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/bin/resources.ap_ -------------------------------------------------------------------------------- /TestImageProcessingLib/gen/com/jcmore2/imageprocessinglibrary/R.java: -------------------------------------------------------------------------------- 1 | /* AUTO-GENERATED FILE. DO NOT MODIFY. 2 | * 3 | * This class was automatically generated by the 4 | * aapt tool from the resource data it found. It 5 | * should not be modified by hand. 6 | */ 7 | package com.jcmore2.imageprocessinglibrary; 8 | 9 | public final class R { 10 | public static final class style { 11 | public static final int AppBaseTheme = 0x7f050000; 12 | public static final int AppTheme = 0x7f050001; 13 | } 14 | public static final class string { 15 | public static final int app_name = 0x7f040000; 16 | } 17 | public static final class drawable { 18 | public static final int ic_launcher = 0x7f020000; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /TestImageProcessingLib/gen/com/jcmore2/testimageprocessinglibrary/BuildConfig.java: -------------------------------------------------------------------------------- 1 | /** Automatically generated file. DO NOT MODIFY */ 2 | package com.jcmore2.testimageprocessinglibrary; 3 | 4 | public final class BuildConfig { 5 | public final static boolean DEBUG = true; 6 | } -------------------------------------------------------------------------------- /TestImageProcessingLib/gen/com/jcmore2/testimageprocessinglibrary/R.java: -------------------------------------------------------------------------------- 1 | /* AUTO-GENERATED FILE. DO NOT MODIFY. 2 | * 3 | * This class was automatically generated by the 4 | * aapt tool from the resource data it found. It 5 | * should not be modified by hand. 6 | */ 7 | 8 | package com.jcmore2.testimageprocessinglibrary; 9 | 10 | public final class R { 11 | public static final class attr { 12 | } 13 | public static final class dimen { 14 | /** Default screen margins, per the Android Design guidelines. 15 | 16 | Customize dimensions originally defined in res/values/dimens.xml (such as 17 | screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. 18 | 19 | */ 20 | public static final int activity_horizontal_margin=0x7f060000; 21 | public static final int activity_vertical_margin=0x7f060001; 22 | } 23 | public static final class drawable { 24 | public static final int ic_launcher=0x7f020000; 25 | public static final int icon=0x7f020001; 26 | public static final int imagen=0x7f020002; 27 | } 28 | public static final class id { 29 | public static final int action_settings=0x7f08000c; 30 | public static final int botonera=0x7f080001; 31 | public static final int file=0x7f080004; 32 | public static final int first_view=0x7f080008; 33 | public static final int image_effect=0x7f08000a; 34 | public static final int imagen=0x7f080005; 35 | public static final int layoutDibujosFull=0x7f080006; 36 | public static final int listaDibujosFull=0x7f080007; 37 | public static final int name_effect=0x7f08000b; 38 | public static final int normal=0x7f080003; 39 | public static final int parent=0x7f080000; 40 | public static final int progBar=0x7f080009; 41 | public static final int save=0x7f080002; 42 | } 43 | public static final class layout { 44 | public static final int activity_test=0x7f030000; 45 | public static final int effect_view=0x7f030001; 46 | } 47 | public static final class menu { 48 | public static final int test=0x7f070000; 49 | } 50 | public static final class string { 51 | public static final int action_settings=0x7f040001; 52 | public static final int app_name=0x7f040000; 53 | public static final int hello_world=0x7f040002; 54 | } 55 | public static final class style { 56 | /** 57 | Base application theme, dependent on API level. This theme is replaced 58 | by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 59 | 60 | 61 | Theme customizations available in newer API levels can go in 62 | res/values-vXX/styles.xml, while customizations related to 63 | backward-compatibility can go here. 64 | 65 | 66 | Base application theme for API 11+. This theme completely replaces 67 | AppBaseTheme from res/values/styles.xml on API 11+ devices. 68 | 69 | API 11 theme customizations can go here. 70 | 71 | Base application theme for API 14+. This theme completely replaces 72 | AppBaseTheme from BOTH res/values/styles.xml and 73 | res/values-v11/styles.xml on API 14+ devices. 74 | 75 | API 14 theme customizations can go here. 76 | 77 | Base application theme, dependent on API level. This theme is replaced 78 | by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 79 | 80 | 81 | Theme customizations available in newer API levels can go in 82 | res/values-vXX/styles.xml, while customizations related to 83 | backward-compatibility can go here. 84 | 85 | 86 | Base application theme for API 11+. This theme completely replaces 87 | AppBaseTheme from res/values/styles.xml on API 11+ devices. 88 | 89 | API 11 theme customizations can go here. 90 | 91 | Base application theme for API 14+. This theme completely replaces 92 | AppBaseTheme from BOTH res/values/styles.xml and 93 | res/values-v11/styles.xml on API 14+ devices. 94 | 95 | API 14 theme customizations can go here. 96 | */ 97 | public static final int AppBaseTheme=0x7f050000; 98 | /** Application theme. 99 | All customizations that are NOT specific to a particular API-level can go here. 100 | Application theme. 101 | All customizations that are NOT specific to a particular API-level can go here. 102 | */ 103 | public static final int AppTheme=0x7f050001; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /TestImageProcessingLib/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /TestImageProcessingLib/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-17 15 | android.library.reference.1=../ImageProcessingLib 16 | -------------------------------------------------------------------------------- /TestImageProcessingLib/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /TestImageProcessingLib/res/drawable-hdpi/icon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/res/drawable-hdpi/icon.jpeg -------------------------------------------------------------------------------- /TestImageProcessingLib/res/drawable-hdpi/imagen.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/res/drawable-hdpi/imagen.jpg -------------------------------------------------------------------------------- /TestImageProcessingLib/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /TestImageProcessingLib/res/drawable-mdpi/icon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/res/drawable-mdpi/icon.jpeg -------------------------------------------------------------------------------- /TestImageProcessingLib/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /TestImageProcessingLib/res/drawable-xhdpi/icon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcmore2/ImageProcessingLib/b46053e489e2a13f7e69cd5e92a8d3d3531717d9/TestImageProcessingLib/res/drawable-xhdpi/icon.jpeg -------------------------------------------------------------------------------- /TestImageProcessingLib/res/layout/activity_test.xml: -------------------------------------------------------------------------------- 1 | 12 | 13 | 16 | 17 | 20 | 21 | 26 | 27 |