---
title: CMGetProfileElement
framework: Application Services
role: pseudoSymbol
platforms: []
path: applicationservices/colorsync_manager/1804973-cmgetprofileelement
---

# CMGetProfileElement

Obtains element data from the specified profile based on the specified element tag signature.

## Declaration

```occ
CMError CMGetProfileElement (
   CMProfileRef prof,
   OSType tag,
   UInt32 *elementSize,
   void *elementData
);
```

## Parameters

- `prof`: A profile reference of type [doc://com.apple.documentation/documentation/applicationservices/cmprofileref](applicationservices/cmprofileref.md) to the profile containing the target element.
- `tag`: The tag signature (for example, ‘A2B0’, or constant `cmAToB0Tag`) for the element in question. The tag identifies the element. For a complete list of the public tag signatures a profile may contain, including a description of each tag, refer to the International Color Consortium Profile Format Specification. The signatures for profile tags are defined in the `CMICCProfile.h` header file.
- `elementSize`: A pointer to a size value. On input, you specify the size of the element data to copy. Specify `NULL` to copy the entire element data. To obtain a portion of the element data, specify the number of bytes to copy. 
 On return, the size of the data returned.
- `elementData`: A pointer to memory for element data. On input, you allocate memory. On return, this buffer holds the element data.
 To obtain the element size in the `elementSize` parameter without copying the element data to this buffer, specify `NULL` for this parameter.

## Return Value

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

## Overview

Before you call the `CMGetProfileElement` function to obtain the element data for a specific element, you must know the size in bytes of the element data so you can allocate a buffer to hold the returned data.

The `CMGetProfileElement` function serves two purposes: to get an element’s size and to obtain an element’s data. In both instances, you provide a reference to the profile containing the element in the `prof` parameter and the tag signature of the element in the `tag` parameter.

To obtain the element data size, call the `CMGetProfileElement` function specifying a pointer to an unsigned long data type in the `elementSize` field and a `NULL` value in the `elementData` field.

After you obtain the element size, you should allocate a buffer large enough to hold the returned element data, then call the `CMGetProfileElement` function again, specifying `NULL` in the `elementSize` parameter to copy the entire element data and a pointer to the data buffer in the `elementData` parameter.

To copy only a portion of the element data beginning from the first byte, allocate a buffer the size of the number of bytes of element data you want to obtain and specify the number of bytes to copy in the `elementSize` parameter. In this case, On return the `elementSize` parameter contains the size in bytes of the element data actually returned.

You cannot use the `CMGetProfileElement` function to copy a portion of element data beginning from an offset into the data. To copy a portion of the element data beginning from any offset, use the function [CMGetPartialProfileElement](1804984-cmgetpartialprofileelement.md).

You cannot use this function to obtain a portion of the `CM2Header` profile header. Instead, you must call the function [CMGetProfileHeader](1804879-cmgetprofileheader.md) to copy the entire profile header and read its contents. 

## See Also

### Accessing Profile Elements

- [CMCountProfileElements](1804963-cmcountprofileelements.md)
- [CMProfileElementExists](1804967-cmprofileelementexists.md)
- [CMSetProfileElement](1804977-cmsetprofileelement.md)
- [CMSetProfileElementSize](1804980-cmsetprofileelementsize.md)
- [CMGetPartialProfileElement](1804984-cmgetpartialprofileelement.md)
- [CMSetPartialProfileElement](1804989-cmsetpartialprofileelement.md)
- [CMGetIndProfileElementInfo](1804996-cmgetindprofileelementinfo.md)
- [CMGetIndProfileElement](1805002-cmgetindprofileelement.md)
- [CMSetProfileElementReference](1805005-cmsetprofileelementreference.md)
- [CMRemoveProfileElement](1805008-cmremoveprofileelement.md)
