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)));
}
use of android.graphics.PorterDuffXfermode in project smartmodule by carozhu.
the class Bitmaputil method getCroppedBitmap.
/**
* @param bitmap
* @return 返回一个圆型图片 应用场景:当你的ImageView/view 想要为它设置一张圆形图片时
*/
public static Bitmap getCroppedBitmap(Bitmap bitmap) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
// 设置一个图片大小的矩形
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
// bm是一个刚好canvas大小的空Bitmap ,画完后应该会自动保存到bm
Canvas canvas = new Canvas(output);
final Paint paint = new Paint();
paint.setAntiAlias(true);
int halfWidth = bitmap.getWidth() / 2;
int halfHeight = bitmap.getHeight() / 2;
// 画圆
canvas.drawCircle(halfWidth, halfHeight, Math.max(halfWidth, halfHeight), paint);
// 设置为取两层图像交集部门,只显示上层图像
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
// Mode -设置Mode模式可以画出一些常见的模型
// paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
// 画图像
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
use of android.graphics.PorterDuffXfermode in project android_frameworks_base by crdroidandroid.
the class ImageHelper method getRoundedCornerBitmap.
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) {
if (bitmap == null) {
return null;
}
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 = 24;
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;
}
use of android.graphics.PorterDuffXfermode in project smartmodule by carozhu.
the class RoundRectangleImageView method getRoundBitmap.
/**
* 获取圆角矩形图片方法
*
* @param bitmap
* @param roundPx
* ,一般设置成14
* @return Bitmap
*/
private Bitmap getRoundBitmap(Bitmap bitmap, int roundPx) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
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);
int x = bitmap.getWidth();
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
use of android.graphics.PorterDuffXfermode in project android_frameworks_base by AOSPA.
the class UserIconDrawable method setBadge.
public UserIconDrawable setBadge(Drawable badge) {
mBadge = badge;
if (mBadge != null) {
if (mClearPaint == null) {
mClearPaint = new Paint();
mClearPaint.setAntiAlias(true);
mClearPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
mClearPaint.setStyle(Paint.Style.FILL);
}
// update metrics
onBoundsChange(getBounds());
} else {
invalidateSelf();
}
return this;
}
Aggregations