libarttypedef struct _ArtPixBuf ArtPixBuf; typedef enum { ART_PIX_RGB /* gray, cmyk, lab, ... ? */ } ArtPixFormat; /* The pixel buffer consists of width * height pixels, each of which has n_channels samples. It is stored in simple packed format. */ struct _ArtPixBuf { ArtPixFormat format; int n_channels; int has_alpha; int bits_per_sample; art_u8 *pixels; int width; int height; int rowstride; };ArtPixBuf is the basic data structure representing images in libart. Currently, only RGB and RGBA images are supported, although the number of formats can be expected to increase.
The actual image pixels are stored in packed format. Thus, for 8-bit images (the only depth presently supported) sample i of pixel (x, y) is stored at address pixbuf->pixels + y * pixbuf->rowstride + x * pixbuf->n_channels + i. For RGB images, the pixels are stored in order red, green, blue. For RGBA images, the pixels are stored with separated alpha in order red, green, blue, alpha.
The rowstride parameter has two applications. First, for images with odd widths, it can ensure that the beginnings of lines all align on 32- or 64-bit boundaries. Second, in the special case of an image for which all rows are identical, a rowstride of zero can be used, and only one row stored.
RGB images should have n_channels of 3 and has_alpha of 0. RGBA images should have n_channels of 4 and has_alpha of 0.
A number of libart operations have an even lower-level interface than ArtPixBuf. Functions specialized to, say, 24-bit RGB buffers often accept arguments containing the pixels pointer, the width, the height, and the rowstride.