-
Book Overview & Buying
-
Table Of Contents
Mastering openFrameworks: Creative Coding Demystified
By :
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:
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.
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 to use absolute paths; for example, image.loadImage( "C:\\myimage.png" ) in Windows.
Draw the image using the image.draw( x, y ) function inside the testApp::draw() function. Here, x and y are float values specifying the top-left corner of the...
Change the font size
Change margin width
Change background colour