Here you can find the source of initAlphaChannel( BitmapFactory.Options bitmapOptions)
Parameter | Description |
---|---|
bitmapOptions | bitmap options |
public static boolean initAlphaChannel( BitmapFactory.Options bitmapOptions)
//package com.java2s; import java.util.Locale; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.text.TextUtils; public class Main { private static final String ALPHA_BITMAP_MIME_TYPE_END = "png"; /**/*from www .j a va2s. c om*/ * set bitmap options preferred config * * @param bitmapOptions bitmap options * @return true if options is valid */ public static boolean initAlphaChannel( BitmapFactory.Options bitmapOptions) { if (!TextUtils.isEmpty(bitmapOptions.outMimeType)) { if (mayNotHasAlphaChannel(bitmapOptions)) { bitmapOptions.inPreferredConfig = Bitmap.Config.RGB_565; bitmapOptions.inDither = false; } else { bitmapOptions.inPreferredConfig = Bitmap.Config.ARGB_8888; } return true; } return false; } /** * FavoriteIdLoader if bitmap may not contain alpha channel * * @param bitmapFactoryOptions bitmap factory option, which has decoded * @return true if yes */ public static boolean mayNotHasAlphaChannel( BitmapFactory.Options bitmapFactoryOptions) { String outMimeType = bitmapFactoryOptions.outMimeType; return !TextUtils.isEmpty(outMimeType) && !outMimeType.toLowerCase(Locale.US).endsWith( ALPHA_BITMAP_MIME_TYPE_END); } }