Unit 'agraphics' Package
[Overview][Constants][Types][Procedures and functions][Variables][Index] [#aros]

FindColor

Find the closest matching color in a colormap.

Declaration

Source position: agraphics.pas line 2202

function FindColor(

  Cm: PColorMap;

  r: LongWord;

  g: LongWord;

  b: LongWord;

  MaxPen: LongWord

):LongWord;

Arguments

Cm

  

Colormap

r

  

red level (32 bit left justified fraction)

g

  

green level (32 bit left justified fraction)

b

  

blue level (32 bit left justified fraction)

MaxPen

  

The maximum entry in the color table to search. A value of -1 will limt the search to only those pens which could be rendered in (for instance, it will not examine the sprite colors on a 4 color screen).

Description

The system will attempt to find the color in the passed colormap which most closely matches the RGB values passed. No new pens will be allocated, and you should not ReleasePen() the returned pen. This function is not sensitive to palette sharing issues. Its intended use is for:

  1. programs which pop up on public screens when those screens are not using palette sharing. You might use this function as a fallback when ObtainBestPenA() says that there are no sharable pens.
  2. Internal color matching by an application which is either running on a non-public screen, or which wants to match colors to an internal color table which may not be associated with any displayed screen.

In order to use the MaxPen=-1 feature, you must have initialized palette sharing via AttachPalExtra() (all intuition screens do this). Otherwise, MaxPen=-1 will search all colors in the colormap.

See also

ObtainBestPenA

  

Search for the closest color match, or allocate a new one.

GetColorMap

  

Allocate and initialize Colormap

ObtainPen

  

Obtain a free palette entry for use by your program.

ReleasePen

  

Release an allocated palette entry to the free pool.


Documentation generated on: 2021-07-30