OfImage and PNG

Hello, and happy coding !

I’m trying to integrate some little PNG, in my sketch, but i’m a little bit lost :
There is a transparent background on my PNG image, but it began black in OF ?

Can you give me a hand about this ? :frowning:

you have to set ofEnableAlphaBlending();

I did it but my ofimage always have a black background. I draw them with illustrator, and export them in PNG, with the transparent background, so it’s not a software problem… i think… :


MenuBar.draw(0, ofGetHeight()-71, ofGetWidth(), 71);


if (OrthoG) {
    MenubarTextOrtho.draw(ofGetWidth()/2 - 40, ofGetHeight() - 200);

} else {
    MenuText.draw(ofGetWidth()/2 - 40, ofGetHeight() - 200 );



Have you checked what type of image your MenuBar is after you load it? If you print it out using cout << MenuBar.type << endl, does it print out 2?

1 Like

also try


you might not exporting the alpha channel from illustrator, can you share the image you are using with us?

1 Like

Yep, it replies 2. why ?

And here is the image, alpha channel in illustrator… what do you mean, transparent background ?


ofImage.type (documentation page) will say how the image is being interpreted when openFrameworks loads it. A value of 2 (the value of the constant OF_IMAGE_COLOR_ALPHA) means that the image is being read as having R, G, B and A channels. So that checks out.

Your image loads fine for me:

ofBackground(255, 255, 0);


ofImage img;
img.draw(0, ofGetHeight()-71, ofGetWidth(), 71);

Are you perhaps setting your background color to black by doing something like: ofBackground(0, 0, 0)?

Hello !
I did it, maybe it is because it’s in a class… but i don’t do nothing about this image in the ofApp (only Act.draw()), i also use “push style” and “pop style” to be sure.

But i have the same problem. Do you think i can change the image type ? :frowning:

What did you do? You ran the code that I posted, and it worked for you?

This shouldn’t affect the alpha channel, but ofSetColor(...) will tint images, so you can can ofSetColor(255) before drawing the image.

Is your code on github or posted somewhere so that we can see more of what you are doing?