O'Reilly logo

Mastering openFrameworks: Creative Coding Demystified by Denis Perevalov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Loading and drawing an image

For loading and drawing an image, you need to declare the image object, load the image from a file, and add a drawing function call in the testApp::draw() function. Perform the following steps:

  1. Declare the image as an ofImage object:
    ofImage image;

    The best way is to declare images in the testApp class declaration in the testApp.h file. For simplicity, sometimes we will declare them right on top of the testApp.cpp file.

  2. Load an image from a file using the loadImage function:
    image.loadImage( fileName );

    Here, fileName is a string value specifying the filename; for example, sunflower.png. Normally, images should be located in the bin/data folder of your application. If you want to use an image from another folder, it is possible ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required