當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。