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

StackOverflow https://stackoverflow.com/questions/16292146

Domanda

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,

È stato utile?

Soluzione 3

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

Altri suggerimenti

You can also try this project it handle a number of Bitmap Processing

Filters :-

  • Boost-Up Colors
  • Brightness
  • Color Depth
  • Color Filter
  • Contrast
  • Emboss
  • Flip and Rotation
  • Gamma
  • Gaussian Blur
  • Grayscale
  • Hue
  • Invert
  • Noise
  • Saturation
  • Sepia
  • Sharpen
  • Sketch
  • Tint
  • Vignette

Since it is in Java and does pixel label processing, it is not as fast as most C++ based library out there but it work great if bitmap size is not very big eg thumbnails.

This is an excellent Library, easy to integrate with gradle, It is Fast and efficent and saved my day:

https://github.com/wasabeef/picasso-transformations

this is an example of how it's use:

 Transformation trans1 = new ContrastFilterTransformation(getActivity(), 1.5f);
 Transformation trans2 = new BrightnessFilterTransformation(getActivity(), 0.2f);
 Picasso.with(getActivity()).load(uri)
        .transform(trans1).transform(trans2).into(imageview3);

You can use Catalano Framework:

http://code.google.com/p/catalano-framework/

FastBitmap image = new FastBitmap(bitmap);
image.toRGB();

//Sepia
Sepia sepia = new Sepia();
sepia.applyInPlace(image);

//Blur
Blur blur = new Blur();
blur.applyInPlace(image);

//Emboss
Emboss emboss = new Emboss();
emboss.applyInPlace(image);

//Retrieve bitmap
bitmap = fb.toBitmap();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top