Here you can find the source of makeSaturated(Bitmap source, int level)
Parameter | Description |
---|---|
source | the source |
level | the level |
public static Bitmap makeSaturated(Bitmap source, int level)
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Color; public class Main { /**/*from ww w. ja v a2 s . c om*/ * Make colors of bitmap saturated. * * @param source * the source * @param level * the level * @return the bitmap * @author siddhesh */ public static Bitmap makeSaturated(Bitmap source, int level) { // get image size int width = source.getWidth(); int height = source.getHeight(); int[] pixels = new int[width * height]; float[] HSV = new float[3]; // get pixel array from source source.getPixels(pixels, 0, width, 0, 0, width, height); int index = 0; // iteration through pixels for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { // get current index in 2D-matrix index = y * width + x; // convert to HSV Color.colorToHSV(pixels[index], HSV); // increase Saturation level HSV[1] *= level; HSV[1] = (float) Math.max(0.0, Math.min(HSV[1], 1.0)); // take color back pixels[index] |= Color.HSVToColor(HSV); } } // output bitmap Bitmap bmOut = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); bmOut.setPixels(pixels, 0, width, 0, 0, width, height); return bmOut; } }