Android Bitmap Color Change makeVivid(Bitmap src, int type, float percent)

Here you can find the source of makeVivid(Bitmap src, int type, float percent)

Description

Make colors in bitmap vivid.

Parameter

Parameter Description
src the src
type the type
percent the percent

Return

the bitmap

Declaration

public static Bitmap makeVivid(Bitmap src, int type, float percent) 

Method Source Code

//package com.java2s;

import android.graphics.Bitmap;

import android.graphics.Color;

public class Main {
    /**//  ww w.  j  a v  a  2 s  . co  m
     * Make colors in bitmap vivid.
     * 
     * @param src
     *            the src
     * @param type
     *            the type
     * @param percent
     *            the percent
     * @return the bitmap
     * @author siddhesh
     */
    public static Bitmap makeVivid(Bitmap src, int type, float percent) {
        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);
                A = Color.alpha(pixel);
                R = Color.red(pixel);
                G = Color.green(pixel);
                B = Color.blue(pixel);
                //            Log.e("CHECK", "RGB : R = " + R + " G = " + G + " B = " + B);
                R = (int) (R * (1 + percent));
                if (R > 255)
                    R = 255;
                G = (int) (G * (1 + percent));
                if (G > 255)
                    G = 255;
                B = (int) (B * (1 + percent));
                if (B > 255)
                    B = 255;
                bmOut.setPixel(x, y, Color.argb(A, R, G, B));
            }
        }
        return bmOut;
    }
}

Related

  1. getGrayscaleHistogram(Bitmap bm)
  2. increaseGreen(Bitmap src, int value)
  3. initAlphaChannel( BitmapFactory.Options bitmapOptions)
  4. initBitmapFactoryOptions( BitmapFactory.Options bitmapOptions, int maxWidth, int maxHeight)
  5. makeSaturated(Bitmap source, int level)
  6. setAlpha(Bitmap sourceImg, int number)
  7. setAlpha(Bitmap sourceImg, int number)
  8. tiltShift(Bitmap sentBitmap, int radius, int x, int y)
  9. changeBitmapColor(Bitmap bmp, int color)