Showing posts with label black. Show all posts
Showing posts with label black. Show all posts

Sunday, 21 April 2013

Gray Scale Photo Effect for android


Please use below class and pass the bitmap to this function and get return bitmap with gray scale effect.


public class GrayFilter {
     
      //   satutarion --- 1.0 , 0.5 and 0
     
      public static Bitmap changeToGray(Bitmap bitmap) {
            return changeToGray(bitmap, 0);
      }
     
      public static Bitmap changeToGray(Bitmap bitmap,float sat) {
            int width, height;
            width = bitmap.getWidth();
            height = bitmap.getHeight();
                 
            Bitmap grayBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
            Canvas canvas = new Canvas(grayBitmap);
            Paint paint = new Paint();
            paint.setAntiAlias(true);
                 
            ColorMatrix colorMatrix = new ColorMatrix();
            colorMatrix.setSaturation(sat);
                 
            ColorMatrixColorFilter filter = new ColorMatrixColorFilter(colorMatrix);
                 
            paint.setColorFilter(filter);
            canvas.drawBitmap(bitmap, 0, 0, paint);
                 
            return grayBitmap;
      }
}


By: NovaRadix Technology.



Call web services easily

get source code from here, Download