Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.graphics.Bitmap;

import android.graphics.Color;

public class Main {
    /**
     * Method to create a fully-transparent Bitmap using the same size of the source passed as
     * parameter and also the same density.
     *
     * @param source The original Bitmap.
     * @return A transparent Bitmap with the same size of the source.
     */
    public static Bitmap clear(Bitmap source) {
        Bitmap newBitmap = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight());
        //to erase the color from a Bitmap, I must use a mutable Bitmap!!!!
        Bitmap mutableBitmap = newBitmap.copy(Bitmap.Config.ARGB_8888, true);
        mutableBitmap.eraseColor(Color.TRANSPARENT);
        return mutableBitmap;
    }
}