0

Think I have an bitmap that I have loaded it from Album Art in Media Store , It has 100 percent transparent value , how can I change that to 50 or 30 ?

Also Do you know any way that I can make image black and white ?

thanks

pedd Mylast
  • 67
  • 1
  • 7

2 Answers2

0

Set the alpha between 0 to 255!!

alpha set to 45 will make the image transparent

ViewName.getBackground().setAlpha(65);

Dharmaraj Patil
  • 116
  • 1
  • 6
0

Use the following method:

/**
 * @param bitmap The source bitmap.
 * @param opacity a value between 0 (completely transparent) and 255 (completely
 * opaque).
 * @return The opacity-adjusted bitmap.  If the source bitmap is mutable it will be
 * adjusted and returned, otherwise a new bitmap is created.
 */
private Bitmap adjustOpacity(Bitmap bitmap, int opacity)
{
    Bitmap mutableBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
    Canvas canvas = new Canvas(mutableBitmap);
    int colour = (opacity & 0xFF) << 24;
    canvas.drawColor(colour, PorterDuff.Mode.DST_IN);
    return mutableBitmap;
}

Explanation here: http://blog.uncommons.org/2011/01/12/adjusting-the-opacity-of-an-android-bitmap/

balazsbalazs
  • 4,071
  • 1
  • 24
  • 29