A very short method to change a bitmap object’s opacity. The opacity value should be in the 0-255 range.

This method places a centered text on top of a bitmap object. You can modify the method to add parameters like a custom color, alignment or others.

The best code in Android that worked for me in converting a colored Bitmap to gray scale is this one.

Notice that before the object is returned, I added two lines of code src.recycle() and src = null? This is to ensure that the non-used Bitmap object will be recycled to help avoid OutOfMemory exception errors.

Now, this is a necessity because unless you restrict your app to only run in smart phones with large RAM, you have to take this into account in order for your app to run seamlessly on smart phones that do not have have large amounts of RAM.

Related Posts Plugin for WordPress, Blogger...