---
name: "getpixel"
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/getpixel"
---

# getpixel(3alleg)

Reads a pixel from a bitmap. Allegro game programming library.

## NAME

getpixel - Reads a pixel from a bitmap. Allegro game programming library.

## SYNOPSIS

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

**int getpixel(BITMAP \*bmp, int x, int y);**

## DESCRIPTION

Reads a pixel from point (x, y) in the bitmap.

## RETURN VALUE

Returns -1 if the point lies outside the bitmap (ignoring the clipping rectangle), otherwise the value of the pixel in the color format of the bitmap.

Warning: -1 is also a valid value for pixels contained in 32-bit bitmaps with alpha channel (when R,G,B,A are all equal to 255) so you can't use the test against -1 as a predicate for such bitmaps. In this cases, the only reliable predicate is is\_inside\_bitmap().

To extract the individual color components, use the getr() / getg() / getb() / geta() family of functions.

## SEE ALSO

[**putpixel**(3alleg)](/putpixel/3alleg.md), [**\_getpixel**(3alleg)](/_getpixel/3alleg.md), [**is\_inside\_bitmap**(3alleg)](/is_inside_bitmap/3alleg.md), [**getr**(3alleg)](/getr/3alleg.md), [**getg**(3alleg)](/getg/3alleg.md), [**getb**(3alleg)](/getb/3alleg.md), [**geta**(3alleg)](/geta/3alleg.md), [**ex12bit**(3alleg)](/ex12bit/3alleg.md), [**exalpha**(3alleg)](/exalpha/3alleg.md), [**exflame**(3alleg)](/exflame/3alleg.md), [**exlights**(3alleg)](/exlights/3alleg.md)
