draw_trans_sprite(3)
β¨ draw_trans_sprite β¨
okay bestie, gather round, because today we're talking about draw_trans_sprite from the Allegro manual π
this is a function that draws a sprite and blends it with the destination β it's from the Allegro game programming library, and it's lowkey iconic for ghost effects π«Ά
πΈ SYNOPSIS πΈ
#include <allegro.h>
void draw_trans_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y);
π¦ DESCRIPTION π¦
so what it does is: it uses the global color_map table, or the truecolor blender functions, to overlay the sprite on top of the existing image β¨
β οΈ important bestie: this must only be used after you've set up the color mapping table (for 256-color modes) or the blender functions (for truecolor modes). no setup, no slay. π
and because translucent drawing involves reading as well as writing the bitmap memory, it is very slow if you draw directly to video RAM π so wherever possible you should use a memory bitmap instead. fr fr, take the hint.
example time, look at her go:
/* Some one time initialisation code. */
COLOR_MAP global_trans_table;
create_trans_table(&global_trans_table, my_palette,
128, 128, 128, NULL);
...
if (get_color_depth() == 8)
color_map = &global_trans_table;
else
set_trans_blender(128, 128, 128, 128);
draw_trans_sprite(buffer, ghost_sprite, x, y);
now, the tea about color depths π β the bitmap and the sprite must normally be in the same color depth. but as a special case:
- you can draw 32 bit RGBA format sprites onto any hicolor or truecolor bitmap, as long as you call
set_alpha_blender()first π - and you can draw 8-bit alpha images onto a 32-bit RGBA destination, as long as you call
set_write_alpha_blender()first π
and just like draw_sprite(), this function skips transparent pixels β except if the source sprite is an 8-bit image. if that's the case, bestie, you should pay attention to properly setting up your color map table for index 0 π don't skip that part, it matters.
π SEE ALSO π
draw_sprite(3)draw_lit_sprite(3)draw_trans_rle_sprite(3)color_map(3)set_trans_blender(3)set_alpha_blender(3)set_write_alpha_blender(3)bitmap_mask_color(3)exalpha(3)exblend(3)exlights(3)exrotscl(3)extrans(3)exxfade(3)
and that's the whole vibe check, bestie π this was draw_trans_sprite(3) from the Allegro manual, version 4.4.3 β go forth and blend your sprites, you absolute main character πβ¨
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms