Android Bitmap Color Change increaseGreen(Bitmap src, int value)

Here you can find the source of increaseGreen(Bitmap src, int value)

Description

Increase green.

Parameter

Parameter Description
src the src
value the value

Return

the bitmap

Declaration

public static Bitmap increaseGreen(Bitmap src, int value) 

Method Source Code

//package com.java2s;

import android.graphics.Bitmap;

import android.graphics.Color;

public class Main {
    /**/*from   w ww  .j a v a  2s  . c  o m*/
     * Increase green.
     *
     * @param src the src
     * @param value the value
     * @return the bitmap
     */
    public static Bitmap increaseGreen(Bitmap src, int value) {
        int width = src.getWidth();
        int height = src.getHeight();
        final float factor = 1.1f;

        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. dilate(Bitmap bitmap, int[][] se)
  2. dilate(Bitmap source, Bitmap target, int[][] se)
  3. doBrightness(Bitmap src, int value)
  4. erosion(Bitmap bitmap, int[][] se)
  5. getGrayscaleHistogram(Bitmap bm)
  6. initAlphaChannel( BitmapFactory.Options bitmapOptions)
  7. initBitmapFactoryOptions( BitmapFactory.Options bitmapOptions, int maxWidth, int maxHeight)
  8. makeSaturated(Bitmap source, int level)
  9. makeVivid(Bitmap src, int type, float percent)