Bitmap hasAlpha - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Bitmap hasAlpha method.

This code example shows how to use the following methods:copy, hasAlpha
	 
	public static Bitmap imageAlpha(Bitmap image, KrollDict args)
	{ 
		if (image != null) {
			// If the image already has an alpha channel then just return 
			if (image.hasAlpha()) {
				return image;
			} 
			 
			// Create a new bitmap that supports alpha 
			Bitmap resultBitmap = image.copy(Bitmap.Config.ARGB_8888, false);
			 
			return resultBitmap;
		} 
		 
		return null; 
	} 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getConfig, getHeight, getWidth, hasAlpha
package org.ebookdroid.common.bitmaps; 
 
import android.graphics.Bitmap; 
import android.graphics.Canvas; 
 
class BitmapRef extends AbstractBitmapRef { 
 
    private volatile Bitmap bitmap;
 
    BitmapRef(final Bitmap bitmap, final long generation) {
        super(bitmap.getConfig(), bitmap.hasAlpha(), bitmap.getWidth(), bitmap.getHeight(), generation);
        this.bitmap = bitmap;
    } 
 
    @Override 
    public Canvas getCanvas() {
        return new Canvas(bitmap);
    } 
 
    @Override 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:copy, getHeight, getWidth, hasAlpha
	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. 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getHeight, getWidth, hasAlpha
     * @return A bitmap that fits the maximum dimensions. 
     */ 
    @SuppressWarnings({"SuspiciousNameCombination"}) 
    @VisibleForTesting 
    static Bitmap getNormalizedBitmap(Bitmap original, int maxDim, boolean forceCropToSquare) {
        final boolean originalHasAlpha = original.hasAlpha();
 
        // All cropXxx's are in the original coordinate. 
        int cropWidth = original.getWidth();
        int cropHeight = original.getHeight();
        int cropLeft = 0;
        int cropTop = 0;
        if (forceCropToSquare && cropWidth != cropHeight) {
            // Crop the image to the square at its center. 
            if (cropHeight > cropWidth) {
                cropTop = (cropHeight - cropWidth) / 2;
                cropHeight = cropWidth;
            } else { 
                cropLeft = (cropWidth - cropHeight) / 2;
                cropWidth = cropHeight;
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:compress, getHeight, getWidth, hasAlpha
	public static TiBlob blobFromImage(Bitmap image)
	{ 
	 
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		byte data[] = new byte[0];
		if (image.hasAlpha()) {
			if (image.compress(CompressFormat.PNG, 100, bos)) {
				data = bos.toByteArray();
			} 
		} 
		else { 
			if (image.compress(CompressFormat.JPEG, 100, bos)) {
				data = bos.toByteArray();
			} 
		} 
 
		TiBlob blob = new TiBlob(TYPE_IMAGE, data, "image/bitmap");
		blob.image = image;
		blob.width = image.getWidth();
		blob.height = image.getHeight();

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:hasAlpha
        return mHeight;
    } 
 
    @Override 
    public int getOpacity() { 
        return (mBitmap == null || mBitmap.hasAlpha() || mPaint.getAlpha() < 255) ?
                PixelFormat.TRANSLUCENT : PixelFormat.OPAQUE;
    } 
 
    @Override 
	public void finalize() throws Throwable{ 
		SvgRaster.svgAndroidDestroy(mSvgId);
		super.finalize(); 
	} 
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Bitmap hasAlpha Questions & Answers:

hasAlpha Method Overview
Returns true if the bitmap's config supports per-pixel alpha, and if the pixels may contain non-opaque alpha values.
See Code Examples for other Android Bitmap Methods: