android.graphics.Xfermode Java Examples
The following examples show how to use
android.graphics.Xfermode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RoundedImageView.java From blurkit-android with MIT License | 6 votes |
@Override protected void onDraw(Canvas canvas) { Drawable myDrawable = getDrawable(); if (myDrawable!=null && myDrawable instanceof BitmapDrawable && mCornerRadius > 0) { rectF.set(myDrawable.getBounds()); int prevCount = canvas.saveLayer(rectF, null, Canvas.ALL_SAVE_FLAG); getImageMatrix().mapRect(rectF); Paint paint = ((BitmapDrawable) myDrawable).getPaint(); paint.setAntiAlias(true); paint.setColor(DEFAULT_COLOR); Xfermode prevMode = paint.getXfermode(); canvas.drawARGB(DEFAULT_RGB, DEFAULT_RGB, DEFAULT_RGB, DEFAULT_RGB); canvas.drawRoundRect(rectF, mCornerRadius, mCornerRadius, paint); paint.setXfermode(porterDuffXfermode); super.onDraw(canvas); paint.setXfermode(prevMode); canvas.restoreToCount(prevCount); } else { super.onDraw(canvas); } }
Example #2
Source File: XulGIFDecoder.java From starcor.xul with GNU Lesser General Public License v3.0 | 5 votes |
public void draw(XulDC dc, int x1, int y1, int w1, int h1, float x2, float y2, float w2, float h2, Paint p) { dc.save(); Xfermode xfermode = p.setXfermode(_colorKeyXferMode); if (_xulDrawable == null) { _xulDrawable = XulDrawable.fromBitmap(_frameImage, "", ""); } dc.drawBitmap(_xulDrawable, x1, y1, w1, h1, x2, y2, w2, h2, p); p.setXfermode(xfermode); dc.restore(); }
Example #3
Source File: ColorHelper.java From Noyze with Apache License 2.0 | 5 votes |
@SuppressWarnings("unused") public static void setXfermode(ImageView icon, Xfermode mode) { try { // Try to load/ cache the xfermode method. if (null == xfremode) { xfremode = ImageView.class.getDeclaredMethod("setXfermode", Xfermode.class); if (null != xfremode) xfremode.setAccessible(true); } if (null != xfremode) xfremode.invoke(icon, mode); } catch (Throwable t) { LogUtils.LOGE("ColorHelper", "Error with ImageView#setXfermode", t); } }
Example #4
Source File: PXPaintGroup.java From pixate-freestyle-android with Apache License 2.0 | 5 votes |
@Override public void setBleningMode(Xfermode mode) { super.setBleningMode(mode); if (paints != null) { for (PXPaint p : paints) { p.setBleningMode(mode); } } }
Example #5
Source File: MaskedImage.java From ALLGO with Apache License 2.0 | 5 votes |
protected void onDraw(Canvas paramCanvas) { Drawable localDrawable = getDrawable(); if (localDrawable == null) return; try { if (this.paint == null) { Paint localPaint1 = new Paint(); this.paint = localPaint1; this.paint.setFilterBitmap(false); Paint localPaint2 = this.paint; Xfermode localXfermode1 = MASK_XFERMODE; @SuppressWarnings("unused") Xfermode localXfermode2 = localPaint2.setXfermode(localXfermode1); } float f1 = getWidth(); float f2 = getHeight(); int i = paramCanvas.saveLayer(0.0F, 0.0F, f1, f2, null, 31); int j = getWidth(); int k = getHeight(); localDrawable.setBounds(0, 0, j, k); localDrawable.draw(paramCanvas); if ((this.mask == null) || (this.mask.isRecycled())) { Bitmap localBitmap1 = createMask(); this.mask = localBitmap1; } Bitmap localBitmap2 = this.mask; Paint localPaint3 = this.paint; paramCanvas.drawBitmap(localBitmap2, 0.0F, 0.0F, localPaint3); paramCanvas.restoreToCount(i); return; } catch (Exception localException) { StringBuilder localStringBuilder = new StringBuilder() .append("Attempting to draw with recycled bitmap. View ID = "); System.out.println("localStringBuilder=="+localStringBuilder); } }
Example #6
Source File: Spans.java From Pioneer with Apache License 2.0 | 5 votes |
@Override public void draw(@NonNull Rect outRect, @NonNull Canvas canvas, CharSequence text, @IntRange(from = 0) int start, @IntRange(from = 0) int end, float x, int top, int y, int bottom, @NonNull Paint paint) { if (bitmap == null) { bitmap = Bitmap.createBitmap(frame.right - frame.left, frame.bottom - frame.top, Bitmap.Config.ARGB_8888); bitmapCanvas = new Canvas(bitmap); } bitmapCanvas.drawColor(Color.BLACK, PorterDuff.Mode.CLEAR); bitmapCanvas.translate(-x, 0); super.draw(outRect, bitmapCanvas, text, start, end, x, top, y, bottom, paint); Xfermode oldXfermode = paint.getXfermode(); paint.setXfermode(this.xfermode); srcGroup.draw(outRect, bitmapCanvas, text, start, end, x, top, y, bottom, paint); paint.setXfermode(oldXfermode); canvas.drawBitmap(bitmap, x, 0, null); }
Example #7
Source File: ColorHelper.java From Noyze with Apache License 2.0 | 5 votes |
@SuppressWarnings("unused") public static void setXfermode(ImageView icon, Xfermode mode) { try { // Try to load/ cache the xfermode method. if (null == xfremode) { xfremode = ImageView.class.getDeclaredMethod("setXfermode", Xfermode.class); if (null != xfremode) xfremode.setAccessible(true); } if (null != xfremode) xfremode.invoke(icon, mode); } catch (Throwable t) { LogUtils.LOGE("ColorHelper", "Error with ImageView#setXfermode", t); } }
Example #8
Source File: Spans.java From Pioneer with Apache License 2.0 | 5 votes |
@Override public void draw(@NonNull Rect outRect, @NonNull Canvas canvas, CharSequence text, @IntRange(from = 0) int start, @IntRange(from = 0) int end, float x, int top, int y, int bottom, @NonNull Paint paint) { if (bitmap == null) { bitmap = Bitmap.createBitmap(frame.right - frame.left, frame.bottom - frame.top, Bitmap.Config.ARGB_8888); bitmapCanvas = new Canvas(bitmap); } bitmapCanvas.drawColor(Color.BLACK, PorterDuff.Mode.CLEAR); bitmapCanvas.translate(-x, 0); super.draw(outRect, bitmapCanvas, text, start, end, x, top, y, bottom, paint); Xfermode oldXfermode = paint.getXfermode(); paint.setXfermode(this.xfermode); srcGroup.draw(outRect, bitmapCanvas, text, start, end, x, top, y, bottom, paint); paint.setXfermode(oldXfermode); canvas.drawBitmap(bitmap, x, 0, null); }
Example #9
Source File: CiPaint.java From cidrawing with Apache License 2.0 | 5 votes |
private Xfermode getXfermodeFromInt(int mode) { if (mode < 0) { return null; } else { PorterDuffXfermode xfermode = new PorterDuffXfermode(PorterDuff.Mode.values()[mode]); return xfermode; } }
Example #10
Source File: MaskedImageView.java From monolog-android with MIT License | 5 votes |
protected void onDraw(Canvas paramCanvas) { Drawable localDrawable = getDrawable(); if (localDrawable == null) return; try { if (this.paint == null) { Paint localPaint1 = new Paint(); this.paint = localPaint1; this.paint.setFilterBitmap(false); Paint localPaint2 = this.paint; Xfermode localXfermode1 = MASK_XFERMODE; @SuppressWarnings("unused") Xfermode localXfermode2 = localPaint2.setXfermode(localXfermode1); } float f1 = getWidth(); float f2 = getHeight(); int i = paramCanvas.saveLayer(0.0F, 0.0F, f1, f2, null, 31); int j = getWidth(); int k = getHeight(); localDrawable.setBounds(0, 0, j, k); localDrawable.draw(paramCanvas); if ((this.mask == null) || (this.mask.isRecycled())) { Bitmap localBitmap1 = createMask(); this.mask = localBitmap1; } Bitmap localBitmap2 = this.mask; Paint localPaint3 = this.paint; paramCanvas.drawBitmap(localBitmap2, 0.0F, 0.0F, localPaint3); paramCanvas.restoreToCount(i); return; } catch (Exception localException) { StringBuilder localStringBuilder = new StringBuilder() .append("Attempting to draw with recycled bitmap. View ID = "); System.out.println("localStringBuilder=="+localStringBuilder); } }
Example #11
Source File: XulGIFDecoder.java From starcor.xul with GNU Lesser General Public License v3.0 | 5 votes |
public void draw(Canvas canvas, int x1, int y1, int w1, int h1, float x2, float y2, float w2, float h2, Paint p) { if (!_isCurrentFrameDecoded) { decodeFrame(); } canvas.save(); Xfermode xfermode = p.setXfermode(_colorKeyXferMode); XulDC.drawBitmap(canvas, _frameImage, x1, y1, w1, h1, x2, y2, w2, h2, p); p.setXfermode(xfermode); canvas.restore(); }
Example #12
Source File: ImageView.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * @hide Candidate for future API inclusion */ public final void setXfermode(Xfermode mode) { if (mXfermode != mode) { mXfermode = mode; mColorMod = true; applyColorMod(); invalidate(); } }
Example #13
Source File: CornerDrawable.java From ProjectX with Apache License 2.0 | 4 votes |
@Override public void draw(Canvas canvas) { if (mPath.isEmpty()) return; final int[] state = getState(); if (mStrokeColor == null) { mPaint.setColor(DrawableHelper.getColor(mFillColor, state, mAlpha)); mPaint.setStyle(Paint.Style.FILL); canvas.drawPath(mPath, mPaint); return; } final int fillColor = DrawableHelper.getColor(mFillColor, state, mAlpha); final int strokeColor = DrawableHelper.getColor(mStrokeColor, state, mAlpha); if (fillColor == strokeColor) { mPaint.setColor(fillColor); mPaint.setStyle(Paint.Style.FILL_AND_STROKE); canvas.drawPath(mPath, mPaint); } else { if (mClipFill) { final Rect bounds = getBounds(); final int layer = Compat.saveLayer(canvas, bounds.left, bounds.top, bounds.right, bounds.bottom, null); mPaint.setColor(fillColor); mPaint.setStyle(Paint.Style.FILL); canvas.drawPath(mPath, mPaint); if (mXfermode == null) mXfermode = new PorterDuffXfermode(PorterDuff.Mode.CLEAR); final Xfermode old = mPaint.getXfermode(); mPaint.setXfermode(mXfermode); mPaint.setColor(Color.BLACK); mPaint.setStyle(Paint.Style.STROKE); canvas.drawPath(mPath, mPaint); mPaint.setXfermode(old); canvas.restoreToCount(layer); mPaint.setColor(strokeColor); canvas.drawPath(mPath, mPaint); } else { mPaint.setColor(fillColor); mPaint.setStyle(Paint.Style.FILL); canvas.drawPath(mPath, mPaint); mPaint.setColor(strokeColor); mPaint.setStyle(Paint.Style.STROKE); canvas.drawPath(mPath, mPaint); } } }
Example #14
Source File: PathDrawable.java From ProjectX with Apache License 2.0 | 4 votes |
@Override public void draw(@SuppressWarnings("NullableProblems") Canvas canvas) { if (!isVisible()) return; final int[] state = getState(); if (mBackgroundColor != null) { mPaint.setStyle(Paint.Style.FILL); mPaint.setColor(mBackgroundColor.getColorForState(state, mBackgroundColor.getDefaultColor())); canvas.drawRect(getBounds(), mPaint); } if (mDrawPath.isEmpty()) return; switch (mStyle) { default: case FILL: { mPaint.setColor(DrawableHelper.getColor(mFillColor, state, mAlpha)); mPaint.setStyle(Paint.Style.FILL); canvas.drawPath(mDrawPath, mPaint); } break; case STROKE: { mPaint.setColor(DrawableHelper.getColor(mStrokeColor, state, mAlpha)); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(computeStrokeWidth()); canvas.drawPath(mDrawPath, mPaint); } break; case FILL_AND_STROKE: { final int fillColor = DrawableHelper.getColor(mFillColor, state, mAlpha); final int strokeColor = DrawableHelper.getColor(mStrokeColor, state, mAlpha); if (fillColor == strokeColor) { mPaint.setColor(fillColor); mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setStrokeWidth(computeStrokeWidth()); canvas.drawPath(mDrawPath, mPaint); } else { final float strokeWidth = computeStrokeWidth(); if (mClipFill) { final Rect bounds = getBounds(); final int layer = Compat.saveLayer(canvas, bounds.left, bounds.top, bounds.right, bounds.bottom, null); mPaint.setColor(fillColor); mPaint.setStyle(Paint.Style.FILL); canvas.drawPath(mDrawPath, mPaint); if (mXfermode == null) mXfermode = new PorterDuffXfermode(PorterDuff.Mode.CLEAR); final Xfermode old = mPaint.getXfermode(); mPaint.setXfermode(mXfermode); mPaint.setColor(Color.BLACK); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(strokeWidth); canvas.drawPath(mDrawPath, mPaint); mPaint.setXfermode(old); canvas.restoreToCount(layer); mPaint.setColor(strokeColor); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(strokeWidth); canvas.drawPath(mDrawPath, mPaint); } else { mPaint.setColor(fillColor); mPaint.setStyle(Paint.Style.FILL); canvas.drawPath(mDrawPath, mPaint); mPaint.setColor(strokeColor); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(strokeWidth); canvas.drawPath(mDrawPath, mPaint); } } } break; } }
Example #15
Source File: BasePXPaint.java From pixate-freestyle-android with Apache License 2.0 | 4 votes |
public void setBleningMode(Xfermode mode) { blendingMode = mode; }
Example #16
Source File: BasePXPaint.java From pixate-freestyle-android with Apache License 2.0 | 4 votes |
public Xfermode getBleningMode() { return blendingMode; }
Example #17
Source File: PXPaint.java From pixate-freestyle-android with Apache License 2.0 | 2 votes |
/** * Sets the blend mode to use when applying this fill */ void setBleningMode(Xfermode mode);
Example #18
Source File: PXPaint.java From pixate-freestyle-android with Apache License 2.0 | 2 votes |
/** * Returns the blend mode to use when applying this fill. * * @return {@link Xfermode} May be <code>null</code> */ Xfermode getBleningMode();