Android Bitmap Color Change setAlpha(Bitmap sourceImg, int number)

Here you can find the source of setAlpha(Bitmap sourceImg, int number)

Description

set Alpha

Declaration

public static Bitmap setAlpha(Bitmap sourceImg, int number) 

Method Source Code

//package com.java2s;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;

public class Main {
    public static Bitmap setAlpha(Bitmap sourceImg, int number) {
        int[] argb = new int[sourceImg.getWidth() * sourceImg.getHeight()];
        sourceImg.getPixels(argb, 0, sourceImg.getWidth(), 0, 0,
                sourceImg.getWidth(), sourceImg.getHeight());// ?????ARGB?
        number = number * 255 / 100;/*  www  . jav  a2 s .  c o m*/
        for (int i = 0; i < argb.length; i++) {
            argb[i] = (number << 24) | (argb[i] & 0x00FFFFFF);// ????????
        }
        sourceImg = Bitmap.createBitmap(argb, sourceImg.getWidth(),
                sourceImg.getHeight(), Config.ARGB_8888);
        return sourceImg;
    }
}

Related

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