---
title: CWCheckColors
framework: Application Services
role: pseudoSymbol
platforms: []
path: applicationservices/colorsync_manager/1805111-cwcheckcolors
---

# CWCheckColors

Tests a list of colors using a specified color world to see if they fall within the gamut of a destination device.

## Declaration

```occ
CMError CWCheckColors (
   CMWorldRef cw,
   CMColor *myColors,
   size_t count,
   UInt8 *result
);
```

## Parameters

- `cw`: A reference to the color world of type [doc://com.apple.documentation/documentation/applicationservices/cmworldref](applicationservices/cmworldref.md) describing how the test is to occur.
 The functions [doc://com.apple.documentation/documentation/applicationservices/colorsync_manager/1805079-ncwnewcolorworld](applicationservices/colorsync_manager/1805079-ncwnewcolorworld.md) and [doc://com.apple.documentation/documentation/applicationservices/colorsync_manager/1805087-cwconcatcolorworld](applicationservices/colorsync_manager/1805087-cwconcatcolorworld.md) both allocate color world references of type [doc://com.apple.documentation/documentation/applicationservices/cmworldref](applicationservices/cmworldref.md).
- `myColors`: A pointer to an array containing a list of colors of type [doc://com.apple.documentation/documentation/applicationservices/1560453-cmcolor](applicationservices/1560453-cmcolor.md) to be checked`.`This function assumes the color values are specified in the data color space of the source profile.
- `count`: The number of colors in the array. This is a one-based count.
- `result`: A pointer to a buffer of packed bits. On return, each bit value is interpreted as a bit field with each bit representing a color in the array pointed to by `myColors`. You allocate enough memory to allow for 1 bit to represent each color in the `myColors` array. Bits in the `result` field are set to 1 if the corresponding color is out of gamut for the destination device. Ensure that the buffer you allocate is zeroed out before you call this function. 
 To access the packed bit-array, use code similar to the following:
 ```occ
inline bool GetNthBit (UInt8* result, int n)
{
    return ( 0 != (result[n/8] & (128>>(n%8))) );
}
```
 The `result` bit array indicates whether the colors in the list are in or out of gamut for the destination profile. If a bit is set, its corresponding color falls out of gamut for the destination device. The leftmost bit in the field corresponds to the first color in the list.

## Return Value

A `CMError` value. See [Result Codes](../colorsync_manager.md).

## Overview

The color test provides a preview of color matching using the specified color world.

All CMMs must support the `CWCheckColors` function. 

If you have set a profile’s gamut-checking mask so that no gamut information is included—see [Flag Mask Definitions for Version 2.x Profiles](../1560699-x_profiles.md) — `CWCheckColors` returns the `cmCantGamutCheckError` error.

The `CWCheckColors` function supports matching sessions set up with one of the multichannel color data types. `CWCheckColors` is not supported if the color world was initialized with a named color space profile. 

## See Also

### Working With ColorWorlds

- [NCWNewColorWorld](1805079-ncwnewcolorworld.md)
- [CWConcatColorWorld](1805087-cwconcatcolorworld.md)
- [NCWConcatColorWorld](1805091-ncwconcatcolorworld.md)
- [CMGetCWInfo](1805097-cmgetcwinfo.md)
- [CWDisposeColorWorld](1805102-cwdisposecolorworld.md)
- [CWMatchColors](1805108-cwmatchcolors.md)
- [CWMatchBitmap](1805116-cwmatchbitmap.md)
- [CWCheckBitmap](1805121-cwcheckbitmap.md)
- [CWFillLookupTexture](1805126-cwfilllookuptexture.md)
