Android的位图轮廓位图、轮廓、Android

2023-09-05 05:14:30 作者:壞吖頭♀

我想提请我绘制的轮廓, 我试图用模糊,如本页面: 如何使周围的位图? 光晕效果 其效果是不是我想要的, 我想要一个实的轮廓, 不模糊。 有谁知道如何?

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?

推荐答案

没有大纲式过滤器或屏蔽,我可以找到,而模糊和荫罩都不是很强。因此,你可以创建自己的效果通过使用彩色滤光片和规模。这个例子将创建一个红色的轮廓

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.