當前位置: 首頁>>代碼示例>>Java>>正文


Java Paint.setXfermode方法代碼示例

本文整理匯總了Java中android.graphics.Paint.setXfermode方法的典型用法代碼示例。如果您正苦於以下問題:Java Paint.setXfermode方法的具體用法?Java Paint.setXfermode怎麽用?Java Paint.setXfermode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.Paint的用法示例。


在下文中一共展示了Paint.setXfermode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRoundedCornerBitmap

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * Creates a bitmap with rounded corners.
 * @param bitmap The bitmap
 * @param i the corner radius in pixels
 * @return The bitmap with rounded corners
 */
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int i) {
	if (bitmap == null) {
		return Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
	}

	Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
			bitmap.getHeight(), Bitmap.Config.ARGB_8888);
	Canvas canvas = new Canvas(output);

	final int color = 0xff424242;
	final Paint paint = new Paint();
	final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
	final RectF rectF = new RectF(rect);

	paint.setAntiAlias(true);
	canvas.drawARGB(0, 0, 0, 0);
	paint.setColor(color);
	canvas.drawRoundRect(rectF, (float) i, (float) i, paint);

	paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
	canvas.drawBitmap(bitmap, rect, rect, paint);

	return output;
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:31,代碼來源:Service.java

示例2: init

import android.graphics.Paint; //導入方法依賴的package包/類
private void init(Context context) {
    setWillNotDraw(false);
    setVisibility(INVISIBLE);

    lineStroke = Utils.dpToPx(4);
    isReady = false;
    isRevealAnimationEnabled = true;
    dismissOnTouch = false;
    isPerformClick = false;
    enableDismissAfterShown = false;
    dismissOnBackPress = false;
    handler = new Handler();
    preferencesManager = new PreferencesManager(context);
    eraser = new Paint();
    eraser.setColor(0xFFFFFFFF);
    eraser.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    eraser.setFlags(Paint.ANTI_ALIAS_FLAG);
}
 
開發者ID:HueToYou,項目名稱:ChatExchange-old,代碼行數:19,代碼來源:SpotlightView.java

示例3: getRoundedCornerBitmap

import android.graphics.Paint; //導入方法依賴的package包/類
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, float pixels) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap
            .getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(0xff424242);

    canvas.drawRoundRect(rectF, pixels, pixels, paint);

    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);

    return output;
}
 
開發者ID:MobileDev418,項目名稱:chat-sdk-android-push-firebase,代碼行數:21,代碼來源:ChatBubbleImageView.java

示例4: createFramedPhoto

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * @param x              圖像的寬度
 * @param y              圖像的高度
 * @param image          源圖片
 * @param outerRadiusRat 圓角的大小
 * @return 圓角圖片
 */
public static Bitmap createFramedPhoto(int x, int y, Bitmap image, float outerRadiusRat) {
    // 根據源文件新建一個darwable對象
    Drawable imageDrawable = new BitmapDrawable(image);

    // 新建一個新的輸出圖片
    Bitmap output = Bitmap.createBitmap(x, y, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    // 新建一個矩形
    RectF outerRect = new RectF(0, 0, x, y);

    // 產生一個紅色的圓角矩形
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.RED);
    canvas.drawRoundRect(outerRect, outerRadiusRat, outerRadiusRat, paint);

    // 將源圖片繪製到這個圓角矩形上
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    imageDrawable.setBounds(0, 0, x, y);
    canvas.saveLayer(outerRect, paint, Canvas.ALL_SAVE_FLAG);
    imageDrawable.draw(canvas);
    canvas.restore();

    return output;
}
 
開發者ID:GitLqr,項目名稱:LQRWeChat,代碼行數:33,代碼來源:ImageUtils.java

示例5: toRoundCorner

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * 轉為圓角圖片
 *
 * @param src     源圖片
 * @param radius  圓角的度數
 * @param recycle 是否回收
 * @return 圓角圖片
 */
public static Bitmap toRoundCorner(Bitmap src, float radius, boolean recycle) {
    if (null == src) return null;
    int width = src.getWidth();
    int height = src.getHeight();
    Bitmap ret = Bitmap.createBitmap(width, height, src.getConfig());
    Paint paint = new Paint();
    Canvas canvas = new Canvas(ret);
    Rect rect = new Rect(0, 0, width, height);
    paint.setAntiAlias(true);
    canvas.drawRoundRect(new RectF(rect), radius, radius, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(src, rect, rect, paint);
    if (recycle && !src.isRecycled()) src.recycle();
    return ret;
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:24,代碼來源:ImageUtils.java

示例6: getRoundedCornerBitmap

import android.graphics.Paint; //導入方法依賴的package包/類
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, float roundPx) {
    if (bitmap == null) {
        return null;
    }
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);
    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    return output;
}
 
開發者ID:jeasinlee,項目名稱:AndroidBasicLibs,代碼行數:19,代碼來源:ImageUtils.java

示例7: init

import android.graphics.Paint; //導入方法依賴的package包/類
private void init(Context context, AttributeSet attrs) {
	mask = BitmapFactory.decodeResource(context.getResources(), R.drawable.face_mask);
	rect = BitmapFactory.decodeResource(context.getResources(), R.drawable.face_rect);
	leftScan = BitmapFactory.decodeResource(context.getResources(), R.drawable.up_left_scan);
	rightScan = BitmapFactory.decodeResource(context.getResources(), R.drawable.up_right_scan);
	faceW = mask.getWidth();
	faceH = mask.getHeight();
	paint = new Paint();
	paint.setAntiAlias(true);
	paint.setColor(Color.parseColor("#4C0C0F3C"));
	paint1 = new Paint();
	paint1.setAntiAlias(true);
	paint1.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
	paint2 = new Paint();
	paint2.setAntiAlias(true);
	paint2.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
	paint3 = new Paint();
	paint3.setAntiAlias(true);
	paint3.setColor(Color.parseColor("#000000"));
}
 
開發者ID:FreeSunny,項目名稱:Amazing,代碼行數:21,代碼來源:ScanView.java

示例8: toRound

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * 轉為圓形圖片
 *
 * @param src     源圖片
 * @param recycle 是否回收
 * @return 圓形圖片
 */
public static Bitmap toRound(Bitmap src, boolean recycle) {
    if (isEmptyBitmap(src)) return null;
    int width = src.getWidth();
    int height = src.getHeight();
    int radius = Math.min(width, height) >> 1;
    Bitmap ret = Bitmap.createBitmap(width, height, src.getConfig());
    Paint paint = new Paint();
    Canvas canvas = new Canvas(ret);
    Rect rect = new Rect(0, 0, width, height);
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    canvas.drawCircle(width >> 1, height >> 1, radius, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(src, rect, rect, paint);
    if (recycle && !src.isRecycled()) src.recycle();
    return ret;
}
 
開發者ID:hoangkien0705,項目名稱:Android-UtilCode,代碼行數:25,代碼來源:ImageUtils.java

示例9: makeRoundCornerBitmap

import android.graphics.Paint; //導入方法依賴的package包/類
public static Bitmap makeRoundCornerBitmap(Bitmap bitmap, int pixels, int color) {
    Bitmap outputBitmap = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(outputBitmap);
    Paint paint = new Paint();
    Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    RectF rectF = new RectF(rect);
    float roundPx = pixels;
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    return outputBitmap;
}
 
開發者ID:JackWHLiu,項目名稱:jackknife,代碼行數:17,代碼來源:ImageUtils.java

示例10: setupDonePaints

import android.graphics.Paint; //導入方法依賴的package包/類
private void setupDonePaints() {
    doneBgPaint = new Paint();
    doneBgPaint.setAntiAlias(true);
    doneBgPaint.setStyle(Paint.Style.FILL);
    doneBgPaint.setColor(0xff39cb72);

    checkmarkPaint = new Paint();

    maskPaint = new Paint();
    maskPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
}
 
開發者ID:NarendraSickarwar,項目名稱:FirebasePost,代碼行數:12,代碼來源:SendingProgressView.java

示例11: getRoundedCornerBitmap

import android.graphics.Paint; //導入方法依賴的package包/類
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, float pixels, int width, int height) {
    final Bitmap output = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(output);

    final int sourceWidth = bitmap.getWidth();
    final int sourceHeight = bitmap.getHeight();

    float xScale = (float) width / bitmap.getWidth();
    float yScale = (float) height / bitmap.getHeight();
    float scale = Math.max(xScale, yScale);

    float scaledWidth = scale * sourceWidth;
    float scaledHeight = scale * sourceHeight;

    float left = (width - scaledWidth) / 2;
    float top = (height - scaledHeight) / 2;

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, width, height);
    final RectF rectF = new RectF(rect);

    final RectF targetRect = new RectF(left, top, left + scaledWidth, top + scaledHeight);

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, pixels, pixels, paint);

    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, null, targetRect, paint);

    return output;
}
 
開發者ID:Ramotion,項目名稱:showroom-android,代碼行數:35,代碼來源:DecodeBitmapTask.java

示例12: getCircleBitmap

import android.graphics.Paint; //導入方法依賴的package包/類
/**
 * 生成透明背景的圓形圖片
 */
public static Bitmap getCircleBitmap(Bitmap bitmap) {
    if (bitmap == null) {
        return null;
    }
    try {
        Bitmap circleBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(circleBitmap);

        final Paint paint = new Paint();
        paint.setAntiAlias(true);

        float radius = Math.min(bitmap.getWidth(), bitmap.getHeight()) / 2.0f;

        //繪製透明底
        canvas.drawARGB(0, 0, 0, 0);

        //繪製背景圓
        paint.setColor(Color.WHITE);
        canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2, radius, paint);

        //取兩層繪製交集。顯示上層。
        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));

        //繪製圖片並取交集,顯示上層
        //取中間區域繪製
        int left = (int) ((bitmap.getWidth() - radius * 2) / 2);
        int top = (int) ((bitmap.getHeight() - radius * 2) / 2);
        canvas.drawBitmap(bitmap, -left, -top, paint);

        bitmap.recycle();
        bitmap = null;

        return circleBitmap;

    } catch (Exception e) {
        return bitmap;
    }
}
 
開發者ID:DuanJiaNing,項目名稱:Musicoco,代碼行數:42,代碼來源:BitmapUtils.java

示例13: dispatchDraw

import android.graphics.Paint; //導入方法依賴的package包/類
@Override
protected void dispatchDraw(Canvas canvas) {
    Paint paint = new Paint();
    paint.setColor(defaultColor);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT));
    canvas.drawCircle(mCenterX, mCenterY, mRadius, paint);
    super.dispatchDraw(canvas);
}
 
開發者ID:Kaufland,項目名稱:andcoachmark,代碼行數:9,代碼來源:CircleView.java

示例14: BezelImageView

import android.graphics.Paint; //導入方法依賴的package包/類
public BezelImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // Attribute initialization.
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BezelImageView,
            defStyle, 0);

    mMaskDrawable = a.getDrawable(R.styleable.BezelImageView_maskDrawable);
    if (mMaskDrawable != null) {
        mMaskDrawable.setCallback(this);
    }

    mBorderDrawable = a.getDrawable(R.styleable.BezelImageView_borderDrawable);
    if (mBorderDrawable != null) {
        mBorderDrawable.setCallback(this);
    }

    mDesaturateOnPress = a.getBoolean(R.styleable.BezelImageView_desaturateOnPress,
            mDesaturateOnPress);

    a.recycle();

    // Other initialization.
    mBlackPaint = new Paint();
    mBlackPaint.setColor(0xff000000);
    
    mMaskedPaint = new Paint();
    mMaskedPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));

    // Always want a cache allocated.
    mCacheBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);

    if (mDesaturateOnPress) {
        // Create a desaturate color filter for pressed state.
        ColorMatrix cm = new ColorMatrix();
        cm.setSaturation(0);
        mDesaturateColorFilter = new ColorMatrixColorFilter(cm);
    }
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:40,代碼來源:BezelImageView.java

示例15: drawBackground

import android.graphics.Paint; //導入方法依賴的package包/類
public void drawBackground(Canvas canvas, Paint paint) {
    canvas.save();
    canvas.translate(getOffsetX(), getOffsetY());

    paint.reset();
    if(Utilities.isAllowFolderTransparentPrefEnabled(Launcher.getLauncherActivity().getApplicationContext())){
        paint.setStyle(Paint.Style.STROKE);
    }else {
        paint.setStyle(Paint.Style.FILL);
    }
    paint.setXfermode(null);
    paint.setAntiAlias(true);

    int alpha = (int) Math.min(MAX_BG_OPACITY, BG_OPACITY * mColorMultiplier);
    if(Utilities.getFolderPreviewBackgroundPrefEnabled(Launcher.getLauncherActivity().getApplicationContext()) != -1){
        paint.setColor(Utilities.getFolderPreviewBackgroundPrefEnabled(Launcher.getLauncherActivity().getApplicationContext()));
    }else {
        paint.setColor(Color.argb(alpha, BG_INTENSITY, BG_INTENSITY, BG_INTENSITY));
    }
    float radius = getScaledRadius();

    canvas.drawCircle(radius, radius, radius, paint);
    canvas.clipPath(mClipPath, Region.Op.DIFFERENCE);

    paint.setStyle(Paint.Style.STROKE);
    paint.setColor(Color.TRANSPARENT);
    paint.setShadowLayer(mStrokeWidth, 0, mStrokeWidth, Color.argb(SHADOW_OPACITY, 0, 0, 0));
    canvas.drawCircle(radius, radius, radius, paint);

    canvas.restore();
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:32,代碼來源:FolderIcon.java


注:本文中的android.graphics.Paint.setXfermode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。