use of android.graphics.PorterDuffXfermode in project MaterialNavigationDrawer by neokree.
the class Utils method getCroppedBitmapDrawable.
public static Bitmap getCroppedBitmapDrawable(Bitmap bitmap) {
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());
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
// canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2, bitmap.getWidth() / 2, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
//return _bmp;
return output;
}
use of android.graphics.PorterDuffXfermode in project Android-Universal-Image-Loader by nostra13.
the class OldRoundedBitmapDisplayer method getRoundedCornerBitmap.
private static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int roundPixels, Rect srcRect, Rect destRect, int width, int height) {
Bitmap output = Bitmap.createBitmap(width, height, Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final Paint paint = new Paint();
final RectF destRectF = new RectF(destRect);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(0xFF000000);
canvas.drawRoundRect(destRectF, roundPixels, roundPixels, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, srcRect, destRectF, paint);
return output;
}
use of android.graphics.PorterDuffXfermode in project phonegap-plugin-push by phonegap.
the class GCMIntentService method getCircleBitmap.
private Bitmap getCircleBitmap(Bitmap bitmap) {
final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);
final Canvas canvas = new Canvas(output);
final int color = Color.RED;
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);
float cx = bitmap.getWidth() / 2;
float cy = bitmap.getHeight() / 2;
float radius = cx < cy ? cx : cy;
canvas.drawCircle(cx, cy, radius, paint);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
bitmap.recycle();
return output;
}
use of android.graphics.PorterDuffXfermode in project weiciyuan by qii.
the class ShowcaseView method setHardwareAccelerated.
public void setHardwareAccelerated(boolean accelerated) {
if (accelerated) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
if (isHardwareAccelerated()) {
Paint hardwarePaint = new Paint();
hardwarePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.OVERLAY));
setLayerType(LAYER_TYPE_HARDWARE, hardwarePaint);
} else {
setLayerType(LAYER_TYPE_SOFTWARE, null);
}
} else {
setDrawingCacheEnabled(true);
}
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
setLayerType(LAYER_TYPE_SOFTWARE, null);
} else {
setDrawingCacheEnabled(true);
}
}
}
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