Here you can find the source of setAlpha(Bitmap sourceImg, int number)
public static Bitmap setAlpha(Bitmap sourceImg, int number)
//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; } }