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

# CGDataConsumerPutBytesCallback

Copies data from a Core Graphics-supplied buffer into a data consumer.

```
typealias CGDataConsumerPutBytesCallback = (UnsafeMutableRawPointer?, UnsafeRawPointer, Int) -> Int
```

## Parameters

`info`

A generic pointer to private data shared among your callback functions. This is the pointer supplied to [`init(info:cbks:)`](/documentation/CoreGraphics/CGDataConsumer/init(info:cbks:)).

`buffer`

The buffer from which you copy the specified number of bytes.

`count`

The number of bytes to copy.

## Return Value

The number of bytes copied. If no more data can be written to the consumer, you should return `0`.

## Discussion

When Core Graphics is ready to send data to the consumer, your function is called. It should copy the specified number of bytes from `buffer` into some resource under your control—for example, a file.

For information on how to associate your callback function with a data consumer, see [`init(info:cbks:)`](/documentation/CoreGraphics/CGDataConsumer/init(info:cbks:)) and [`CGDataConsumerCallbacks`](/documentation/CoreGraphics/CGDataConsumerCallbacks).

---

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)