use of android.graphics.PorterDuffXfermode in project LikeAnimation by frogermcs.
the class CircleView method init.
private void init() {
circlePaint.setStyle(Paint.Style.FILL);
maskPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
}
use of android.graphics.PorterDuffXfermode in project WordPress-Android by wordpress-mobile.
the class ImageUtils method getRoundedEdgeBitmap.
/**
* Returns the passed bitmap with rounded corners
* @param bitmap - the bitmap to modify
* @param radius - the radius of the corners
* @param borderColor - the border to apply (use Color.TRANSPARENT for none)
*/
public static Bitmap getRoundedEdgeBitmap(final Bitmap bitmap, int radius, int borderColor) {
if (bitmap == null) {
return null;
}
final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
final 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(Color.RED);
canvas.drawRoundRect(rectF, radius, radius, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
if (borderColor != Color.TRANSPARENT) {
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(1f);
paint.setColor(borderColor);
canvas.drawRoundRect(rectF, radius, radius, paint);
}
return output;
}
use of android.graphics.PorterDuffXfermode in project ZI by yixia.
the class BitmapHelper method getRoundedCornerBitmap.
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, float radius) {
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);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, radius, radius, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
use of android.graphics.PorterDuffXfermode in project PhotoNoter by yydcdut.
the class RoundedImageView method getCroppedBitmap.
public static Bitmap getCroppedBitmap(Bitmap bmp, int radius) {
Bitmap sbmp;
if (bmp.getWidth() != radius || bmp.getHeight() != radius) {
sbmp = Bitmap.createScaledBitmap(bmp, radius, radius, false);
} else {
sbmp = bmp;
}
Bitmap output = Bitmap.createBitmap(sbmp.getWidth(), sbmp.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, sbmp.getWidth(), sbmp.getHeight());
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
paint.setDither(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(Color.parseColor("#BAB399"));
canvas.drawCircle(sbmp.getWidth() / 2 + 0.7f, sbmp.getHeight() / 2 + 0.7f, sbmp.getWidth() / 2 + 0.1f, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(sbmp, rect, rect, paint);
return output;
}
use of android.graphics.PorterDuffXfermode in project weiciyuan by qii.
the class ImageEditUtility method getRoundedCornerBitmap.
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int cornerRadius) {
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);
final float roundPx = cornerRadius;
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);
bitmap.recycle();
return output;
}
Aggregations