Android Bitmap Color Change initAlphaChannel( BitmapFactory.Options bitmapOptions)

Here you can find the source of initAlphaChannel( BitmapFactory.Options bitmapOptions)

Description

set bitmap options preferred config

Parameter

Parameter Description
bitmapOptions bitmap options

Return

true if options is valid

Declaration

public static boolean initAlphaChannel(
        BitmapFactory.Options bitmapOptions) 

Method Source Code

//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);
    }
}

Related

  1. dilate(Bitmap source, Bitmap target, int[][] se)
  2. doBrightness(Bitmap src, int value)
  3. erosion(Bitmap bitmap, int[][] se)
  4. getGrayscaleHistogram(Bitmap bm)
  5. increaseGreen(Bitmap src, int value)
  6. initBitmapFactoryOptions( BitmapFactory.Options bitmapOptions, int maxWidth, int maxHeight)
  7. makeSaturated(Bitmap source, int level)
  8. makeVivid(Bitmap src, int type, float percent)
  9. setAlpha(Bitmap sourceImg, int number)