如何围绕位图制作外部发光效果?

时间:2012-10-10 09:30:44

标签: android blur glow

我为我的位图imageview创建了发光效果。它的工作,但我有外部发光颜色的问题。

这是我期望的设计外发光颜色:

http://www.flashcomponents.net/component/professional-3d-carousel-as2-and-as3.html请参阅链接

但是我的发光效果看起来不太好请帮助我如何使预期的发光效果? 这是我的代码:

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        int margin = 24;
        int halfMargin = margin / 2;

        // the glow radius
        int glowRadius = 16;

        // the glow color
        int glowColor = Color.rgb(0, 192, 255);

        // The original image to use
        Bitmap src = BitmapFactory.decodeResource(getResources(),
                R.drawable.ic_launcher);

        // extract the alpha from the source image
        Bitmap alpha = src.extractAlpha();

        // The output bitmap (with the icon + glow)
        Bitmap bmp = Bitmap.createBitmap(src.getWidth() + margin,
                src.getHeight() + margin, Bitmap.Config.ARGB_8888);

        // The canvas to paint on the image
        Canvas canvas = new Canvas(bmp);

        Paint paint = new Paint();
        paint.setColor(glowColor);

        // outer glow
        paint.setMaskFilter(new BlurMaskFilter(glowRadius, Blur.OUTER));
        canvas.drawBitmap(alpha, halfMargin, halfMargin, paint);

        // original icon
        canvas.drawBitmap(src, halfMargin, halfMargin, null);

        ((ImageView) findViewById(R.id.bmpImg)).setImageBitmap(bmp);

    }


}

我是android新手,我只需要编程......

enter image description here

我在imageview背面的预期发光请看我预期的屏幕截图: enter image description here

0 个答案:

没有答案
相关问题