1

I'm trying to draw the contour of my drawable,
I tried to use Blur, as in this page:
How to make glow effect around a bitmap?
Its effect is not what I want,
I want a "solid" contour,
not blurred.

anyone knows how?

Community
  • 1
  • 1
user538565
  • 513
  • 1
  • 6
  • 21
  • Have you tried Blur.SOLID, here is an example: http://about-android.blogspot.com/2010/07/2d-graphics-with-effects_11.html – Lumis Jul 20 '11 at 17:01
  • I have, and it made my image all white, as you can see in page you suggested. "Blur.SOLID" doesn't create a contour – user538565 Jul 21 '11 at 10:56

1 Answers1

3

There is no outline type filter or mask that I can find, while blur and shadow mask are not very strong. Hence you could create your own effect by using color filter and scale. This example would create a red contour

ColorFilter filter;
filter = new PorterDuffColorFilter(0xFFFF0000, PorterDuff.Mode.SRC_IN);         

paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColorFilter(filter);

canvas.save();
canvas.scale(1.1f, 1.1f,imageCenterX , imageCenterY);
canvas.drawBitmap(image, imageX, imageY, paint);
canvas.restore();

canvas.drawBitmap(image, imageX, imageY, null);

It is fast enough for a game frame animation, I've tested it.

Lumis
  • 21,517
  • 8
  • 63
  • 67