Android Bitmap Color Change boost(Bitmap src)

Here you can find the source of boost(Bitmap src)

Description

Boost color intensity.

Parameter

Parameter Description
src the src

Return

the bitmap

Declaration

public static Bitmap boost(Bitmap src) 

Method Source Code

//package com.java2s;

import android.graphics.Bitmap;

import android.graphics.Color;

public class Main {
    /**//from  w w  w  . j  a  v a  2  s . c o  m
     * Boost color intensity.
     * 
     * @param src
     *            the src
     * @return the bitmap
     * @author siddhesh
     */
    public static Bitmap boost(Bitmap src) {
        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;
        for (int pixel : pix) {
            A = Color.alpha(pixel);
            R = Color.red(pixel);
            G = Color.green(pixel);
            B = Color.blue(pixel);

            R = (int) (R * factor);
            if (R > 255)
                R = 255;

            G = (int) (G * factor);
            if (G > 255)
                G = 255;

            B = (int) (B * factor);
            if (B > 255)
                B = 255;

            pix[i] = Color.argb(A, R, G, B);
            i++;
        }

        bmOut.setPixels(pix, 0, width, 0, 0, width, height);
        // src.recycle();
        return bmOut;
    }
}

Related

  1. adjustedContrast(Bitmap src, double value)
  2. brightness(Bitmap src, int value)
  3. changeHue(Bitmap bmp, int hue, int width, int height)
  4. createAnaglyphBitmap(Bitmap bitmap)
  5. createSaturatedBitmap(final Bitmap bitmap)