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


Java Paint.getXfermode方法代码示例

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


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

示例1: onDraw

import android.graphics.Paint; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    Drawable drawable = getDrawable();
    if (drawable instanceof BitmapDrawable) {
        RectF rectF = new RectF(drawable.getBounds());
        int restoreCount = canvas.saveLayer(rectF, null, Canvas.ALL_SAVE_FLAG);
        getImageMatrix().mapRect(rectF);

        Paint paint = ((BitmapDrawable) drawable).getPaint();
        paint.setAntiAlias(true);
        paint.setColor(0xff000000);

        canvas.drawARGB(0, 0, 0, 0);
        canvas.drawRoundRect(rectF, RADIUS, RADIUS, paint);

        Xfermode restoreMode = paint.getXfermode();
        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
        super.onDraw(canvas);

        // Restore paint and canvas
        paint.setXfermode(restoreMode);
        canvas.restoreToCount(restoreCount);
    } else {
        super.onDraw(canvas);
    }
}
 
开发者ID:Kaufland,项目名称:andcouchbaseentity,代码行数:27,代码来源:RoundImageView.java

示例2: onDraw

import android.graphics.Paint; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
	
	Drawable maiDrawable = getDrawable();
	if (!isInEditMode() && maiDrawable instanceof BitmapDrawable) {
		Paint paint = ((BitmapDrawable) maiDrawable).getPaint();
        
        Rect bitmapBounds = maiDrawable.getBounds();
        rect.set(bitmapBounds);
        
		int saveCount = canvas.saveLayer(rect, null,
                   Canvas.MATRIX_SAVE_FLAG |
                   Canvas.CLIP_SAVE_FLAG |
                   Canvas.HAS_ALPHA_LAYER_SAVE_FLAG |
                   Canvas.FULL_COLOR_LAYER_SAVE_FLAG |
                   Canvas.CLIP_TO_LAYER_SAVE_FLAG);
		getImageMatrix().mapRect(rect);

        paint.setAntiAlias(true);
        canvas.drawARGB(0, 0, 0, 0);
        final int color = 0xffffffff;
        paint.setColor(color);
        canvas.drawPath(boundPath, paint);

		Xfermode oldMode = paint.getXfermode();
		paint.setXfermode(duffMode);
        super.onDraw(canvas);
        paint.setXfermode(oldMode);
        canvas.restoreToCount(saveCount);
        
        drawHover(canvas);
		drawBorder(canvas);
	} else {
		super.onDraw(canvas);
	}
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:37,代码来源:HoverImageView.java


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