Fade out for an ofImage?

Hello again! =D

I’m writing some code in order to make an ofImage (PNG with alpha channel) appear on screen while moving and then just disappear as if it was faded out.
I already have the code running doing a ofSetBackgroundAuto(false) and drawing a rectangle with a very low alpha channel value, but it has limited functionality and I end up having a background with black colors and “not so black” bits and lines" that are very noticeable in high contrast situations.

So, any way to have an ofImage (PNG with alpha channel), and have an alpha channel value added to it incrementally in order for it to “fade to black”?.
Or maybe some other trick?

thanks you very much. :smiley:

Hi,

did you try it like this?

void testApp::setup(){
int appear = 0; // (0-255)

}

void testApp::update(){
appear++;
}

void testApp::draw(){
ofSetupScreen();
ofEnableAlphaBlending();
ofSetColor(255, 255, 255, appear);
pic1.draw(0,0);
ofDisableAlphaBlending();
}

Maybe you can post your example code if this doesn’t help.

K.

:smiley:

Whoa!
I didn’t really know one could do that.
So it really did work, only problem is the PNG has trasparency but now it displays that portion of the image as if it were white instead of transparent. But I do get the fading effect I wanted.

I think the odd white pixels won’t matter that much since in my example the background is blank. Even so, I think I read something about that somewhere in the forum.

Thank you veyr mucho ketchupok!!
=D

Edit-------------------
I was wrong, it does work but the weird pixels which should be alpha in the PNG now display as white, forming a square. Is there any way to fix that?
or maybe a way to set those pixels to be always transparent?

no wait, wait… now it works perfectly, I actually finished the program and your method works great, but now I am confused. Might the white color appearing in the alpha valued pixels be a bug or something?
How can I predict if the code will work or not if something like this happens?
has anyone had a similar problem?

thanks anyways :smiley: works great!