Java tutorial
//package com.java2s; /** * Appcelerator Titanium Mobile * Copyright (c) 2009-2012 by Appcelerator, Inc. All Rights Reserved. * Licensed under the terms of the Apache Public License * Please see the LICENSE included with this distribution for details. */ import android.graphics.Bitmap; public class Main { /** * Add an alpha channel to the given image if it does not already have one. * * @param image * the image to add an alpha channel to. * @return a copy of the given image with an alpha channel. If the image already have the alpha channel, return the * image itself. */ public static Bitmap imageWithAlpha(Bitmap image) { if (image == null) { return null; } if (image.hasAlpha()) { return image; } return image.copy(Bitmap.Config.ARGB_8888, true); } }