ALLEGRO_PIXEL_FORMAT - Man Page

Allegro 5 API

Synopsis

#include <allegro5/allegro.h>

typedef enum ALLEGRO_PIXEL_FORMAT

Description

Pixel formats. Each pixel format specifies the exact size and bit layout of a pixel in memory. Components are specified from high bits to low bits, so for example a fully opaque red pixel in ARGB_8888 format is 0xFFFF0000.

Note:

The pixel format is independent of endianness. That is, in the above example you can always get the red component with

(pixel & 0x00ff0000) >> 16

But you can not rely on this code:

*(pixel + 2)

It will return the red component on little endian systems, but the green component on big endian systems.

Also note that Allegro’s naming is different from OpenGL naming here, where a format of GL_RGBA8 merely defines the component order and the exact layout including endianness treatment is specified separately. Usually GL_RGBA8 will correspond to ALLEGRO_PIXEL_ABGR_8888 though on little endian systems, so care must be taken (note the reversal of RGBA <-> ABGR).

The only exception to this ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE which will always have the components as 4 bytes corresponding to red, green, blue and alpha, in this order, independent of the endianness.

Some of the pixel formats represent compressed bitmap formats. Compressed bitmaps take up less space in the GPU memory than bitmaps with regular (uncompressed) pixel formats. This smaller footprint means that you can load more resources into GPU memory, and they will be drawn somewhat faster. The compression is lossy, however, so it is not appropriate for all graphical styles: it tends to work best for images with smooth color gradations. It is possible to compress bitmaps at runtime by passing the appropriate bitmap format in al_set_new_bitmap_format and then creating, loading, cloning or converting a non-compressed bitmap. This, however, is not recommended as the compression quality differs between different GPU drivers. It is recommended to compress these bitmaps ahead of time using external tools and then load them compressed.

Unlike regular pixel formats, compressed pixel formats are not laid out in memory one pixel row at a time. Instead, the bitmap is subdivided into rectangular blocks of pixels that are then laid out in block rows. This means that regular locking functions cannot use compressed pixel formats as the destination format. Instead, you can use the blocked versions of the bitmap locking functions which do support these formats.

It is not recommended to use compressed bitmaps as target bitmaps, as that operation cannot be hardware accelerated. Due to proprietary algorithms used, it is typically impossible to create compressed memory bitmaps.

See Also

al_set_new_bitmap_format(3), al_get_bitmap_format(3)

Referenced By

al_get_bitmap_format(3), al_get_display_format(3), al_get_new_bitmap_format(3), al_get_pixel_block_height(3), al_get_pixel_block_size(3), al_get_pixel_block_width(3), al_get_pixel_format_bits(3), al_get_pixel_size(3), ALLEGRO_DISPLAY_MODE(3), ALLEGRO_LOCKED_REGION(3), al_lock_bitmap(3), al_lock_bitmap_region(3), al_set_new_bitmap_format(3).

Allegro reference manual