2

I'm working on an android application, and I have a drawable that I'm loading up from a source image. On this image i want make a image blur and embross ,i have read How to change colors of a Drawable in Android?

can you give me some advice?thank you

edit:i have emboss an image,but i cannot blue an image,can you give me some blue

Community
  • 1
  • 1
pengwang
  • 19,536
  • 34
  • 119
  • 168

3 Answers3

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

this only emboss a pic

pengwang
  • 19,536
  • 34
  • 119
  • 168
1

I think you are probably looking for something like this: http://code.google.com/p/jjil/

sparkymat
  • 9,938
  • 3
  • 30
  • 48
0
paint.setColorFilter( <LightingColorFilter> );
Luke
  • 11,426
  • 43
  • 60
  • 69
mbarnes
  • 455
  • 2
  • 7
  • You will find emboss, and a bunch of other goodies in Paint. All very easy once you play with it a little. – mbarnes Jul 19 '11 at 08:13
  • yes,i have test this method,but the blue effect is not obvious,so i give up the method . thank you – pengwang Jul 19 '11 at 08:19