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

# bestfit\_color(3alleg)

Finds a palette color fitting the requested RGB values. Allegro game programming library.

## NAME

bestfit\_color - Finds a palette color fitting the requested RGB values. Allegro game programming library.

## SYNOPSIS

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

**int bestfit\_color(const PALETTE pal, int r, int g, int b);**

## DESCRIPTION

Searches the specified palette for the closest match to the requested  color, which are specified in the VGA hardware 0-63 format. Normally you  should call makecol8() instead, but this lower level function may be  useful if you need to use a palette other than the currently selected  one, or specifically don't want to use the rgb\_map lookup table.

## RETURN VALUE

Returns the index of the palette for the closest match to the requested color.

## SEE ALSO

[**makecol8**(3alleg)](/makecol8/3alleg.md)
