Mac Developer Library

Developer

ApplicationServices Framework Reference CGDataProvider Reference

Options
Deployment Target:

On This Page
Language:

CGDataProvider Reference

The CGDataProvider header file declares a data type that supplies Quartz functions with data. 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 Programming Guide.

See also CGDataConsumer Reference.

Functions

  • CGDataProviderCreate CGDataProviderCreate Available in OS X v10.0 through OS X v10.7

    Creates a Quartz sequential-access data provider.

    Declaration

    Objective-C

    CGDataProviderRef CGDataProviderCreate ( void *info, const CGDataProviderCallbacks *callbacks );

    Parameters

    info

    A pointer to data of any type or NULL. When Quartz calls the functions specified in the callbacks parameter, it sends each of the functions this data.

    callbacks

    A pointer to a CGDataProviderCallbacks structure that specifies the callback functions you implement to handle the data provider’s basic memory management. For a complete description, see CGDataProviderCallbacks.

    Return Value

    A new data provider. You are responsible for releasing this object using CGDataProviderRelease.

    Discussion

    You use this function to create a sequential-access data provider that uses callback functions to read data from your program in a stream.

    Import Statement

    Objective-C

    @import ApplicationServices;

    Availability

    Available in OS X v10.0 through OS X v10.7.

    Deprecated in OS X v10.5.

  • CGDataProviderCreateDirectAccess CGDataProviderCreateDirectAccess Available in OS X v10.0 through OS X v10.7

    Creates a Quartz direct-access data provider.

    Declaration

    Objective-C

    CGDataProviderRef CGDataProviderCreateDirectAccess ( void *info, size_t size, const CGDataProviderDirectAccessCallbacks *callbacks );

    Parameters

    info

    A pointer to data of any type or NULL. When Quartz calls the functions specified in the callbacks parameter, it sends each of the functions this pointer.

    size

    A value that specifies the number of bytes that the data provider contains.

    callbacks

    A pointer to a CGDataProviderDirectAccessCallbacks structure that specifies the callback functions you implement to handle the data provider’s basic memory management. For a complete description, see CGDataProviderDirectAccessCallbacks.

    Return Value

    A new data provider. You are responsible for releasing this object using CGDataProviderRelease.

    Discussion

    You use this function to create a direct-access data provider that uses callback functions to read data from your program in a single block.

    Import Statement

    Objective-C

    @import ApplicationServices;

    Availability

    Available in OS X v10.0 through OS X v10.7.

    Deprecated in OS X v10.5.

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

    Declaration

    Swift

    func CGDataProviderCreateWithData(_ info: UnsafeMutablePointer<Void>, _ data: UnsafePointer<Void>, _ size: UInt, _ releaseData: CGDataProviderReleaseDataCallback) -> CGDataProvider!

    Objective-C

    CGDataProviderRef CGDataProviderCreateWithData ( void *info, const void *data, size_t size, CGDataProviderReleaseDataCallback releaseData );

    Parameters

    info

    A pointer to data of any type, or NULL. When Quartz calls the function specified in the releaseData parameter, Quartz sends it this pointer as its first argument.

    data

    A pointer to the array of data that the provider contains.

    size

    A value that specifies the number of bytes that the data provider contains.

    releaseData

    A pointer to a release callback for the data provider, or NULL. Your release function is called when Quartz frees the data provider. For more information, see CGDataProviderReleaseDataCallback.

    Return Value

    A new data provider. You are responsible for releasing this object using CGDataProviderRelease.

    Discussion

    You use this function to create a direct-access data provider that uses callback functions to read data from your program an entire block at one time.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func CGDataProviderCreateWithURL(_ url: CFURL!) -> CGDataProvider!

    Objective-C

    CGDataProviderRef CGDataProviderCreateWithURL ( CFURLRef url );

    Parameters

    url

    A CFURL object to use for the data provider. When you supply Quartz data via the provider, it reads the data from the URL address.

    Return Value

    A new data provider or NULL if the data from the URL could not be accessed. You are responsible for releasing this object using CGDataProviderRelease.

    Discussion

    You use this function to create a direct-access data provider that supplies data from a URL. When you supply Quartz with a direct-access data provider, Quartz obtains data from your program in a single entire block.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    func CGDataProviderCreateWithFilename(_ filename: UnsafePointer<Int8>) -> CGDataProvider!

    Objective-C

    CGDataProviderRef CGDataProviderCreateWithFilename ( const char *filename );

    Parameters

    filename

    The full or relative pathname to use for the data provider. When you supply Quartz data via the provider, it reads the data from the specified file.

    Return Value

    A new data provider or NULL if the file could not be opened. You are responsible for releasing this object using CGDataProviderRelease.

    Discussion

    You use this function to create a direct-access data provider that supplies data from a file. When you supply Quartz with a direct-access data provider, Quartz obtains data from your program in a single block.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in OS X v10.0 and later.

  • Creates a Quartz data provider that reads from a CFData object.

    Declaration

    Swift

    func CGDataProviderCreateWithCFData(_ data: CFData!) -> CGDataProvider!

    Objective-C

    CGDataProviderRef CGDataProviderCreateWithCFData ( CFDataRef data );

    Parameters

    data

    The CFData object to read from.

    Return Value

    A new data provider. You are responsible for releasing this object using CGDataProviderRelease.

    Discussion

    You can use this function when you need to represent Quartz data as a CFData type. For example, you might create a CFData object when reading data from the pasteboard.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in OS X v10.4 and later.

  • Returns the Core Foundation type identifier for Quartz data providers.

    Declaration

    Swift

    func CGDataProviderGetTypeID() -> CFTypeID

    Objective-C

    CFTypeID CGDataProviderGetTypeID ( void );

    Return Value

    The identifier for the opaque type CGDataProviderRef.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in OS X v10.2 and later.

  • Returns a copy of the provider’s data.

    Declaration

    Swift

    func CGDataProviderCopyData(_ provider: CGDataProvider!) -> CFData!

    Objective-C

    CFDataRef CGDataProviderCopyData ( CGDataProviderRef provider );

    Parameters

    provider

    The data provider whose data you want to copy.

    Return Value

    A new data object containing a copy of the provider’s data. You are responsible for releasing this object.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in OS X v10.3 and later.

  • Decrements the retain count of a data provider.

    Declaration

    Objective-C

    void CGDataProviderRelease ( CGDataProviderRef provider );

    Parameters

    provider

    The data provider to release.

    Discussion

    This function is equivalent to CFRelease, except that it does not cause an error if the provider parameter is NULL.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Availability

    Available in OS X v10.0 and later.

  • Increments the retain count of a data provider.

    Declaration

    Objective-C

    CGDataProviderRef CGDataProviderRetain ( CGDataProviderRef provider );

    Parameters

    provider

    The data provider to retain.

    Return Value

    The same data provider you passed in as the provider parameter.

    Discussion

    This function is equivalent to CFRetain, except that it does not cause an error if the provider parameter is NULL.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Availability

    Available in OS X v10.0 and later.

  • Creates a Quartz sequential-access data provider.

    Declaration

    Swift

    func CGDataProviderCreateSequential(_ info: UnsafeMutablePointer<Void>, _ callbacks: UnsafePointer<CGDataProviderSequentialCallbacks>) -> CGDataProvider!

    Objective-C

    CGDataProviderRef CGDataProviderCreateSequential ( void *info, const CGDataProviderSequentialCallbacks *callbacks );

    Parameters

    info

    A pointer to data of any type or NULL. When Quartz calls the functions specified in the callbacks parameter, it sends each of the functions this pointer.

    callbacks

    A pointer to a CGDataProviderSequentialCallbacks structure that specifies the callback functions you implement to handle the data provider’s basic memory management.

    Return Value

    A new data provider. You are responsible for releasing this object using CGDataProviderRelease.

    Discussion

    You use this function to create a sequential-access data provider that uses callback functions to read data from your program in a single block.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in OS X v10.5 and later.

  • Creates a Quartz direct-access data provider.

    Declaration

    Swift

    func CGDataProviderCreateDirect(_ info: UnsafeMutablePointer<Void>, _ size: off_t, _ callbacks: UnsafePointer<CGDataProviderDirectCallbacks>) -> CGDataProvider!

    Objective-C

    CGDataProviderRef CGDataProviderCreateDirect ( void *info, off_t size, const CGDataProviderDirectCallbacks *callbacks );

    Parameters

    info

    A pointer to data of any type or NULL. When Quartz calls the functions specified in the callbacks parameter, it sends each of the functions this pointer.

    size

    The number of bytes of data to provide.

    callbacks

    A pointer to a CGDataProviderDirectCallbacks structure that specifies the callback functions you implement to handle the data provider’s basic memory management.

    Return Value

    A new data provider. You are responsible for releasing this object using CGDataProviderRelease.

    Discussion

    You use this function to create a direct-access data provider that uses callback functions to read data from your program in a single block.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in OS X v10.5 and later.

Callbacks

  • A callback function that copies from a provider data stream into a Quartz-supplied buffer.

    Declaration

    Swift

    typealias CGDataProviderGetBytesCallback = CFunctionPointer<((UnsafeMutablePointer<Void>, UnsafeMutablePointer<Void>, UInt) -> UInt)>

    Objective-C

    size_t (*CGDataProviderGetBytesCallback) ( void *info, void *buffer, size_t count );

    Parameters

    info

    A generic pointer to private data shared among your callback functions. This is the same pointer you supplied to CGDataProviderCreate.

    buffer

    The Quartz-supplied buffer into 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 buffer, you should return 0.

    Discussion

    When Quartz is ready to receive data from the provider data stream, your function is called. It should copy the specified number of bytes into buffer.

    For information on how to associate your callback function with a data provider, see CGDataProviderCreate and CGDataProviderCallbacks.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in OS X v10.3 and later.

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

    Declaration

    Swift

    typealias CGDataProviderReleaseInfoCallback = CFunctionPointer<((UnsafeMutablePointer<Void>) -> Void)>

    Objective-C

    void (*CGDataProviderReleaseInfoCallback) ( void *info );

    Parameters

    info

    A generic pointer to private information shared among your callback functions. This is the same pointer you supplied to CGDataProviderCreate.

    Discussion

    When Quartz frees a data provider that has an associated release function, the release function is called.

    For information on how to associate your callback function with a data provider, see CGDataProviderCreate and CGDataProviderCallbacks.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in OS X v10.3 and later.

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

    Declaration

    Swift

    typealias CGDataProviderRewindCallback = CFunctionPointer<((UnsafeMutablePointer<Void>) -> Void)>

    Objective-C

    void (*CGDataProviderRewindCallback) ( void *info );

    Parameters

    info

    A generic pointer to private data shared among your callback functions. This is the same pointer you supplied to CGDataProviderCreate.

    Discussion

    When Quartz needs to read from the beginning of the provider’s data stream, your function is called.

    For information on how to associate your callback function with a data provider, see CGDataProviderCreate and CGDataProviderCallbacks.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in OS X v10.3 and later.

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

    Declaration

    Objective-C

    void (*CGDataProviderSkipBytesCallback) ( void *info, size_t count );

    Parameters

    info

    A generic pointer to private data shared among your callback functions. This is the same pointer you supplied to CGDataProviderCreate.

    count

    The number of bytes to skip.

    Discussion

    When Quartz needs to advance forward in the provider’s data stream, your function is called.

    For information on how to associate your callback function with a data provider, see CGDataProviderCreate and CGDataProviderCallbacks.

    Import Statement

    Objective-C

    @import ApplicationServices;

    Availability

    Available in OS X v10.3 through OS X v10.7.

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

    Declaration

    Swift

    typealias CGDataProviderSkipForwardCallback = CFunctionPointer<((UnsafeMutablePointer<Void>, off_t) -> off_t)>

    Objective-C

    off_t (*CGDataProviderSkipForwardCallback) ( void *info, off_t count );

    Parameters

    info

    A generic pointer to private data shared among your callback functions. This is the same pointer you supplied to CGDataProviderCreate.

    count

    The number of bytes to skip.

    Return Value

    The number of bytes that were actually skipped.

    Discussion

    When Quartz needs to advance forward in the provider’s data stream, your function is called.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in OS X v10.5 and later.

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

    Declaration

    Swift

    typealias CGDataProviderGetBytePointerCallback = CFunctionPointer<((UnsafeMutablePointer<Void>) -> UnsafePointer<Void>)>

    Objective-C

    const void * (*CGDataProviderGetBytePointerCallback) ( void *info );

    Parameters

    info

    A generic pointer to private data shared among your callback functions. This is the same pointer you supplied to CGDataProviderCreateDirectAccess.

    Return Value

    A generic pointer to your provider data. By suppling this pointer, you are giving Quartz read-only access to both the pointer and the underlying provider data. You must not move or modify the provider data until Quartz calls your CGDataProviderReleaseBytePointerCallback function.

    Discussion

    When Quartz needs direct access to your provider data, this function is called.

    For information on how to associate your function with a direct-access data provider, see CGDataProviderCreateDirectAccess and CGDataProviderDirectAccessCallbacks.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in OS X v10.3 and later.

  • A callback function that copies data from the provider into a Quartz buffer.

    Declaration

    Objective-C

    typedef size_t (*CGDataProviderGetBytesAtOffsetCallback) ( void *info, void *buffer, size_t offset, size_t count );

    Parameters

    info

    A generic pointer to private data shared among your callback functions. This is the same pointer you supplied to CGDataProviderCreateDirectAccess.

    buffer

    The Quartz-supplied buffer into which you copy the specified number of bytes.

    offset

    Specifies the relative location in the data provider at which to begin copying data.

    count

    The number of bytes to copy.

    Return Value

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

    Discussion

    When Quartz is ready to receive data from the provider, your function is called.

    For information on how to associate your function with a direct-access data provider, see CGDataProviderCreateDirectAccess and CGDataProviderDirectAccessCallbacks.

    Import Statement

    Objective-C

    @import ApplicationServices;

    Availability

    Available in OS X v10.3 through OS X v10.7.

  • A callback function that releases the pointer Quartz obtained by calling CGDataProviderGetBytePointerCallback.

    Declaration

    Swift

    typealias CGDataProviderReleaseBytePointerCallback = CFunctionPointer<((UnsafeMutablePointer<Void>, UnsafePointer<Void>) -> Void)>

    Objective-C

    typedef void (*CGDataProviderReleaseBytePointerCallback) ( void *info, const void *pointer );

    Parameters

    info

    A generic pointer to private data shared among your callback functions. This is the same pointer you supplied to CGDataProviderCreateDirectAccess.

    pointer

    A pointer to your provider data. This is the same pointer you returned in CGDataProviderGetBytePointerCallback.

    Discussion

    When Quartz no longer needs direct access to your provider data, your function is called. You may safely modify, move, or release your provider data at this time.

    For information on how to associate your function with a direct-access data provider, see CGDataProviderCreateDirectAccess and CGDataProviderDirectAccessCallbacks.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in OS X v10.3 and later.

  • A callback function that releases data you supply to the function CGDataProviderCreateWithData.

    Declaration

    Swift

    typealias CGDataProviderReleaseDataCallback = CFunctionPointer<((UnsafeMutablePointer<Void>, UnsafePointer<Void>, UInt) -> Void)>

    Objective-C

    typedef void (*CGDataProviderReleaseDataCallback) ( void *info, const void *data, size_t size );

    Parameters

    info

    A generic pointer to private data shared among your callback functions. This is the same pointer you supplied to CGDataProviderCreateWithData.

    data

    A pointer to your provider data.

    size

    The size of the data.

    Discussion

    When Quartz no longer needs direct access to your provider data, your function is called. You may safely modify, move, or release your provider data at this time.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in OS X v10.5 and later.

  • A callback function that copies data from the provider into a Quartz buffer.

    Declaration

    Swift

    typealias CGDataProviderGetBytesAtPositionCallback = CFunctionPointer<((UnsafeMutablePointer<Void>, UnsafeMutablePointer<Void>, off_t, UInt) -> UInt)>

    Objective-C

    typedef size_t (*CGDataProviderGetBytesAtPositionCallback) ( void *info, void *buffer, off_t position, size_t count );

    Parameters

    info

    A generic pointer to private data shared among your callback functions. This is the same pointer you supplied to CGDataProviderCreateDirect.

    buffer

    The Quartz-supplied buffer into which you copy the specified number of bytes.

    position

    Specifies the relative location in the data provider at which to begin copying data.

    count

    The number of bytes to copy.

    Return Value

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

    Discussion

    When Quartz is ready to receive data from the provider, your function is called.

    Import Statement

    Objective-C

    @import CoreGraphics;

    Swift

    import CoreGraphics

    Availability

    Available in OS X v10.5 and later.

Data Types