---
title: CMGetIndProfileElement
framework: Application Services
role: pseudoSymbol
platforms: []
path: applicationservices/colorsync_manager/1805002-cmgetindprofileelement
---

# CMGetIndProfileElement

Obtains the element data corresponding to a particular index from the specified profile. 

## Declaration

```occ
CMError CMGetIndProfileElement (
   CMProfileRef prof,
   UInt32 index,
   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 element.
- `index`: The index of the element whose data you want to obtain. This is a one-based element index within the range returned as the `elementCount` parameter of the `CMCountProfileElements` function.
- `elementSize`: A pointer to an element data size. On input, specify the size of the element data to copy (except when `elementData` is set to `NULL`). Specify `NULL` to copy the entire element data. To obtain a portion of the element data, specify the number of bytes to be copy. 
 On return, the size of the element data actually copied.
- `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 `CMGetIndProfileElement` function to obtain the element data for an element at a specific index, you first determine the size in bytes of the element data. To determine the data size, you can

- call the function [CMGetIndProfileElementInfo](1804996-cmgetindprofileelementinfo.md), passing the element’s index
- call the `CMGetIndProfileElement` function itself, specifying a pointer to an unsigned long data type in the `elementSize` field and a `NULL` value in the `elementData` field

Once you have determined the size of the element data, you allocate a buffer to hold as much of the data as you need. If you want all of the element data, you specify `NULL` in the `elementSize` parameter. If you want only a portion of the element data, you specify the number of bytes you want in the `elementSize` parameter. You supply a pointer to the data buffer in the `elementData` parameter. After calling `CMGetIndProfileElement`, the `elementSize` parameter contains the size in bytes of the element data actually copied. 

Before calling this function, you should call the function [CMCountProfileElements](1804963-cmcountprofileelements.md). It returns the profile’s total element count in the `elementCount` parameter. 

## See Also

### Accessing Profile Elements

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