use of android.graphics.PaintFlagsDrawFilter in project FlowingDrawer by mxn21.
the class BuildLayerFrameLayout method dispatchDraw.
@Override
protected void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
if (mChanged && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
post(new Runnable() {
@Override
public void run() {
if (mAttached && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
final int layerType = getLayerType();
// If it's already a hardware layer, it'll be built anyway.
if (layerType != LAYER_TYPE_HARDWARE || mFirst) {
mFirst = false;
setLayerType(LAYER_TYPE_HARDWARE, null);
buildLayer();
setLayerType(LAYER_TYPE_NONE, null);
}
}
}
});
mChanged = false;
}
PaintFlagsDrawFilter pfd = new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
canvas.setDrawFilter(pfd);
}
use of android.graphics.PaintFlagsDrawFilter in project android_frameworks_base by DirtyUnicorns.
the class DetailedWeatherView method overlay.
private Drawable overlay(Resources resources, Drawable image, String min, String max, String tempUnits) {
final Canvas canvas = new Canvas();
canvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.ANTI_ALIAS_FLAG, Paint.FILTER_BITMAP_FLAG));
final float density = resources.getDisplayMetrics().density;
final int footerHeight = Math.round(18 * density);
final int imageWidth = image.getIntrinsicWidth();
final int imageHeight = image.getIntrinsicHeight();
final TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
Typeface font = Typeface.create("sans-serif-condensed", Typeface.NORMAL);
textPaint.setTypeface(font);
textPaint.setColor(resources.getColor(R.color.omni_jaws_detailed_temperature_color));
textPaint.setTextAlign(Paint.Align.LEFT);
final int textSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 14f, resources.getDisplayMetrics());
textPaint.setTextSize(textSize);
final int height = imageHeight + footerHeight;
final int width = imageWidth;
final Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
canvas.setBitmap(bmp);
image.setBounds(0, 0, imageWidth, imageHeight);
image.draw(canvas);
String str = null;
if (max != null) {
str = min + "/" + max + tempUnits;
} else {
str = min + tempUnits;
}
Rect bounds = new Rect();
textPaint.getTextBounds(str, 0, str.length(), bounds);
canvas.drawText(str, width / 2 - bounds.width() / 2, height - textSize / 2, textPaint);
return new BitmapDrawable(resources, bmp);
}
use of android.graphics.PaintFlagsDrawFilter in project android_frameworks_base by ResurrectionRemix.
the class DetailedWeatherView method overlay.
private Drawable overlay(Resources resources, Drawable image, String min, String max, String tempUnits) {
final Canvas canvas = new Canvas();
canvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.ANTI_ALIAS_FLAG, Paint.FILTER_BITMAP_FLAG));
final float density = resources.getDisplayMetrics().density;
final int footerHeight = Math.round(18 * density);
final int imageWidth = image.getIntrinsicWidth();
final int imageHeight = image.getIntrinsicHeight();
Log.d("maxwen", "" + imageWidth + " " + imageHeight);
final TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
Typeface font = Typeface.create("sans-serif-condensed", Typeface.NORMAL);
textPaint.setTypeface(font);
textPaint.setColor(resources.getColor(R.color.omni_jaws_detailed_temperature_color));
textPaint.setTextAlign(Paint.Align.LEFT);
final int textSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 14f, resources.getDisplayMetrics());
textPaint.setTextSize(textSize);
final int height = imageHeight + footerHeight;
final int width = imageWidth;
final Bitmap bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
canvas.setBitmap(bmp);
image.setBounds(0, 0, imageWidth, imageHeight);
image.draw(canvas);
String str = null;
if (max != null) {
str = min + "/" + max + tempUnits;
} else {
str = min + tempUnits;
}
Rect bounds = new Rect();
textPaint.getTextBounds(str, 0, str.length(), bounds);
canvas.drawText(str, width / 2 - bounds.width() / 2, height - textSize / 2, textPaint);
return new BitmapDrawable(resources, bmp);
}
use of android.graphics.PaintFlagsDrawFilter in project android_frameworks_base by ResurrectionRemix.
the class PenSizeArrayAdapter method createPenSizeImae.
private ImageView createPenSizeImae(int position) {
ImageView imageView = new ImageView(getContext());
final int width = getContext().getResources().getDimensionPixelSize(R.dimen.crop_buttons);
final int contentWidth = getContext().getResources().getDimensionPixelSize(R.dimen.crop_buttons_inlet);
final int penSizeValue = Integer.valueOf(mPenSizes[position]);
final float density = getContext().getResources().getDisplayMetrics().density;
final int penSize = Math.round(penSizeValue * density);
final Canvas canvas = new Canvas();
canvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.ANTI_ALIAS_FLAG, Paint.FILTER_BITMAP_FLAG));
final Bitmap bmp = Bitmap.createBitmap(contentWidth, contentWidth, Bitmap.Config.ARGB_8888);
canvas.setBitmap(bmp);
final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.RED);
paint.setStrokeWidth(penSize);
canvas.drawLine(0, contentWidth / 2, contentWidth, contentWidth / 2, paint);
imageView.setImageDrawable(new BitmapDrawable(getContext().getResources(), bmp));
AbsListView.LayoutParams params = new AbsListView.LayoutParams(width, width);
imageView.setLayoutParams(params);
imageView.setScaleType(ScaleType.CENTER);
return imageView;
}
use of android.graphics.PaintFlagsDrawFilter in project android_frameworks_base by ResurrectionRemix.
the class ScreenshotEditor method createPenSizeImage.
private BitmapDrawable createPenSizeImage(int penSize) {
final int width = getResources().getDimensionPixelSize(R.dimen.crop_buttons_inlet);
final Canvas canvas = new Canvas();
canvas.setDrawFilter(new PaintFlagsDrawFilter(Paint.ANTI_ALIAS_FLAG, Paint.FILTER_BITMAP_FLAG));
final Bitmap bmp = Bitmap.createBitmap(width, width, Bitmap.Config.ARGB_8888);
canvas.setBitmap(bmp);
final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.BLACK);
paint.setStrokeWidth(penSize);
canvas.drawLine(0, width / 2, width, width / 2, paint);
return new BitmapDrawable(getResources(), bmp);
}
Aggregations