Tint Images

All your problems with Audio, Video and Images.

Tint Images

Postby Zeba Momin » Tue Jan 19, 2010 7:01 am

Hello all
In my android application... i need to give background image to a LinearLayout which is slightly tinted in black.
I hav dis image without the tint. Is there any way i can giv a slight black tint to that image in android?
Wat i hav tried is:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.   ivCoverArt = (ImageView) this.findViewById(R.id.coverart);
  2.  
  3.  ivCoverArt.setImageBitmap(bmCoverArt);
  4.  
  5.  PorterDuffColorFilter Black = new PorterDuffColorFilter(Color.BLACK,PorterDuff.Mode.LIGHTEN);
  6.  
  7.  ivCoverArt.getBackground().setColorFilter(Black);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

Here i hav tried to jst giv black tint to an ImageView...but dis makes no effect!!!
Can sumone plzz help me wid dis?
Thank you
Zeba Momin
Developer
Developer
 
Posts: 49
Joined: Thu Sep 17, 2009 6:53 am

Top

Re: Tint Images

Postby pskink » Tue Jan 19, 2010 12:17 pm

Zeba Momin wrote: PorterDuffColorFilter Black = new PorterDuffColorFilter(Color.BLACK,PorterDuff.Mode.LIGHTEN);
ivCoverArt.getBackground().setColorFilter(Black); [/syntax]
Here i hav tried to jst giv black tint to an ImageView...but dis makes no effect!!!
Can sumone plzz help me wid dis?
Thank you


use Mode.SRC_ATOP and some alpha instead of Color.BLACK, e.g. 0x40000000

pskink
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Postby Zeba Momin » Tue Jan 19, 2010 12:35 pm

Thank you for replying
I tried now
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ivCoverArt = (ImageView) this.findViewById(R.id.coverart);
  2.  
  3.                         ivCoverArt.setImageBitmap(bmCoverArt);
  4.  
  5.                         PorterDuffColorFilter Black = new PorterDuffColorFilter(
  6.  
  7.                                         0x44400000 , PorterDuff.Mode.SRC_ATOP);
  8.  
  9.                         ivCoverArt.getBackground().setColorFilter(Black);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


But again no difference made!!!
Am I right in first doing
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ivCoverArt.setImageBitmap(bmCoverArt);
Parsed in 0.033 seconds, using GeSHi 1.0.8.4

and den
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ivCoverArt.getBackground().setColorFilter(Black);
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
Zeba Momin
Developer
Developer
 
Posts: 49
Joined: Thu Sep 17, 2009 6:53 am

Postby pskink » Mon Jan 25, 2010 9:16 am

Zeba Momin wrote:Am I right in first doing
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ivCoverArt.setImageBitmap(bmCoverArt);
Parsed in 0.035 seconds, using GeSHi 1.0.8.4

and den
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ivCoverArt.getBackground().setColorFilter(Black);
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ivCoverArt.setColorFilter(Black);
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


or even easier, just:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ivCoverArt.setColorFilter(0x44400000, Mode.SRC_ATOP);
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


it creates ColorFilter behind the scene and then apply it
pskink
pskink
Master Developer
Master Developer
 
Posts: 719
Joined: Mon Nov 24, 2008 3:49 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 4 guests