Search in sources :

Example 96 with PorterDuffXfermode

use of android.graphics.PorterDuffXfermode in project MaterialDesignLibrary by navasmdc.

the class ButtonFloat method cropCircle.

public Bitmap cropCircle(Bitmap bitmap) {
    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());
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2, bitmap.getWidth() / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    return output;
}
Also used : Bitmap(android.graphics.Bitmap) Rect(android.graphics.Rect) PorterDuffXfermode(android.graphics.PorterDuffXfermode) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint)

Example 97 with PorterDuffXfermode

use of android.graphics.PorterDuffXfermode in project android_packages_inputmethods_LatinIME by CyanogenMod.

the class DrawingPreviewPlacerView method setHardwareAcceleratedDrawingEnabled.

public void setHardwareAcceleratedDrawingEnabled(final boolean enabled) {
    if (!enabled)
        return;
    final Paint layerPaint = new Paint();
    layerPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER));
    setLayerType(LAYER_TYPE_HARDWARE, layerPaint);
}
Also used : PorterDuffXfermode(android.graphics.PorterDuffXfermode) Paint(android.graphics.Paint)

Example 98 with PorterDuffXfermode

use of android.graphics.PorterDuffXfermode in project android_packages_apps_Launcher2 by CyanogenMod.

the class Cling method init.

void init(Launcher l, int[] positionData) {
    if (!mIsInitialized) {
        mLauncher = l;
        mPositionData = positionData;
        Resources r = getContext().getResources();
        mPunchThroughGraphic = r.getDrawable(R.drawable.cling);
        mPunchThroughGraphicCenterRadius = r.getDimensionPixelSize(R.dimen.clingPunchThroughGraphicCenterRadius);
        mAppIconSize = r.getDimensionPixelSize(R.dimen.app_icon_size);
        mRevealRadius = r.getDimensionPixelSize(R.dimen.reveal_radius) * 1f;
        mButtonBarHeight = r.getDimensionPixelSize(R.dimen.button_bar_height);
        mErasePaint = new Paint();
        mErasePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));
        mErasePaint.setColor(0xFFFFFF);
        mErasePaint.setAlpha(0);
        mIsInitialized = true;
    }
}
Also used : PorterDuffXfermode(android.graphics.PorterDuffXfermode) Resources(android.content.res.Resources) Paint(android.graphics.Paint)

Example 99 with PorterDuffXfermode

use of android.graphics.PorterDuffXfermode in project TransitionHelper by ImmortalZ.

the class CirleAnimView method init.

private void init(Context context) {
    mPaint = new Paint();
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setAntiAlias(true);
    mPaint.setColor(getResources().getColor(R.color.showmethod_end_color));
    xfermode = new PorterDuffXfermode(PorterDuff.Mode.DST_OUT);
    setWillNotDraw(false);
}
Also used : PorterDuffXfermode(android.graphics.PorterDuffXfermode) Paint(android.graphics.Paint)

Example 100 with PorterDuffXfermode

use of android.graphics.PorterDuffXfermode in project SimpleCropView by IsseiAoki.

the class CropImageView method getCircularBitmap.

/**
     * Crop the square image in a circular
     *
     * @param square image bitmap
     * @return circular image bitmap
     */
public Bitmap getCircularBitmap(Bitmap square) {
    if (square == null)
        return null;
    Bitmap output = Bitmap.createBitmap(square.getWidth(), square.getHeight(), Bitmap.Config.ARGB_8888);
    final Rect rect = new Rect(0, 0, square.getWidth(), square.getHeight());
    Canvas canvas = new Canvas(output);
    int halfWidth = square.getWidth() / 2;
    int halfHeight = square.getHeight() / 2;
    final Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setFilterBitmap(true);
    canvas.drawCircle(halfWidth, halfHeight, Math.min(halfWidth, halfHeight), paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(square, rect, rect, paint);
    return output;
}
Also used : Bitmap(android.graphics.Bitmap) Rect(android.graphics.Rect) PorterDuffXfermode(android.graphics.PorterDuffXfermode) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint) 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