OF_ERROR: Couldn't load image. Help?

Hi, I’m a Processing enthusiast new to oF and trying to get some basic stuff working. I am stuck trying to load an image— how basic can we get?

Header has:

  
ofImage _image;  

Then, in my setup() I have:

  
_image.loadImage("circle.png");  

Which compiles fine, but then I get at runtime:

  
OF_ERROR: Couldn't load image from circle.png  
OF_ERROR: getTextureData() - texture has not been allocated  

What gives? I’ve tried all sorts of path-messing-about, making sure the circle.png file is in fact in my Xcode project, etc. Is there something I have to do to prepare the ofImage before loading something? I looked into the actual method definition and it looks like the loadImage function does its own allocation automatically…

thanks
C

Are you sure that your image is located in bin/data folder?

1 Like

Got it!

  
ofGetDataPath("myImage.png");  

I thought it was ok to just to

  
image.loadImage("myImage.png");  

but, no. Now I know.

(for the record:

  
image.loadImage(ofGetDataPath("myImage.png"));  

works fine too.)