---
name: "set_color_depth"
section: "3alleg"
platform: "linux"
package: "liballegro-doc"
version: "2:4.2.2-2.2"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/set_color_depth"
---

# set\_color\_depth(3alleg)

Sets the global pixel color depth. Allegro game programming library.

## NAME

set\_color\_depth - Sets the global pixel color depth. Allegro game programming library.

## SYNOPSIS

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

**void set\_color\_depth(int depth);**

## DESCRIPTION

Sets the pixel format to be used by subsequent calls to set\_gfx\_mode()  and create\_bitmap(). Valid depths are 8 (the default), 15, 16, 24, and 32  bits. Example:

```
   set_color_depth(32);
   if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) {
      abort_on_error("Couldn't set a 32 bit color resolution");
   }
```

Note that the screen color depth won't change until the next successful call to set\_gfx\_mode().

## SEE ALSO

[**get\_color\_depth**(3alleg)](/get_color_depth/3alleg.md), [**set\_gfx\_mode**(3alleg)](/set_gfx_mode/3alleg.md), [**set\_color\_conversion**(3alleg)](/set_color_conversion/3alleg.md), [**makecol**(3alleg)](/makecol/3alleg.md), [**getr**(3alleg)](/getr/3alleg.md), [**desktop\_color\_depth**(3alleg)](/desktop_color_depth/3alleg.md)
