Android examples for Graphics:Color
replace Interval Color
//package com.java2s; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class Main { public static Bitmap repleceIntervalColor(Bitmap bitmap, int replaceThisColor, int colorNew) { if (bitmap != null) { int picw = bitmap.getWidth(); int pich = bitmap.getHeight(); int[] pix = new int[picw * pich]; bitmap.getPixels(pix, 0, picw, 0, 0, picw, pich); for (int y = 0; y < pich; y++) { for (int x = 0; x < picw; x++) { int index = y * picw + x; if (pix[index] == replaceThisColor) { pix[index] = colorNew; }// ww w . ja v a 2 s. co m } } Bitmap bm = Bitmap.createBitmap(pix, picw, pich, Bitmap.Config.ARGB_8888); return bm; } return null; } public static Bitmap repleceIntervalColor(int id,int oldColor, int colorNew, Context mContext) { return repleceIntervalColor( BitmapFactory.decodeResource(mContext.getResources(), id), oldColor, colorNew); } }