I am loading an image into ofImage. Is there a way to get the path of the loaded image?
Specifically, I am checking if it loaded, and if it didn’t I want to display the path that failed.
(And I know there are other ways to accomplish this, but I wanted to see if its possible to get the path from ofImage).
I looked at the source code for
ofImage::load on github:
It doesn’t look like the class saves the filename in any place; so the best way to accomplish what you want is probably something like this:
std::string filename = "path/to/file";
Thanks. Yes, that is the workaround I could do, but I wanted to see if it was possible (it would definitely be useful).
Btw, for my specific use case, ofImage.load will actually give an error with the path if it cant load the image.
You can always define a class which extends ofImage, something like ofImageWithFilename (not tested):
class ofImageWithFilename : public ofImage
bool specialLoadImage(const string & filename)
m_filename = filename;