List of utility methods to do Bitmap Color Change
Bitmap | adjustedContrast(Bitmap src, double value) Adjust contrast of bitmap. int width = src.getWidth(); int height = src.getHeight(); Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig()); Canvas c = new Canvas(); c.setBitmap(bmOut); c.drawBitmap(src, 0, 0, new Paint(Color.BLACK)); int A, R, G, B; int pixel; ... |
Bitmap | boost(Bitmap src) Boost color intensity. int width = src.getWidth(); int height = src.getHeight(); final float factor = 1.3f; Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig()); int[] pix = new int[width * height]; src.getPixels(pix, 0, width, 0, 0, width, height); int A, R, G, B; int i = 0; ... |
Bitmap | brightness(Bitmap src, int value) Brightness. int width = src.getWidth(); int height = src.getHeight(); Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig()); int A, R, G, B; int pixel; for (int x = 0; x < width; ++x) { for (int y = 0; y < height; ++y) { pixel = src.getPixel(x, y); ... |
Bitmap | changeHue(Bitmap bmp, int hue, int width, int height) Change hue of bitmap. if (bmp == null) { return null; Bitmap bitmap = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight()); if ((hue < 0) || (hue > 360)) { return null; int size = width * height; int[] all_pixels = new int[size]; int top = 0; int left = 0; int offset = 0; int stride = width; bitmap.getPixels(all_pixels, offset, stride, top, left, width, height); int pixel = 0; int alpha = 0; float[] hsv = new float[3]; for (int i = 0; i < size; i++) { pixel = all_pixels[i]; alpha = Color.alpha(pixel); Color.colorToHSV(pixel, hsv); hsv[0] = hue; hsv[1] = 0.2f; all_pixels[i] = Color.HSVToColor(alpha, hsv); bitmap.setPixels(all_pixels, offset, stride, top, left, width, height); return bitmap; |
Bitmap | createAnaglyphBitmap(Bitmap bitmap) create Anaglyph Bitmap int width = bitmap.getWidth(); int height = bitmap.getHeight(); float scaleWidth = 2f; float scaleHeight = 1f; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); Bitmap leftBitmap = Bitmap.createBitmap(bitmap, 0, 0, width / 2, height, matrix, true); ... |
Bitmap | createSaturatedBitmap(final Bitmap bitmap) Used to remove the saturation (if saturate) and slightly enlarge a Bitmap . if (bitmap == null) { return null; final Bitmap mBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.RGB_565); final Canvas mCanvas = new Canvas(mBitmap); final Paint mPaint = new Paint(); final ColorMatrix mColorMatrix = new ColorMatrix(); ... |
void | dilate(Bitmap bitmap, int[][] se) dilate dilate(bitmap.copy(bitmap.getConfig(), false), bitmap, se); |
int | dilate(Bitmap source, Bitmap target, int[][] se) dilate int hlen = source.getWidth(), vlen = source.getHeight(), offsetX = (int) -Math .floor(se[0].length / 2), offsetY = (int) -Math .floor(se.length / 2); int toReturn = 0; for (int i = 0; i < vlen; i++) { for (int j = 0; j < hlen; j++) { if ((source.getPixel(j, i) & 0xff) > 0) { kernelDilate(j, i, hlen, vlen, target, se, offsetX, ... |
Bitmap | doBrightness(Bitmap src, int value) Adjust brightness of bitmap. int width = src.getWidth(); int height = src.getHeight(); Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig()); int A, R, G, B; int pixel; for (int x = 0; x < width; ++x) { for (int y = 0; y < height; ++y) { pixel = src.getPixel(x, y); ... |
void | erosion(Bitmap bitmap, int[][] se) erosion int hlen = bitmap.getWidth(), vlen = bitmap.getHeight(); for (int i = 0; i < vlen; i++) { for (int j = 0; j < hlen; j++) { bitmap.setPixel( j, i, kernelMatch(j, i, hlen, vlen, bitmap, se) ? 0xffffffff : 0xff000000); ... |