|
NAMEal_load_bitmap_flags - Allegro 5 APISYNOPSIS
DESCRIPTIONLoads an image file into a new ALLEGRO_BITMAP(3). The file type is determined by the extension, except if the file has no extension in which case al_identify_bitmap(3) is used instead.Returns NULL on error. The flags parameter may be a combination of the following constants:
The reason for this can be seen in the Allegro example ex_premulalpha, ie, using pre-multiplied alpha gives more accurate color results in some cases. To use alpha blending with images loaded with pre-multiplied alpha, you would use the default blending mode, which is set with al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA). The ALLEGRO_NO_PREMULTIPLIED_ALPHA flag being set will ensure that images are not loaded with alpha pre-multiplied, but are loaded with color values direct from the image. That looks like this:
To draw such an image using regular alpha blending, you would use al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA) to set the correct blender. This has some caveats. First, as mentioned above, drawing such an image can result in less accurate color blending (when drawing an image with linear filtering on, the edges will be darker than they should be). Second, the behaviour is somewhat confusing, which is explained in the example below.
To explain further, if you have a pixel with 0.5 alpha, and you’re using (ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA) for blending, the formula is:
Expands to:
So if you draw the image to the temporary buffer, it is blended once resulting in 0.75 alpha, then drawn again to the screen, blended in the same way, resulting in a pixel has 0.1875 as an alpha value.
This is not yet honoured. Note: the core Allegro library does not support any image file formats by default. You must use the allegro_image addon, or register your own format handler. SINCE5.1.0SEE ALSOal_load_bitmap(3)
Visit the GSP FreeBSD Man Page Interface. |