Derived from | |
Framework | ApplicationServices/ImageIO |
Declared in | CGImageSource.h |
Companion guides |
CGImageSource objects, available in Mac OS X v10.4 or later, abstract the data-reading task. An image source can read image data from a URL, a CFData
object, or a data consumer.
After creating a CGImageSource object for the appropriate source, you can obtain images, thumbnails, image properties, and other image information using CGImageSource functions.
CGImageSourceGetTypeID
CGImageSourceGetType
CGImageSourceCopyTypeIdentifiers
CGImageSourceGetCount
CGImageSourceCopyProperties
CGImageSourceCopyPropertiesAtIndex
CGImageSourceGetStatus
CGImageSourceGetStatusAtIndex
Returns the properties of the image source.
CFDictionaryRef CGImageSourceCopyProperties ( CGImageSourceRef isrc, CFDictionaryRef options );
An image source.
A dictionary you can use to request additional options. See “Image Source Option Dictionary Keys” for the keys you can supply.
A dictionary that contains the properties associated with the image source container. See CGImageProperties Reference for a list of properties that can be in the dictionary.
These properties apply to the container in general but not necessarily to any individual image contained in the image source.
CGImageSource.h
Returns the properties of the image at a specified location in an image source.
CFDictionaryRef CGImageSourceCopyPropertiesAtIndex ( CGImageSourceRef isrc, size_t index, CFDictionaryRef options );
An image source.
The index of the image whose properties you want to obtain. The index is zero-based.
A dictionary you can use to request additional options. See “Image Source Option Dictionary Keys”
for the keys you can supply.
A dictionary that contains the properties associated with the image. See CGImageProperties Reference for a list of properties that can be in the dictionary.
CGImageSource.h
Returns an array of uniform type identifiers (UTIs) that are supported for image sources.
CFArrayRef CGImageSourceCopyTypeIdentifiers ( void );
Returns an array of the UTIs that are supported for image sources.
See Uniform Type Identifiers Overview for a list of system-declared and third-party UTIs.
CGImageSource.h
Creates a CGImage object for the image data associated with the specified index in an image source.
CGImageRef CGImageSourceCreateImageAtIndex ( CGImageSourceRef isrc, size_t index, CFDictionaryRef options );
An image source.
The index that specifies the location of the image. The index is zero-based.
A dictionary that specifies additional creation options. See “Image Source Option Dictionary Keys”
for the keys you can supply.
Returns a CGImage object. You are responsible for releasing this object using CGImageRelease
.
CGImageSource.h
Create an incremental image source.
CGImageSourceRef CGImageSourceCreateIncremental ( CFDictionaryRef options );
A dictionary that specifies additional creation options. See “Image Source Option Dictionary Keys”
for the keys you can supply.
Returns an image source object. You are responsible for releasing this object using CFRelease
.
The function CGImageSourceCreateIncremental
creates an empty image source container to which you can add data later by calling the functions CGImageSourceUpdateDataProvider
or CGImageSourceUpdateData
. You don’t provide data when you call this function.
An incremental image is an image that is created in chunks, similar to the way large images viewed over the web are loaded piece by piece.
CGImageSource.h
Creates a thumbnail image of the image located at a specified location in an image source.
CGImageRef CGImageSourceCreateThumbnailAtIndex ( CGImageSourceRef isrc, size_t index, CFDictionaryRef options );
An image source.
The index that specifies the location of the image. The index is zero-based.
A dictionary that specifies additional creation options. See “Image Source Option Dictionary Keys”
for the keys you can supply.
A CGImage object. You are responsible for releasing this object using CGImageRelease
.
If the image source is a PDF, this function creates a 72 dpi image of the PDF page specified by the index that you pass. You must, however, pass an options dictionary that contains either the kCGImageSourceCreateThumbnailFromImageIfAbsent
or kCGImageSourceCreateThumbnailFromImageAlways
keys, with the value of the key set to TRUE
.
CGImageSource.h
Creates an image source that reads from a Core Foundation data object.
CGImageSourceRef CGImageSourceCreateWithData ( CFDataRef data, CFDictionaryRef options );
The data object to read from. For more information on data objects, see CFData Reference and Data Objects.
A dictionary that specifies additional creation options. See “Image Source Option Dictionary Keys”
for the keys you can supply.
An image source. You are responsible for releasing this object using CFRelease
.
CGImageSource.h
Creates an image source that reads data from the specified data provider.
CGImageSourceRef CGImageSourceCreateWithDataProvider ( CGDataProviderRef provider, CFDictionaryRef options );
The data provider to read from. For more information on data providers, see CGDataProvider Reference and Quartz 2D Programming Guide.
A dictionary that specifies additional creation options. See “Image Source Option Dictionary Keys”
for the keys you can supply.
An image source. You are responsible for releasing this object using CFRelease
.
CGImageSource.h
Creates an image source that reads from a location specified by a URL.
CGImageSourceRef CGImageSourceCreateWithURL ( CFURLRef url, CFDictionaryRef options );
The URL to read from.
A dictionary that specifies additional creation options. See “Image Source Option Dictionary Keys”
for the keys you can supply.
An image source. You are responsible for releasing this object using CFRelease
.
CGImageSource.h
Returns the number of images (not including thumbnails) in the image source.
size_t CGImageSourceGetCount ( CGImageSourceRef isrc );
An image source.
The number of images. If the image source is a multilayered PSD file, the function returns 1
.
This function does not extract the layers of a PSD file.
CGImageSource.h
Return the status of an image source.
CGImageSourceStatus CGImageSourceGetStatus ( CGImageSourceRef isrc );
An image source.
Returns the current status of the image source. See “Image Source Status”
for a list of possible values.
The status is particularly informative for incremental image sources, but may also be used by clients that provide non-incremental data.
CGImageSource.h
Returns the current status of an image that is at a specified location in an image source.
CGImageSourceStatus CGImageSourceGetStatusAtIndex ( CGImageSourceRef isrc, size_t index );
An image source.
The index of the image whose status you want to obtain. The index is zero-based.
Returns the current status of the image. See “Image Source Status”
for a list of possible values.
The status is particularly informative for incremental image sources, but may also be used by clients that provide non-incremental data.
CGImageSource.h
Returns the uniform type identifier of the source container.
CFStringRef CGImageSourceGetType ( CGImageSourceRef isrc );
An image source.
The uniform type identifier of the image.
The uniform type identifier (UTI) of the source container can be different from the type of the images in the container. For example, the .icns
format supports embedded JPEG2000
. The type of the source container is "com.apple.icns"
but type of the images is JPEG2000
.
See Uniform Type Identifier Concepts for a list of system-declared and third-party UTIs.
CGImageSource.h
Returns the unique type identifier of an image source opaque type.
CFTypeID CGImageSourceGetTypeID ( void );
Returns the Core Foundation type ID for an image source.
A type identifier is an integer that identifies the opaque type to which a Core Foundation object belongs. You use type IDs in various contexts, such as when you are operating on heterogeneous collections. Note that a CFType ID is different from a uniform type identifier (UTI).
CGImageSource.h
Updates an incremental image source with new data.
void CGImageSourceUpdateData ( CGImageSourceRef isrc, CFDataRef data, bool final );
An image source.
The data to add to the image source. Each time you call the function CGImageSourceUpdateData
, the data
parameter must contain all of the image file data accumulated so far.
A value that specifies whether the data is the final set. Pass true
if it is, false
otherwise.
CGImageSource.h
Updates an incremental image source with a new data provider.
void CGImageSourceUpdateDataProvider ( CGImageSourceRef isrc, CGDataProviderRef provider, bool final );
An image source.
The new data provider. The new data provider must provide all the previous data supplied to the image source plus any additional new data.
A value that specifies whether the data is the final set. Pass true
if it is, false
otherwise.
CGImageSource.h
An opaque type that represents an image source.
typedef struct CGImageSource *CGImageSourceRef;
CGImageSource.h
Status states for images and image sources.
enum CGImageSourceStatus { kCGImageStatusUnexpectedEOF = -5, kCGImageStatusInvalidData = -4, kCGImageStatusUnknownType = -3, kCGImageStatusReadingHeader = -2, kCGImageStatusIncomplete = -1, kCGImageStatusComplete = 0 }; typedef enum CGImageSourceStatus CGImageSourceStatus;
kCGImageStatusUnexpectedEOF
The end of the file was encountered unexpectedly.
Available in Mac OS X v10.4 and later.
Declared in CGImageSource.h
.
kCGImageStatusInvalidData
The data is not valid.
Available in Mac OS X v10.4 and later.
Declared in CGImageSource.h
.
kCGImageStatusUnknownType
The image is an unknown type.
Available in Mac OS X v10.4 and later.
Declared in CGImageSource.h
.
kCGImageStatusReadingHeader
In the process of reading the header.
Available in Mac OS X v10.4 and later.
Declared in CGImageSource.h
.
kCGImageStatusIncomplete
The operation is not complete
Available in Mac OS X v10.4 and later.
Declared in CGImageSource.h
.
kCGImageStatusComplete
The operation is complete.
Available in Mac OS X v10.4 and later.
Declared in CGImageSource.h
.
These status values are returned by the functions CGImageSourceGetStatus
and CGImageSourceGetStatusAtIndex
.
CGImageSource.h
Keys that you can include in the options dictionary to create an image source.
CFStringRef kCGImageSourceTypeIdentifierHint; CFStringRef kCGImageSourceShouldAllowFloat; CFStringRef kCGImageSourceShouldCache; CFStringRef kCGImageSourceCreateThumbnailFromImageIfAbsent; CFStringRef kCGImageSourceCreateThumbnailFromImageAlways; CFStringRef kCGImageSourceThumbnailMaxPixelSize; CFStringRef kCGImageSourceCreateThumbnailWithTransform
kCGImageSourceTypeIdentifierHint
The best guess of the uniform type identifier (UTI) for the format of the image source file. If specified, the value of this key must be a CFString object. This key can be provided in the options dictionary when you create a CGImageSource object.
Available in Mac OS X v10.4 and later.
Declared in CGImageSource.h
.
kCGImageSourceShouldAllowFloat
Whether the image should be returned as a CGImage object that uses floating-point values, if supported by the file format. CGImage objects that use extended-range floating-point values may require additional processing to render in a pleasing manner. The value of this key must be a CFBoolean value. The default value is kCFBooleanFalse
.
Available in Mac OS X v10.4 and later.
Declared in CGImageSource.h
.
kCGImageSourceShouldCache
Whether the image should be cached in a decoded form. The value of this key must be a CFBoolean value. The default value is kCFBooleanTrue
. This key can be provided in the options dictionary that you can pass to the functions CGImageSourceCopyPropertiesAtIndex
and CGImageSourceCreateImageAtIndex
.
Available in Mac OS X v10.4 and later.
Declared in CGImageSource.h
.
kCGImageSourceCreateThumbnailFromImageIfAbsent
Whether a thumbnail should be automatically created for an image if a thumbnail isn't present in the image source file. The thumbnail is created from the full image, subject to the limit specified by kCGImageSourceThumbnailMaxPixelSize
. If a maximum pixel size isn't specified, then the thumbnail is the size of the full image, which in most cases is not desirable. This key must be a CFBoolean value. The default value is kCFBooleanFalse
. This key can be provided in the options dictionary that you pass to the function CGImageSourceCreateThumbnailAtIndex
.
Available in Mac OS X v10.4 and later.
Declared in CGImageSource.h
.
kCGImageSourceCreateThumbnailFromImageAlways
Whether a thumbnail should be created from the full image even if a thumbnail is present in the image source file. The thumbnail is created from the full image, subject to the limit specified by kCGImageSourceThumbnailMaxPixelSize
. If a maximum pixel size isn't specified, then the thumbnail is the size of the full image, which probably isn't what you want. This key must be a CFBoolean value. The default value is kCFBooleanFalse
. This key can be provided in the options dictionary that you can pass to the function CGImageSourceCreateThumbnailAtIndex
.
Available in Mac OS X v10.4 and later.
Declared in CGImageSource.h
.
kCGImageSourceThumbnailMaxPixelSize
The maximum width and height in pixels of a thumbnail. If this key is not specified, the width and height of a thumbnail is not limited and thumbnails may be as big as the image itself. If present, this key must be a CFNumber value. This key can be provided in the options dictionary that you pass to the function CGImageSourceCreateThumbnailAtIndex
.
Available in Mac OS X v10.4 and later.
Declared in CGImageSource.h
.
kCGImageSourceCreateThumbnailWithTransform
Whether the thumbnail should be rotated and scaled according to the orientation and pixel aspect ratio of the full image. The value of this key must be a CFBoolean value. The default value is kCFBooleanFalse
.
Available in Mac OS X v10.4 and later.
Declared in CGImageSource.h
.
Except for kCGImageSourceTypeIdentifierHint
, which you use when creating an image source, these constants specify options that you can set when creating an image from image source. Each constant is a key; you must supply the appropriate value when you add this option to the options dictionary.
CGImageSource.h
© 2004, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-12-04)