Code example for Bitmap

Methods: getHeightgetWidthhasAlpha

0
	public static Bitmap imageWithAlpha(Bitmap image)
	{ 
		if (image == null) {
			return null; 
		} 
		if (image.hasAlpha()) {
			return image;
		} 
		return image.copy(Bitmap.Config.ARGB_8888, true);
	} 
 
	/** 
	 * Create a copy of the given image with rounded corners and a transparent border around its edges. 
	 *  
	 * @param image 
	 *            the image to add rounded corners to. 
	 * @param cornerRadius 
	 *            the radius of the rounded corners. 
	 * @param borderSize 
	 *            the size of the border to be added. 
	 * @return a copy of the given image with rounded corners and a transparent border. If the cornerRadius <= 0 or 
	 *         borderSize < 0, return the image itself. 
	 */ 
	public static Bitmap imageWithRoundedCorner(Bitmap image, float cornerRadius, float borderSize)
	{ 
		if (image == null) {
			return null; 
		} 
		if (cornerRadius <= 0 || borderSize < 0) {
			Log.w(TAG, "Unable to add rounded corners. Invalid corner radius or borderSize for imageWithRoundedCorner");
			return image;
		} 
 
		int width = image.getWidth();
		int height = image.getHeight();
		Bitmap imageRoundedCorner = Bitmap.createBitmap(width + (int) (borderSize * 2), height + (int) (borderSize * 2),
			Bitmap.Config.ARGB_8888);
		Canvas canvas = new Canvas(imageRoundedCorner);
 
		Path clipPath = new Path();
Contextual code suggestions in your IDE  Get Codota for Java