当前位置: 首页>>代码示例>>Java>>正文


Java Bitmap.extractAlpha方法代码示例

本文整理汇总了Java中android.graphics.Bitmap.extractAlpha方法的典型用法代码示例。如果您正苦于以下问题:Java Bitmap.extractAlpha方法的具体用法?Java Bitmap.extractAlpha怎么用?Java Bitmap.extractAlpha使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Bitmap的用法示例。


在下文中一共展示了Bitmap.extractAlpha方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: recreateIcon

import android.graphics.Bitmap; //导入方法依赖的package包/类
public synchronized Bitmap recreateIcon(Bitmap icon) {
    int[] offset = new int[2];
    Bitmap shadow = icon.extractAlpha(mBlurPaint, offset);
    Bitmap result = Bitmap.createBitmap(mIconSize, mIconSize, Config.ARGB_8888);
    mCanvas.setBitmap(result);

    // Draw ambient shadow
    mDrawPaint.setAlpha(AMBIENT_SHADOW_ALPHA);
    mCanvas.drawBitmap(shadow, offset[0], offset[1], mDrawPaint);

    // Draw key shadow
    mDrawPaint.setAlpha(KEY_SHADOW_ALPHA);
    mCanvas.drawBitmap(shadow, offset[0], offset[1] + KEY_SHADOW_DISTANCE * mIconSize, mDrawPaint);

    // Draw the icon
    mDrawPaint.setAlpha(255);
    mCanvas.drawBitmap(icon, 0, 0, mDrawPaint);

    mCanvas.setBitmap(null);
    return result;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:22,代码来源:ShadowGenerator.java

示例2: drawImageDropShadow

import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
 *图片阴影
 * @param originalBitmap
 */
public static Drawable drawImageDropShadow(Bitmap originalBitmap, Context context) {

    BlurMaskFilter blurFilter = new BlurMaskFilter(3,BlurMaskFilter.Blur.NORMAL);
    Paint shadowPaint = new Paint();
    shadowPaint.setAlpha(80);
    shadowPaint.setColor(context.getResources().getColor(R.color.black));
    shadowPaint.setMaskFilter(blurFilter);
    int[] offsetXY = new int[2];
    Bitmap shadowBitmap = originalBitmap.extractAlpha(shadowPaint, offsetXY);
    Bitmap shadowImage32 = shadowBitmap.copy(Bitmap.Config.ARGB_8888, true);
    if ( !shadowImage32.isPremultiplied() )
    {
        shadowImage32.setPremultiplied( true );
    }
    Canvas c = new Canvas(shadowImage32);
    c.drawBitmap(originalBitmap, offsetXY[0], offsetXY[1], null);
    return new BitmapDrawable(shadowImage32);
}
 
开发者ID:Evan-Galvin,项目名称:FreeStreams-TVLauncher,代码行数:23,代码来源:ImageTools.java

示例3: drawShadow

import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
 *  为指定图片增加阴影
 *
 * @param map     图片
 * @param radius  阴影的半径
 * @return bitmap
 */
public static Bitmap drawShadow(Bitmap map, int radius) {
    if (map == null)
        return null;

    BlurMaskFilter blurFilter = new BlurMaskFilter(radius, BlurMaskFilter.Blur.OUTER);
    Paint shadowPaint = new Paint();
    shadowPaint.setMaskFilter(blurFilter);

    int[] offsetXY = new int[2];
    Bitmap shadowImage = map.extractAlpha(shadowPaint, offsetXY);
    shadowImage = shadowImage.copy(Bitmap.Config.ARGB_8888, true);
    Canvas c = new Canvas(shadowImage);
    c.drawBitmap(map, -offsetXY[0], -offsetXY[1], null);
    return shadowImage;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:23,代码来源:BmpUtil.java

示例4: toAlpha

import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
 * 转为alpha位图
 *
 * @param src     源图片
 * @param recycle 是否回收
 * @return alpha位图
 */
public static Bitmap toAlpha(final Bitmap src, final Boolean recycle) {
	if (isEmptyBitmap(src)) {
		return null;
	}
	Bitmap ret = src.extractAlpha();
	if (recycle && !src.isRecycled()) {
		src.recycle();
	}
	return ret;
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:18,代码来源:ImageUtils.java

示例5: toAlpha

import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
 * 转为alpha位图
 *
 * @param src 源图片
 * @param recycle 是否回收
 * @return alpha位图
 */
public static Bitmap toAlpha(Bitmap src, Boolean recycle) {
    if (isEmptyBitmap(src)) {
        return null;
    }
    Bitmap ret = src.extractAlpha();
    if (recycle && !src.isRecycled()) {
        src.recycle();
    }
    return ret;
}
 
开发者ID:imliujun,项目名称:LJFramework,代码行数:18,代码来源:ImageUtils.java

示例6: applyExpensiveOutlineWithBlur

import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
 * Applies a more expensive and accurate outline to whatever is currently drawn in a specified
 * bitmap.
 */
public void applyExpensiveOutlineWithBlur(Bitmap srcDst, Canvas srcDstCanvas) {

    // We start by removing most of the alpha channel so as to ignore shadows, and
    // other types of partial transparency when defining the shape of the object
    byte[] pixels = new byte[srcDst.getWidth() * srcDst.getHeight()];
    ByteBuffer buffer = ByteBuffer.wrap(pixels);
    buffer.rewind();
    srcDst.copyPixelsToBuffer(buffer);

    for (int i = 0; i < pixels.length; i++) {
        if ((pixels[i] & 0xFF) < 188) {
            pixels[i] = 0;
        }
    }

    buffer.rewind();
    srcDst.copyPixelsFromBuffer(buffer);

    // calculate the outer blur first
    mBlurPaint.setMaskFilter(mMediumOuterBlurMaskFilter);
    int[] outerBlurOffset = new int[2];
    Bitmap thickOuterBlur = srcDst.extractAlpha(mBlurPaint, outerBlurOffset);

    mBlurPaint.setMaskFilter(mThinOuterBlurMaskFilter);
    int[] brightOutlineOffset = new int[2];
    Bitmap brightOutline = srcDst.extractAlpha(mBlurPaint, brightOutlineOffset);

    // calculate the inner blur
    srcDstCanvas.setBitmap(srcDst);
    srcDstCanvas.drawColor(0xFF000000, PorterDuff.Mode.SRC_OUT);
    mBlurPaint.setMaskFilter(mMediumInnerBlurMaskFilter);
    int[] thickInnerBlurOffset = new int[2];
    Bitmap thickInnerBlur = srcDst.extractAlpha(mBlurPaint, thickInnerBlurOffset);

    // mask out the inner blur
    srcDstCanvas.setBitmap(thickInnerBlur);
    srcDstCanvas.drawBitmap(srcDst, -thickInnerBlurOffset[0],
            -thickInnerBlurOffset[1], mErasePaint);
    srcDstCanvas.drawRect(0, 0, -thickInnerBlurOffset[0], thickInnerBlur.getHeight(),
            mErasePaint);
    srcDstCanvas.drawRect(0, 0, thickInnerBlur.getWidth(), -thickInnerBlurOffset[1],
            mErasePaint);

    // draw the inner and outer blur
    srcDstCanvas.setBitmap(srcDst);
    srcDstCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
    srcDstCanvas.drawBitmap(thickInnerBlur, thickInnerBlurOffset[0], thickInnerBlurOffset[1],
            mDrawPaint);
    srcDstCanvas.drawBitmap(thickOuterBlur, outerBlurOffset[0], outerBlurOffset[1],
            mDrawPaint);

    // draw the bright outline
    srcDstCanvas.drawBitmap(brightOutline, brightOutlineOffset[0], brightOutlineOffset[1],
            mDrawPaint);

    // cleanup
    srcDstCanvas.setBitmap(null);
    brightOutline.recycle();
    thickOuterBlur.recycle();
    thickInnerBlur.recycle();
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:66,代码来源:HolographicOutlineHelper.java

示例7: applyExpensiveOutlineWithBlur

import android.graphics.Bitmap; //导入方法依赖的package包/类
public void applyExpensiveOutlineWithBlur(Bitmap srcDst, Canvas srcDstCanvas,
        boolean clipAlpha) {
    if (ProviderConfig.IS_DOGFOOD_BUILD && srcDst.getConfig() != Bitmap.Config.ALPHA_8) {
        throw new RuntimeException("Outline blue is only supported on alpha bitmaps");
    }

    // We start by removing most of the alpha channel so as to ignore shadows, and
    // other types of partial transparency when defining the shape of the object
    if (clipAlpha) {
        byte[] pixels = new byte[srcDst.getWidth() * srcDst.getHeight()];
        ByteBuffer buffer = ByteBuffer.wrap(pixels);
        buffer.rewind();
        srcDst.copyPixelsToBuffer(buffer);

        for (int i = 0; i < pixels.length; i++) {
            if ((pixels[i] & 0xFF) < 188) {
                pixels[i] = 0;
            }
        }

        buffer.rewind();
        srcDst.copyPixelsFromBuffer(buffer);
    }

    // calculate the outer blur first
    mBlurPaint.setMaskFilter(mMediumOuterBlurMaskFilter);
    int[] outerBlurOffset = new int[2];
    Bitmap thickOuterBlur = srcDst.extractAlpha(mBlurPaint, outerBlurOffset);

    mBlurPaint.setMaskFilter(mThinOuterBlurMaskFilter);
    int[] brightOutlineOffset = new int[2];
    Bitmap brightOutline = srcDst.extractAlpha(mBlurPaint, brightOutlineOffset);

    // calculate the inner blur
    srcDstCanvas.setBitmap(srcDst);
    srcDstCanvas.drawColor(0xFF000000, PorterDuff.Mode.SRC_OUT);
    mBlurPaint.setMaskFilter(mMediumInnerBlurMaskFilter);
    int[] thickInnerBlurOffset = new int[2];
    Bitmap thickInnerBlur = srcDst.extractAlpha(mBlurPaint, thickInnerBlurOffset);

    // mask out the inner blur
    srcDstCanvas.setBitmap(thickInnerBlur);
    srcDstCanvas.drawBitmap(srcDst, -thickInnerBlurOffset[0],
            -thickInnerBlurOffset[1], mErasePaint);
    srcDstCanvas.drawRect(0, 0, -thickInnerBlurOffset[0], thickInnerBlur.getHeight(),
            mErasePaint);
    srcDstCanvas.drawRect(0, 0, thickInnerBlur.getWidth(), -thickInnerBlurOffset[1],
            mErasePaint);

    // draw the inner and outer blur
    srcDstCanvas.setBitmap(srcDst);
    srcDstCanvas.drawColor(0, PorterDuff.Mode.CLEAR);
    srcDstCanvas.drawBitmap(thickInnerBlur, thickInnerBlurOffset[0], thickInnerBlurOffset[1],
            mDrawPaint);
    srcDstCanvas.drawBitmap(thickOuterBlur, outerBlurOffset[0], outerBlurOffset[1],
            mDrawPaint);

    // draw the bright outline
    srcDstCanvas.drawBitmap(brightOutline, brightOutlineOffset[0], brightOutlineOffset[1],
            mDrawPaint);

    // cleanup
    srcDstCanvas.setBitmap(null);
    brightOutline.recycle();
    thickOuterBlur.recycle();
    thickInnerBlur.recycle();
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:68,代码来源:HolographicOutlineHelper.java

示例8: toAlpha

import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
 * 转为alpha位图
 *
 * @param src     源图片
 * @param recycle 是否回收
 * @return alpha位图
 */
public static Bitmap toAlpha(final Bitmap src, final Boolean recycle) {
    if (isEmptyBitmap(src)) return null;
    Bitmap ret = src.extractAlpha();
    if (recycle && !src.isRecycled()) src.recycle();
    return ret;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:ImageUtils.java

示例9: toAlpha

import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
 * 转为alpha位图
 *
 * @param src     源图片
 * @param recycle 是否回收
 * @return alpha位图
 */
public static Bitmap toAlpha(Bitmap src, Boolean recycle) {
    if (isEmptyBitmap(src)) return null;
    Bitmap ret = src.extractAlpha();
    if (recycle && !src.isRecycled()) src.recycle();
    return ret;
}
 
开发者ID:hoangkien0705,项目名称:Android-UtilCode,代码行数:14,代码来源:ImageUtils.java


注:本文中的android.graphics.Bitmap.extractAlpha方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。