I am loading images and would like to store the width and height of them in the setup. How do I do that?
Cheers!
I am loading images and would like to store the width and height of them in the setup. How do I do that?
Cheers!
Hi @pepeu, you can get the width or height of an image anytime by calling the functions .getWidth() or .getHeight() on an ofImage. These functions return a floating point number, which can be stored in a float
variable like this:
float imageWidth = image.getWidth();
float imageHeight = image.getHeight();
If you’re just learning openFrameworks (OF) and how to write c++ code, there are some things on the OF website that can help. Have a look at ofBook, which covers a lot of the things that OF can do:
https://openframeworks.cc/ofBook/chapters/cplusplus_basics.html
And be sure and check out the Learning tab of the OF website (ofBook is there too).
Also, there are a lot of projects in the /examples folder that comes with OF. The graphicsExample, polygonExample, and colorExample are some fun ones to explore in the /examples/graphics/ folder.
Aah, thank you! So simple. Haha! Cheers!