Link to home
Start Free TrialLog in
Avatar of pivar
pivarFlag for Sweden

asked on

Fade an image

Hi,

I have an image that I would like to "fade" to white. Maybe fade is not the correct term here. What I would like to do is animate a change of the colors to all white, that is, lessen the color. (Maybe this is not the correct term either. As you can see, I'm not a graphics guy.)
This would be in Android/Java.

Is this possible in code?

/peter
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

i haven't used it, but i found this
http://stackoverflow.com/questions/4533731/android-fade-effect-between-layouts

please try the same
Avatar of pivar

ASKER

I would like to apply this on an image, drawing it to the canvas myself. How would this be implemented with your solution?

thx
why don't you try to put that image inside a layout and then fade that layout instead of that image?
Avatar of pivar

ASKER

Because I want to implement this in a drawing engine which draws various types of imageobject to the same canvas, where the fader object would be one. Because of this I would like to be able to transform the image/Bitmap.
ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Member_2_5069294
Member_2_5069294

Assuming Android Canvas matches HTML5 Canvas, and you have a 2D context, then its code like this.

context.fillStyle = "white"
context.fillRect (top, left, width, height)
context.globalAlpha = ? // some amount of transparency, 1 = full opaque, 0 = full transparent
context.drawImage (image, top, left, width, height)

Open in new window

The program would change the globalAlpha value from one to zero over a time period.
Avatar of pivar

ASKER

satsumo, would that affect the whole canvas, or just my image that I'm drawing? What is meant by "Android Canvas matches HTML5 Canvas"?
Avatar of pivar

ASKER

Just to confirm that we're on the right track. It is the transparency one should change to get the impression of an image "loosing" its colors?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial