Search in sources :

Example 26 with PorterDuffXfermode

use of android.graphics.PorterDuffXfermode in project muzei by romannurik.

the class SettingsChooseSourceFragment method prepareGenerateSourceImages.

private void prepareGenerateSourceImages() {
    mImageFillPaint.setColor(Color.WHITE);
    mImageFillPaint.setAntiAlias(true);
    mAlphaPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
    mSelectedSourceImage = new BitmapDrawable(getResources(), generateSourceImage(ResourcesCompat.getDrawable(getResources(), R.drawable.ic_source_selected, null)));
}
Also used : PorterDuffXfermode(android.graphics.PorterDuffXfermode) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 27 with PorterDuffXfermode

use of android.graphics.PorterDuffXfermode in project platform_frameworks_base by android.

the class ScrimView method setDrawAsSrc.

public void setDrawAsSrc(boolean asSrc) {
    mDrawAsSrc = asSrc;
    mPaint.setXfermode(new PorterDuffXfermode(mDrawAsSrc ? PorterDuff.Mode.SRC : PorterDuff.Mode.SRC_OVER));
    invalidate();
}
Also used : PorterDuffXfermode(android.graphics.PorterDuffXfermode)

Example 28 with PorterDuffXfermode

use of android.graphics.PorterDuffXfermode in project androidquery by androidquery.

the class BitmapAjaxCallback method getRoundedCornerBitmap.

private static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), 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);
    final 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(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    return output;
}
Also used : RectF(android.graphics.RectF) Bitmap(android.graphics.Bitmap) Rect(android.graphics.Rect) PorterDuffXfermode(android.graphics.PorterDuffXfermode) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint) Paint(android.graphics.Paint)

Example 29 with PorterDuffXfermode

use of android.graphics.PorterDuffXfermode in project Lazy by l123456789jy.

the class BitmapUtil method combineImagesToSameSize.

/**
     * 合并
     * @param bgd 后景Bitmap
     * @param fg 前景Bitmap
     * @return 合成后Bitmap
     */
public static Bitmap combineImagesToSameSize(Bitmap bgd, Bitmap fg) {
    Bitmap bmp;
    int width = bgd.getWidth() < fg.getWidth() ? bgd.getWidth() : fg.getWidth();
    int height = bgd.getHeight() < fg.getHeight() ? bgd.getHeight() : fg.getHeight();
    if (fg.getWidth() != width && fg.getHeight() != height) {
        fg = zoom(fg, width, height);
    }
    if (bgd.getWidth() != width && bgd.getHeight() != height) {
        bgd = zoom(bgd, width, height);
    }
    bmp = Bitmap.createBitmap(width, height, Config.ARGB_8888);
    Paint paint = new Paint();
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_ATOP));
    Canvas canvas = new Canvas(bmp);
    canvas.drawBitmap(bgd, 0, 0, null);
    canvas.drawBitmap(fg, 0, 0, paint);
    return bmp;
}
Also used : Bitmap(android.graphics.Bitmap) PorterDuffXfermode(android.graphics.PorterDuffXfermode) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint)

Example 30 with PorterDuffXfermode

use of android.graphics.PorterDuffXfermode in project Shuttle by timusus.

the class IntroductoryOverlay method setupHolePaint.

private void setupHolePaint() {
    PorterDuffXfermode xfermode = new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY);
    mHolePaint = new Paint();
    mHolePaint.setColor(0xFFFFFF);
    mHolePaint.setAlpha(0);
    mHolePaint.setXfermode(xfermode);
    mHolePaint.setAntiAlias(true);
}
Also used : PorterDuffXfermode(android.graphics.PorterDuffXfermode) Paint(android.graphics.Paint)

Aggregations

PorterDuffXfermode (android.graphics.PorterDuffXfermode)148 Paint (android.graphics.Paint)124 Canvas (android.graphics.Canvas)101 Bitmap (android.graphics.Bitmap)90 Rect (android.graphics.Rect)64 RectF (android.graphics.RectF)49 SuppressLint (android.annotation.SuppressLint)9 LinearGradient (android.graphics.LinearGradient)9 Matrix (android.graphics.Matrix)9 TypedArray (android.content.res.TypedArray)8 Point (android.graphics.Point)6 IOException (java.io.IOException)6 BitmapDrawable (android.graphics.drawable.BitmapDrawable)5 ColorMatrix (android.graphics.ColorMatrix)4 Path (android.graphics.Path)4 Resources (android.content.res.Resources)3 Drawable (android.graphics.drawable.Drawable)3 ResourceHelper (com.klinker.android.launcher.api.ResourceHelper)3 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)3 RadialGradient (android.graphics.RadialGradient)2