模糊和浮雕图像

时间:2011-07-18 05:15:36

标签: android image colors

我正在开发一个Android应用程序,我有一个可绘制的,我正在从源图像加载。在这张图片上,我想让图像变得模糊不清,我已阅读How to change colors of a Drawable in Android?

你可以给我一些建议吗?谢谢

编辑:我已经压印了一张图片,但是我不能将图像变蓝,你能不能给我一些蓝色

3 个答案:

答案 0 :(得分:2)

 public Bitmap fudiao(Bitmap bmpOriginal) {
    int width, height, r,g, b, c,a, gry,c1,a1,r1,g1,b1,red,green,blue; 
    height = bmpOriginal.getHeight(); 
    width = bmpOriginal.getWidth(); 
    int depth = 30;

      Bitmap bmpSephia = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bmpSephia);
        Paint paint = new Paint();
      //  ColorMatrix cm = new ColorMatrix();
      //  cm.setScale(.3f, .3f, .3f, 1.0f);   
      //  ColorMatrixColorFilter f = new ColorMatrixColorFilter(cm);
      //  paint.setColorFilter(f);
       canvas.drawBitmap(bmpOriginal, 0, 0, null);
        for(int y=1; y< height-1; y++) {
            for(int x=1; x < width-1; x++) {
                c = bmpOriginal.getPixel(x, y);

                r = Color.red(c);
                g = Color.green(c);
                b = Color.blue(c);

                c1 = bmpOriginal.getPixel(x-1, y-1);

                r1 = Color.red(c1);
                g1 = Color.green(c1);
                b1 = Color.blue(c1);


                red = Math.max(67, Math.min(255, Math.abs(r - r1 + 128)));
                green = Math.max(67, Math.min(255, Math.abs(g - g1 + 128)));
                blue = Math.max(67, Math.min(255, Math.abs(b - b1 + 128))); 
                if (red > 255)
                {
                    red = 255;
                }
                else if (red < 0)
                {
                    red = 0;
                }

                if (green > 255)
                {
                    green = 255;
                }
                else if (green < 0)
                {
                    green = 0;
                }

                if (blue > 255)
                {
                    blue = 255;
                }
                else if (blue < 0)
                {
                    blue = 0;
                }

               bmpSephia.setPixel(x, y, Color.rgb(red, green, blue));
               // bmpSephia.setPixel(x, y, Color.argb(a1, red, green, blue));
            }
        }      
        return bmpSephia;
    }

这只是浮雕图片

答案 1 :(得分:1)

我想你可能正在寻找这样的东西:http://code.google.com/p/jjil/

答案 2 :(得分:0)

paint.setColorFilter( <LightingColorFilter> );