Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

i want to add a color filter to the imageview

I'd like to add a ColorFilter to ImageView.

Currently I'm using:

ImageView iv = (ImageView)findViewById(resIdOfImageToFilter); iv.setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP); 

I've checked Multiple Modes in PotterDuff such as SRC_IN, SRC etc., but I'm not getting any difference in any of the modes... All mode turns the whole ImageView in perfect Red color.

I need to blend RED color in the existing image so that image will look with a REDDISH tinge....

like image 211
Shashank Degloorkar Avatar asked Nov 19 '11 10:11

Shashank Degloorkar


People also ask

What is SRC in ImageView?

android:scaleType. Controls how the image should be resized or moved to match the size of this ImageView. android:src. Sets a drawable as the content of this ImageView.

What is Imagefilterview?

An ImageView that can display, combine and filter images. Added in 2.0. Subclass of ImageView to handle various common filtering operations.


1 Answers

The right way to do it was using PorterDuff.Mode.LIGHTEN.

So the updated code will be like:

ImageView iv = (ImageView)findViewById(resIdOfImageToFilter); iv.setColorFilter(Color.RED, PorterDuff.Mode.LIGHTEN); 
like image 154
Shashank Degloorkar Avatar answered Sep 28 '22 10:09

Shashank Degloorkar