How to apply different image effects (filters) on bitmap like sepia, black and white, blur, etc.?

Nixit Patel picture Nixit Patel · Apr 30, 2013 · Viewed 34.3k times · Source

I am not having any idea of how to apply different effect on Image,

I have seen the EffectFactory class and Effect class in effect class there is one method apply but I am not sure what to pass in inputTexId and optputTexId, and from where I get the new updated image, how to store the updated image in imageView,

Please help me with how to approach this problem. Is there any opensource library available for providing effects on Image.

Thanks,

Answer

Chintan Rathod picture Chintan Rathod · Apr 30, 2013

I have implemented Jerry's Java Image Processing Library. Works fine for me.

Download AndroidJars.

Edit

Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
//Find the bitmap's width height
int width = AndroidUtils.getBitmapOfWidth(getResources(), R.drawable.ic_launcher);
int height = AndroidUtils.getBitmapOfHeight(getResources(), R.drawable.ic_launcher);
//Create a filter object.
GaussianFilter filter = new GaussianFilter();
//set???? function to specify the various settings.
filter.setRadius(8.5f);
//Change int Array into a bitmap
int[] src = AndroidUtils.bitmapToIntArray(bitmap);
//Applies a filter.
filter.filter(src, width, height);
//Change the Bitmap int Array (Supports only ARGB_8888)
Bitmap dstBitmap = Bitmap.createBitmap(src, width, height, Config.ARGB_8888);

Find more detailed information at Android-jhlabs