List of usage examples for android.graphics Paint setXfermode
public Xfermode setXfermode(Xfermode xfermode)
From source file:Main.java
/** * Changes the paint color to transparent * * @param paint the object to mutate with the new color *///from w w w . ja va 2s. c o m public static void changePaintTransparent(Paint paint) { paint.setAlpha(0x00); paint.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.CLEAR)); }
From source file:Main.java
public static void cleanCanvas(Canvas mCanvas) { if (mCanvas != null) { Paint paint = new Paint(); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); mCanvas.drawPaint(paint);//ww w . j a v a 2s . c o m paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC)); mCanvas = null; } }
From source file:Main.java
public static Bitmap combineImages(Bitmap bgd, Bitmap fg) { Bitmap bmp;//from ww w. java 2 s.c o m int width = bgd.getWidth() > fg.getWidth() ? bgd.getWidth() : fg.getWidth(); int height = bgd.getHeight() > fg.getHeight() ? bgd.getHeight() : fg.getHeight(); 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; }
From source file:Main.java
public static Bitmap combineImages(Bitmap bgd, Bitmap fg) { Bitmap bmp;// ww w .j a v a 2s. c o m int width = bgd.getWidth() > fg.getWidth() ? bgd.getWidth() : fg.getWidth(); int height = bgd.getHeight() > fg.getHeight() ? bgd.getHeight() : fg.getHeight(); bmp = Bitmap.createBitmap(width, height, Config.ARGB_8888); Paint paint = new Paint(); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP)); Canvas canvas = new Canvas(bmp); canvas.drawBitmap(bgd, 0, 0, null); canvas.drawBitmap(fg, 0, 0, paint); return bmp; }
From source file:Main.java
/** * * @return// w ww . ja v a 2 s . c o m */ public static Paint newPaint() { Paint paint = new Paint(1); paint.setFilterBitmap(true); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN)); return paint; }
From source file:Main.java
public static Bitmap createScreenshot4(View view, int thumbnailWidth, int thumbnailHeight) { if (view != null) { Bitmap mCapture;//from w w w . ja va 2 s .c o m try { mCapture = Bitmap.createBitmap(thumbnailWidth, thumbnailHeight, Bitmap.Config.RGB_565); } catch (OutOfMemoryError e) { return null; } Canvas c = new Canvas(mCapture); Paint transPainter = new Paint(); transPainter.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); c.drawRect(0, 0, mCapture.getWidth(), mCapture.getHeight(), transPainter); try { view.draw(c); } catch (Exception e) { } return mCapture; } return null; }
From source file:Main.java
public static Bitmap cropJpgFile(String inFl, String outFl) throws IOException { Bitmap bmpIn = BitmapFactory.decodeFile(inFl); Bitmap bmOverlay = Bitmap.createBitmap(bmpIn.getWidth(), bmpIn.getHeight(), Bitmap.Config.ARGB_8888); Paint p = new Paint(); p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); Canvas c = new Canvas(bmOverlay); c.drawBitmap(bmpIn, 0, 0, null);//from w ww.j a v a 2 s. c o m //c.drawRect(30, 30, 100, 100, p); File fileOut = new File(outFl); FileOutputStream out = new FileOutputStream(fileOut); bmOverlay = drawTextToBitmap(bmOverlay, "Image Viewer"); bmOverlay.compress(Bitmap.CompressFormat.JPEG, 100, out); return bmOverlay; }
From source file:Main.java
public static void erase(Canvas canvas, RectF rectf) { Paint paint = new Paint(); paint.setColor(0);/*w w w . j a v a2s. co m*/ paint.setDither(true); paint.setXfermode(new PorterDuffXfermode(android.graphics.PorterDuff.Mode.CLEAR)); canvas.drawRect(rectf, paint); }
From source file:Main.java
public static Bitmap combineImagesToSameSize(Bitmap bgd, Bitmap fg) { Bitmap bmp;// ww w. j a v a 2s .c om 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; }
From source file:Main.java
public static Bitmap punchAHoleInABitmap(Context context, Bitmap foreground, float x1, float y1) { Bitmap bitmap = Bitmap.createBitmap(foreground.getWidth(), foreground.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); canvas.drawBitmap(foreground, 0, 0, paint); paint.setAntiAlias(true);/*from w ww . j av a 2 s . c o m*/ paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); float radius = (float) (getScreenSize(context).x * .06); canvas.drawCircle(x1, y1 - 450, radius, paint); return bitmap; }