<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGDataProvider",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Core Graphics"
    ],
    "preciseIdentifier" : "c:@T@CGDataProviderRef"
  },
  "title" : "CGDataProvider"
}
-->

# CGDataProvider

An abstraction for data-reading tasks that eliminates the need to manage a raw memory buffer.

```
class CGDataProvider
```

## Overview

Data provider objects abstract the data-access task and eliminate the need for applications to manage data through a raw memory buffer.

For information on how to use CGDataProvider functions, see [Quartz 2D Programming Guide](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction/Introduction.html#//apple_ref/doc/uid/TP30001066) Programming Guide.

See also [`CGDataConsumer`](/documentation/CoreGraphics/CGDataConsumer).

## Topics

### Creating Sequential-Access Data Providers

[`init(sequentialInfo:callbacks:)`](/documentation/CoreGraphics/CGDataProvider/init(sequentialInfo:callbacks:))

Creates a sequential-access data provider.

[`CGDataProviderSequentialCallbacks`](/documentation/CoreGraphics/CGDataProviderSequentialCallbacks)

Defines a structure containing pointers to client-defined callback functions that manage the sending of data for a sequential-access data provider.

[`CGDataProviderRewindCallback`](/documentation/CoreGraphics/CGDataProviderRewindCallback)

A callback function that moves the current position in the data stream back to the beginning.

[`CGDataProviderGetBytesCallback`](/documentation/CoreGraphics/CGDataProviderGetBytesCallback)

A callback function that copies from a provider data stream into a Core Graphics buffer.

[`CGDataProviderSkipForwardCallback`](/documentation/CoreGraphics/CGDataProviderSkipForwardCallback)

A callback function that advances the current position in the data stream supplied by the provider.

[`CGDataProviderReleaseInfoCallback`](/documentation/CoreGraphics/CGDataProviderReleaseInfoCallback)

A callback function that releases any private data or resources associated with the data provider.

### Creating Direct-Access Data Providers

[`init(directInfo:size:callbacks:)`](/documentation/CoreGraphics/CGDataProvider/init(directInfo:size:callbacks:))

Creates a direct-access data provider.

[`init(data:)`](/documentation/CoreGraphics/CGDataProvider/init(data:))

Creates a data provider that reads from a CFData object.

[`init(url:)`](/documentation/CoreGraphics/CGDataProvider/init(url:))

Creates a direct-access data provider that uses a URL to supply data.

[`init(dataInfo:data:size:releaseData:)`](/documentation/CoreGraphics/CGDataProvider/init(dataInfo:data:size:releaseData:))

Creates a direct-access data provider that uses data your program supplies.

[`init(filename:)`](/documentation/CoreGraphics/CGDataProvider/init(filename:))

Creates a direct-access data provider that uses a file to supply data.

[`CGDataProviderDirectCallbacks`](/documentation/CoreGraphics/CGDataProviderDirectCallbacks)

Defines pointers to client-defined callback functions that manage the sending of data for a direct-access data provider.

[`CGDataProviderGetBytePointerCallback`](/documentation/CoreGraphics/CGDataProviderGetBytePointerCallback)

A callback function that returns a generic pointer to the provider data.

[`CGDataProviderGetBytesAtPositionCallback`](/documentation/CoreGraphics/CGDataProviderGetBytesAtPositionCallback)

A callback function that copies data from the provider into a Core Graphics buffer.

[`CGDataProviderReleaseBytePointerCallback`](/documentation/CoreGraphics/CGDataProviderReleaseBytePointerCallback)

A callback function that releases the pointer Core Graphics obtained by calling [`CGDataProviderGetBytePointerCallback`](/documentation/CoreGraphics/CGDataProviderGetBytePointerCallback).

[`CGDataProviderReleaseInfoCallback`](/documentation/CoreGraphics/CGDataProviderReleaseInfoCallback)

A callback function that releases any private data or resources associated with the data provider.

[`CGDataProviderReleaseDataCallback`](/documentation/CoreGraphics/CGDataProviderReleaseDataCallback)

A callback function that releases data you supply to the function [`init(dataInfo:data:size:releaseData:)`](/documentation/CoreGraphics/CGDataProvider/init(dataInfo:data:size:releaseData:)).

### Retaining and Releasing Data Providers

[`CGDataProviderRelease`](/documentation/CoreGraphics/CGDataProviderRelease)

Decrements the retain count of a data provider.

[`CGDataProviderRetain`](/documentation/CoreGraphics/CGDataProviderRetain)

Increments the retain count of a data provider.

### Getting Data from a Data Provider

[`data`](/documentation/CoreGraphics/CGDataProvider/data)

Returns a copy of the provider’s data.

### Working with Core Foundation Types

[`typeID`](/documentation/CoreGraphics/CGDataProvider/typeID)

Returns the Core Foundation type identifier for data providers.

### Instance Properties

[`info`](/documentation/CoreGraphics/CGDataProvider/info)

## See Also

  [Quartz 2D Programming Guide](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction/Introduction.html#//apple_ref/doc/uid/TP30001066)



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)