In the preceding sections, we considered different ways of drawing images loaded from files. In this section, we see how to generate new images or alter an existing image by specifying its pixels directly.
A raster image is represented as an array of pixels in memory. If we have an image with width
w pixels and height
h pixels, it is represented by
N = w * h pixels. Normally, the horizontal rows of an image lie sequentially in memory: the
w pixels of the first row, then the second row, and so on to the
The pixels of the image can hold differing amounts of information depending on the image type. In openFrameworks, the following types are used:
OF_IMAGE_COLOR_ALPHAtype denotes a colored image with transparency. Here, each pixel is represented by 4 bytes, holding red, green, blue, and alpha color components respectively, with values from 0 to 255.