---
name: "draw_trans_sprite"
section: "3alleg4"
platform: "linux"
package: "allegro4-doc"
version: "2:4.4.3.1-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/draw_trans_sprite/3alleg4"
---

# draw\_trans\_sprite(3alleg4)

Draws a sprite blending it with the destination. Allegro game programming library.

## NAME

draw\_trans\_sprite - Draws a sprite blending it with the destination. Allegro game programming library.

## SYNOPSIS

**#include \<allegro.h\>**

**void draw\_trans\_sprite(BITMAP \*bmp, BITMAP \*sprite, int x, int y);**

## DESCRIPTION

Uses the global color\_map table or truecolor blender functions to overlay the sprite on top of the existing image. This must only be used after you  have set up the color mapping table (for 256-color modes) or blender  functions (for truecolor modes). Because it involves reading as well as  writing the bitmap memory, translucent drawing is very slow if you draw  directly to video RAM, so wherever possible you should use a memory  bitmap instead. Example:

```
   /* 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);
```

The bitmap and 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. As draw\_sprite() this function skips transparent pixels, except if the source sprite is an 8-bit image; if this is the case, you should pay attention to properly set up your color map table for index 0.

## SEE ALSO

**draw\_sprite**(3alleg4), **draw\_lit\_sprite**(3alleg4), **draw\_trans\_rle\_sprite**(3alleg4), **color\_map**(3alleg4), **set\_trans\_blender**(3alleg4), **set\_alpha\_blender**(3alleg4), **set\_write\_alpha\_blender**(3alleg4), **bitmap\_mask\_color**(3alleg4), **exalpha**(3alleg4), **exblend**(3alleg4), **exlights**(3alleg4), **exrotscl**(3alleg4), **extrans**(3alleg4), **exxfade**(3alleg4)
