I'm currently trying to add a color picker to my application which downloads a zip file of images, extracts them and installs them to the user's SystemUI.
I've looked for quite a while to try and find a way to change colors within these icons, but so far I haven't been able to find anything that I could implement.
I'd like to be able to use something like a color mask where it would basically put the color over another color (but not transparent areas) or a color fill would do... I just need to be able to color in the active part of the image and not the inactive part.
Since I'm not allowed to post images yet, here's a direct link to help visualize what I'm trying to achieve.
http://i1135.photobucket.com/albums/m636/Mastur_Mynd/stack_img.png
UPDATE - After messing around a little and looking around some more I've found a bit to help I believe...
package com.masturmods.settings.util;
import net.margaritov.preference.colorpicker.ColorPickerPreference;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
public class Colorizer extends ColorPickerPreference {
public Colorizer(Context context) {
super(context);
}
public static void colorize(String pathName, int color) {
Bitmap dec = BitmapFactory.decodeFile(pathName);
Bitmap mIcon = dec.copy(Bitmap.Config.ARGB_8888, true);
Canvas c = new Canvas(mIcon);
Paint paint = new Paint(color);
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0);
ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
paint.setColorFilter(f);
c.drawBitmap(mIcon, 0, 0, paint);
mIcon.recycle();
}
}
Thanks to Herry the images pass through to the Canvas now, but they aren't changing at all. I've traced everything so far and the color is being saved by the preference and is being accessed by this code.