【问题标题】:Android Bitmap contourAndroid 位图轮廓
【发布时间】:2011-07-20 15:27:27
【问题描述】:

我正在尝试绘制可绘制对象的轮廓,
我尝试使用模糊,如在此页面中:
How to make glow effect around a bitmap?
它的效果不是我想要的,
我想要一个“实心”轮廓,
不模糊。

有人知道怎么做吗?

【问题讨论】:

  • 你试过 Blur.SOLID,这里是一个例子:about-android.blogspot.com/2010/07/…
  • 我有,它使我的图像全白,正如您在建议的页面中看到的那样。 “Blur.SOLID”不会创建轮廓

标签: android contour


【解决方案1】:

我找不到轮廓类型的滤镜或蒙版,而模糊和阴影蒙版不是很强大。因此,您可以使用滤色器和比例创建自己的效果。这个例子将创建一个红色轮廓

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);

对于游戏帧动画来说已经足够快了,我已经测试过了。

【讨论】:

    猜你喜欢
    • 2012-01-04
    • 1970-01-01
    • 2014-11-21
    • 2021-01-05
    • 1970-01-01
    • 1970-01-01
    • 2012-11-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多