Android Blurmaskfilter Has No Effect in Canvas.Drawoval While Text Is Blurred

Android BlurMaskFilter has no effect in canvas.drawOval while text is blurred

Looks like a bug to me. I reported it to the Android team; we'll see what they say.

It renders correctly if you set android:hardwareAccelerated="false" on your Activity in AndroidManifest.xml.

Here is the official word from the Android graphics team:
"BlurMaskFilter is not supported with hardware acceleration."
(As of July 10, 2012)

Android canvas circle color blur

use AntiAlias property for Paint. it protect the image from blurring and gives smoothing edges

debug = new Paint();
debug.setAntiAlias(true);
debug.setColor(Color.RED);

Dynamically generated line with glow effective

I imitate this effect in this way :

  1. Draw line with BlurMaskFilter;
  2. Draw over it normal line.

I use Path class to generate line and save coordinates of MOVE_ACTION event to generate only part of path what i need.

Create 2 Paint()s:

_paintSimple = new Paint();
_paintSimple.setAntiAlias(true);
_paintSimple.setDither(true);
_paintSimple.setColor(Color.argb(248, 255, 255, 255));
_paintSimple.setStrokeWidth(20f);
_paintSimple.setStyle(Paint.Style.STROKE);
_paintSimple.setStrokeJoin(Paint.Join.ROUND);
_paintSimple.setStrokeCap(Paint.Cap.ROUND);

_paintBlur = new Paint();
_paintBlur.set(_paintSimple);
_paintBlur.setColor(Color.argb(235, 74, 138, 255));
_paintBlur.setStrokeWidth(30f);
_paintBlur.setMaskFilter(new BlurMaskFilter(15, BlurMaskFilter.Blur.NORMAL));

And draw twice my Path():

@Override
protected void onDraw(Canvas canvas) {
canvas.drawPath(mPath, _paintBlur);
canvas.drawPath(mPath, _paintSimple);
}

Android 4.2 on Nexus 7: canvas.drawText() not working correctly

I answer my own question after a lot of googling...

The trick consist in the use of setLinearText(true) for the Paint object used for drawing the text. Now, everything looks great.

paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(color);
paint.setTextSize(size);
paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
paint.setTextAlign(Align.CENTER);
paint.setLinearText(true);

Here the link that saves my day:

http://gc.codehum.com/p/android/issues/detail?id=39755

I hope it can help someonelse.

The text is not rendered at the best yet:

Sample Image

Edited (14/01/2013)

I'm still facing a kering problem (only on 4.2.1). Please see my other question here:

Android 4.2.1 wrong character kerning (spacing)

Edited (05/02/2013)

I see another projects has the same problem. Look at the link below:

http://mindtherobot.com/blog/272/android-custom-ui-making-a-vintage-thermometer/

If you run the sample on Nexus 4.2.1 (or in the simulator Android 4.2) you get the same "strange" text...

Edited (20/02/2013)

Found a workaround that not uses setLinearText(true), look here:

Android 4.2.1 wrong character kerning (spacing)

canvas.drawCircle does not work - while drawLine works - might be caused by using Sherlock?

almost unbelieveble but true, just change the target setting (or remove it alltogether) and it will work - it did in my case :-)



Related Topics



Leave a reply



Submit