Programming Digital Media

The Quartz/Python interface

The Quartz/Python interface The Mac OS X Core Graphics system, or Quartz 2D, is an application programming interface (API) for writing applications for OS X. Apple has also provided a Python wrapper for most of the Quartz library.

This reference is organized by the Python classes used to wrap Quartz 2D functions. The naming scheme in Quartz implies sets of object-based functions which determine the Python class in which the function is located. For example, geometric objects like points and rectangles are contained in the CGGeometry group. Functions in this group, like CGRectIntersection, become in the API methods of the implied object, in this case a rectangle. So in Python, code for rectangle intersection will look like this:

    rectangle_1 = CGRectMake(10, 20, 100, 200) 
    rectangle_2 = CGRectMake(50, 80, 400, 100) 
    rectangular_intersection = rectangle_1.intersection(rectangle_2) 

In the descriptions below, functions that create instances of a class will be marked with the word "creates" at the right side. Methods of a class, on the other hand, are marked with the phrase "method of" at the right. For methods that return a value, the word "returns" and the type of the return value follows the function declaration. The function declarations are not in Python, but use a C-like syntax which puts the type of the argument before the argument name. For example, this is the documentation for the CGRectMake function that creates an instance of CGRect:


creates CGRect
CGRectMake(float x, float y, float width, float height)
Make a rect from (x, y, width, height).

Given a CGRect made with CGRectMake, you can call methods with it. The "returns" value for the intersection method is another CGRect:


method of CGRect
intersection (CGRect r2)      returns CGRect
Return the intersection of r1 and r2. This may return a null rect.

I produced this documentation from file /Developer/Examples/Quartz/Python/API-SUMMARY as described in Apple's documentation using Python and a modicum of brute force. There are still some gray areas, in particular where the Python wrapping isn't easily deduced from the C type. When in doubt, take a look at the API-SUMMARY file. Additional information about the functions that are being wrapped is available in the API documentation of Quartz in which function arguments are more fully described.


Python classes

      CGAffineTransform
      CGPoint
      CGSize
      CGRect
      CGImage
      CGPath
      CGColor
      CGColorSpace
      CGContext
      CGBitmapContext
      CGContext
      CGPDFDocument
      CGPDFPage
      CGPDFArray
      CGPDFContentStream
      CGPDFDictionary
      CGPDFStream
      CGPDFOperatorTable
      CGPDFScanner
      CGPSConverter
      QDPict

Named value types

These types are used in arguments to specify attributes to functions. For example, the CGRectEdge type is used by the divide method of CGRect. For an argument that specifies one of these types, you can use any of the listed values for that type.

CGRectEdge

      CGRectMinXEdge
      CGRectMinYEdge
      CGRectMaxXEdge
      CGRectMaxYEdge

CGPathElementType

      kCGPathElementMoveToPoint
      kCGPathElementAddLineToPoint
      kCGPathElementAddQuadCurveToPoint
      kCGPathElementAddCurveToPoint
      kCGPathElementCloseSubpath

CGLineJoin

      kCGLineJoinMiter
      kCGLineJoinRound
      kCGLineJoinBevel

CGLineCap

      kCGLineCapButt
      kCGLineCapRound
      kCGLineCapSquare

CGPathDrawingMode

      kCGPathFill
      kCGPathEOFill
      kCGPathStroke
      kCGPathFillStroke
      kCGPathEOFillStroke

CGTextDrawingMode

      kCGTextFill
      kCGTextStroke
      kCGTextFillStroke
      kCGTextInvisible
      kCGTextFillClip
      kCGTextStrokeClip
      kCGTextFillStrokeClip
      kCGTextClip

CGTextEncoding

      kCGEncodingFontSpecific
      kCGEncodingMacRoman

CGInterpolationQuality

      kCGInterpolationDefault     Let the context decide.
      kCGInterpolationNone     Never interpolate.
      kCGInterpolationLow     Fast but low quality.
      kCGInterpolationHigh     Slow but high quality.

CGBlendMode

      kCGBlendModeNormal
      kCGBlendModeMultiply
      kCGBlendModeScreen
      kCGBlendModeOverlay
      kCGBlendModeDarken
      kCGBlendModeLighten
      kCGBlendModeColorDodge
      kCGBlendModeColorBurn
      kCGBlendModeSoftLight
      kCGBlendModeHardLight
      kCGBlendModeDifference
      kCGBlendModeExclusion
      kCGBlendModeHue
      kCGBlendModeSaturation
      kCGBlendModeColor
      kCGBlendModeLuminosity

CGImageAlphaInfo

      kCGImageAlphaNone
      kCGImageAlphaPremultipliedLast     Premultiplied RGBA
      kCGImageAlphaPremultipliedFirst     Premultiplied ARGB
      kCGImageAlphaLast     Non-premultiplied RGBA
      kCGImageAlphaFirst     Non-premultiplied ARGB
      kCGImageAlphaNoneSkipLast     Equivalent to kCGImageAlphaNone
      kCGImageAlphaNoneSkipFirst

CGImageSourceStatus

      kCGImageStatusUnexpectedEOF
      kCGImageStatusInvalidData
      kCGImageStatusUnknownType
      kCGImageStatusReadingHeader
      kCGImageStatusIncomplete
      kCGImageStatusComplete

CGPDFBox

      kCGPDFMediaBox
      kCGPDFCropBox
      kCGPDFBleedBox
      kCGPDFTrimBox
      kCGPDFArtBox

CGPDFDataFormat

      CGPDFDataFormatRaw
      CGPDFDataFormatJPEGEncoded


Classes


CGAffineTransform

float a, b, c, d
float x, y
Instance variables.

creates CGAffineTransform
CGAffineTransformMake(float a, float b, float c, float d, float tx, float ty)
Return the transform [ a b c d tx ty ].

creates CGAffineTransform
CGAffineTransformMakeTranslation(float tx, float ty)
Return a transform which translates by (tx, ty) t' = [ 1 0 0 1 tx ty ]

creates CGAffineTransform
CGAffineTransformMakeScale(float sx, float sy)
Return a transform which scales by (sx, sy) t' = [ sx 0 0 sy 0 0 ]

creates CGAffineTransform
CGAffineTransformMakeRotation(float angle)
Return a transform which rotates by angle radians: t' = [ cos(angle) sin(angle) -sin(angle) cos(angle) 0 0 ]

method of CGAffineTransform
translate (float tx, float ty)       returns CGAffineTransform
Translate t by (tx, ty) and return the result: t' = [ 1 0 0 1 tx ty ] * t

method of CGAffineTransform
scale (float sx, float sy)       returns CGAffineTransform
Scale t by (sx, sy) and return the result: t' = [ sx 0 0 sy 0 0 ] * t

method of CGAffineTransform
rotate (float angle)       returns CGAffineTransform
Rotate t by angle radians and return the result: t' = [ cos(angle) sin(angle) -sin(angle) cos(angle) 0 0 ] * t

method of CGAffineTransform
invert ()       returns CGAffineTransform
Invert t and return the result. If t has zero determinant, then t is returned unchanged.

method of CGAffineTransform
concat (CGAffineTransform t2)       returns CGAffineTransform
Concatenate t2 to t1 and return the result: t' = t1 * t2

method of CGAffineTransform
equalToTransform(CGAffineTransform t2)       returns bool
Return true if t1 and t2 are equal, false otherwise.

method of CGAffineTransform
transformIsIdentity ()       returns bool
Return true if t is the identity transform, false otherwise.


CGPoint

float x
float y
Instance variables.

creates CGPoint
CGPointMake(float x, float y)
Make a point from (x, y).

method of CGPoint
equalToPoint (CGPoint point2)       returns bool
Return true if point1 and point2 are the same, 0 otherwise.

method of CGPoint
applyAffineTransform (CGAffineTransform t)       returns CGPoint
Transform point by t and return the result: p' = p * t where p = [ x y 1 ].


CGSize

float width
float height
Instance variables.

creates CGSize
CGSizeMake(float width, float height)
Make a size from (width, height).

method of CGSize
equalToSize (CGSize size2)       returns bool
Return true if size1 and size2 are the same, 0 otherwise.

method of CGSize
applyAffineTransform (CGAffineTransform t)       returns CGSize
Transform size by t and return the result: s' = s * t where s = [ width height 0 ].


CGRect

CGPoint origin
CGSize size
Instance variables.

creates CGRect
CGRectMake(float x, float y, float width, float height)
Make a rect from (x, y; width, height).

creates CGRect
CGContextMeasurePlainTextInRect (CGDataProviderRef provider, CGRect rect, float fontSize = 0)
Convenience function for measuring text.

creates CGRect
CGContextMeasureRTFTextInRect (CGDataProviderRef provider, CGRect rect, float fontSize = 0)
Convenience function for measuring text.

creates CGRect
CGContextMeasureDocFormatTextInRect (CGDataProviderRef provider, CGRect rect, float fontSize = 0)
Convenience function for measuring text.

creates CGRect
CGContextMeasureHTMLTextInRect (CGDataProviderRef provider, CGRect rect, float fontSize = 0)
Convenience function for measuring text.

method of CGRect
getMinX ()       returns float
Return the leftmost x-value of rect.

method of CGRect
getMidX ()       returns float
Return the midpoint x-value of rect.

method of CGRect
getMaxX ()       returns float
Return the rightmost x-value of rect.

method of CGRect
getMinY ()       returns float
Return the bottommost y-value of rect.

method of CGRect
getMidY ()       returns float
Return the midpoint y-value of rect.

method of CGRect
getMaxY ()       returns float
Return the topmost y-value of rect.

method of CGRect
getWidth ()       returns float
Return the width of rect.

method of CGRect
getHeight ()       returns float
Return the height of rect.

method of CGRect
equalToRect (CGRect rect2)       returns bool
Return true if rect1 and rect2 are the same, 0 otherwise.

method of CGRect
standardize ()       returns CGRect
Standardize rect — i.e., convert it to an equivalent rect which has positive width and height.

method of CGRect
isEmpty ()       returns bool
Return true if rect is empty — i.e., if it has zero width or height. A null rect is defined to be empty.

method of CGRect
isNull ()       returns bool
Return true if rect is null — e.g., the result of intersecting two disjoint rectangles is a null rect.

method of CGRect
isInfinite ()       returns bool
Return true if rect is the infinite rectangle, false otherwise.

method of CGRect
inset (float dx, float dy)       returns CGRect
Inset rect by (dx, dy) — i.e., offset its origin by (dx, dy), and decrease its size by (2*dx, 2*dy).

method of CGRect
integral ()       returns CGRect
Expand rect to the smallest rect containing it with integral origin and size.

method of CGRect
Union (CGRect r2)       returns CGRect
Return the union of r1 and r2. NOTE: the python/perl methods are actually called 'union'.

method of CGRect
intersection (CGRect r2)       returns CGRect
Return the intersection of r1 and r2. This may return a null rect.

method of CGRect
offset (float dx, float dy)       returns CGRect
Offset rect by (dx, dy).

method of CGRect
divide (CGRect *slice, CGRect *remainder, float amount, CGRectEdge edge)      
Make two new rectangles, slice and remainder, by dividing rect with a line that's parallel to one of its sides, specified by edge — either CGRectMinXEdge, CGRectMinYEdge, CGRectMaxXEdge, or CGRectMaxYEdge. The size of slice is determined by amount, which measures the distance from the specified edge.

method of CGRect
containsPoint (CGPoint point)       returns bool
Return true if point is contained in rect, 0 otherwise.

method of CGRect
containsRect (CGRect rect2)       returns bool
Return true if rect2 is contained in rect1, 0 otherwise. rect2 is contained in rect1 if the union of rect1 and rect2 is equal to rect1.

method of CGRect
intersectsRect (CGRect rect2)       returns bool
Return true if rect1 intersects rect2, 0 otherwise. rect1 intersects rect2 if the intersection of rect1 and rect2 is not the null rect.

method of CGRect
applyAffineTransform (CGAffineTransform t)       returns CGRect
Transform rect by t and return the result. Since affine transforms do not preserve rectangles in general, this function returns the smallest rectangle which contains the transformed corner points of rect. If t consists solely of scales, flips and translations, then the returned rectangle coincides with the rectangle constructed from the four transformed corners.


CGImage

creates CGImage
CGImageCreate(size_t width, size_t height, size_t bitsPerComponent, size_t bitsPerPixel, size_t bytesPerRow, CGColorSpaceRef colorspace, CGImageAlphaInfo alphaInfo, CGDataProviderRef provider, const float decode[10], bool shouldInterpolate, CGColorRenderingIntent intent)
Create an image.

creates CGImage
CGImageMaskCreate(size_t width, size_t height, size_t bitsPerComponent, size_t bitsPerPixel, size_t bytesPerRow, CGDataProviderRef provider, const float decode[10], bool shouldInterpolate)
Create an image mask.

creates CGImage
CGImageCreateWithJPEGDataProvider(CGDataProviderRef source, const float decode[10], bool shouldInterpolate, CGColorRenderingIntent intent)
Create an image from source, a data provider of JPEG-encoded data.

creates CGImage
CGImageCreateWithPNGDataProvider(CGDataProviderRef source, const float decode[10], bool shouldInterpolate, CGColorRenderingIntent intent)
Create an image using source, a data provider for PNG-encoded data.

creates CGImage
CGImageCreate(size_t width, size_t height, size_t bitsPerComponent, size_t bitsPerPixel, size_t bytesPerRow, CGColorSpaceRef colorspace, CGImageAlphaInfo alphaInfo, CGDataProviderRef provider, const float decode[10], bool shouldInterpolate, CGColorRenderingIntent intent)
Create a new data provider that will read data from the file 'filename'.

creates CGImage
CGImageMaskCreate(size_t width, size_t height, size_t bitsPerComponent, size_t bitsPerPixel, size_t bytesPerRow, CGDataProviderRef provider, const float decode[10], bool shouldInterpolate)
Create an image mask.

creates CGImage
CGImageCreateWithJPEGDataProvider(CGDataProviderRef source, const float decode[10], bool shouldInterpolate, CGColorRenderingIntent intent)
Create an image from source, a data provider of JPEG-encoded data.

creates CGImage
CGImageCreateWithPNGDataProvider(CGDataProviderRef source, const float decode[10], bool shouldInterpolate, CGColorRenderingIntent intent)
Create an image using source, a data provider for PNG-encoded data.

creates CGImage
CGImageCreateWithDataProvider (CGDataProviderRef source)
Create an image using source, a data provider with data encoded using one of the standard image formats.

creates CGImage
CGImageImport (CGDataProviderRef source)
Create an image using source, a data provider with data encoded using one of the image formats supported by ImageIO.

creates CGImage
CGImageImportWithAffineTransform (CGDataProviderRef source, CGAffineTransform *OUTPUT)
Create an image using source, a data provider with data encoded using one of the image formats supported by QuickTime graphics importers. The returned affine transform has the necessary scale factors to map the created image to 72dpi.

method of CGImage
isMask ()       returns bool
Return true if image is an image mask, false otherwise.

method of CGImage
getWidth ()       returns integer
Return the width of image.

method of CGImage
getHeight ()       returns integer
Return the height of image.

method of CGImage
getBitsPerComponent ()       returns integer
Return the number of bits/component of image.

method of CGImage
getBitsPerPixel ()       returns integer
Return the number of bits/pixel of image.

method of CGImage
getBytesPerRow ()       returns integer
Return the number of bytes/row of image.

method of CGImage
getColorSpace ()       returns CGColorSpaceRef
Return the colorspace of image, or NULL if image is an image mask.

method of CGImage
getAlphaInfo ()       returns CGImageAlphaInfo
Return the alpha info of image.

method of CGImage
getDataProvider ()       returns CGDataProviderRef
Return the data provider of image.

method of CGImage
getDecode ()       returns float list
Return the decode array of image.

method of CGImage
getShouldInterpolate ()       returns bool
Return the interpolation parameter of image.

method of CGImage
getRenderingIntent ()       returns CGColorRenderingIntent
Return the rendering intent of image.

method of CGImage
getBitmapInfo ()       returns CGBitmapInfo
Return the bitmap info of image.

method of CGImage
createWithImageInRect (CGRect rect)       returns CGImageRef
Create an image using the data contained within the subrectangle rect of image. The new image is created by 1) adjusting rect to integral bounds by calling "CGRectIntegral"; 2) intersecting the result with a rectangle with origin (0, 0) and size equal to the size of image 3) referencing the pixels within the resulting rectangle, treating the first pixel of the image data as the origin of the image. If the resulting rectangle is the null rectangle, this function returns NULL. If W and H are the width and height of image, respectively, then the point (0,0) corresponds to the first pixel of the image data; the point (W-1, 0) is the last pixel of the first row of the image data; (0, H-1) is the first pixel of the last row of the image data; and (W-1, H-1) is the last pixel of the last row of the image data. The resulting image retains a reference to the original image, so you may release the original image after calling this function.

method of CGImage
createWithMask (CGImageRef mask)       returns CGImageRef
Create a new image from image masked by mask, which may be an image mask or an image. If mask is an image mask, then it indicates which parts of the context are to be painted with the image when drawn in a context, and which are to be masked out (left unchanged). The source samples of the image mask determine which areas are painted, acting as an "inverse alpha": if the value of a source sample in the image mask is S, then the corresponding region in image is blended with the destination using an alpha of (1-S). (For example, if S is 1, then the region is not painted, while if S is 0, the region is fully painted.) If mask is an image, then it serves as alpha mask for blending the image onto the destination. The source samples of mask determine which areas are painted: if the value of the source sample in mask is S, then the corresponding region in image is blended with the destination with an alpha of S. (For example, if S is 0, then the region is not painted, while if S is 1, the region is fully painted.) The parameter image may not be an image mask and may not have an image mask or masking color associated with it. If mask is an image, then it must be in the DeviceGray color space, may not have alpha, and may not itself be masked by an image mask or a masking color.

method of CGImage
createWithMaskingColors (float components[8])       returns CGImageRef
Create a new image from image masked by components, an array of 2N values { min[1], max[1], ... min[N], max[N] } where N is the number of components in color space of image. Any image sample with color value {c[1], ... c[N]} where min[i] <= c[i] <= max[i] for 1 <= i <= N is masked out (that is, not painted). Each value in components must be a valid image sample value: if image has integral pixel components, then each value of must be in the range [0 .. 2**bitsPerComponent - 1] (where bitsPerComponent is the number of bits/component of image if image has floating-point pixel components, then each value may be any floating-point number which is a valid color component. The parameter image may not be an image mask, and may not already have an image mask or masking color associated with it.


CGPath

creates CGPath
CGPathCreateCopy(CGPathRef path)
Create a copy of path.

method of CGPath
equalToPath (CGPathRef path2)       returns bool
Return true if path1 is equal to path2 false otherwise.

method of CGPath
isEmpty ()       returns bool
Return true if path contains no elements, false otherwise.

method of CGPath
isRect (CGRect *rect)       returns bool
Return true if path represents a rectangle, false otherwise.

method of CGPath
getCurrentPoint ()       returns CGPoint
Return the current point of the current subpath of path. If there is no current point, then return CGPointZero.

method of CGPath
getBoundingBox ()       returns CGRect
Return the bounding box of path. The bounding box is the smallest rectangle completely enclosing all points in the path, including control points for Bezier and quadratic curves. If the path is empty, then return CGRectNull.

method of CGPath
containsPoint (CGAffineTransform *m, CGPoint point, bool eoFill)       returns bool
Return true if point is contained in path false otherwise. A point is contained in a path if it is inside the painted region when the path is filled; if eoFill is true, then the even-odd fill rule is used to evaluate the painted region of the path, otherwise, the winding-number fill rule is used. If m is non-NULL, then the point is transformed by m before determining whether the path contains it.

method of CGPath
moveToPoint (CGAffineTransform *m, float x, float y)      
Move the current point to (x, y) in path and begin a new subpath. If m is non-NULL, then transform (x, y) by m first.

method of CGPath
addLineToPoint (CGAffineTransform *m, float x, float y)      
Append a straight line segment from the current point to (x, y) in path and move the current point to (x, y). If m is non-NULL, then transform (x, y) by m first.

method of CGPath
addQuadCurveToPoint (CGAffineTransform *m, float cpx, float cpy, float x, float y)      
Append a quadratic curve from the current point to (x, y) with control point (cpx, cpy) in path and move the current point to (x, y). If m is non-NULL, then transform all points by m first.

method of CGPath
addCurveToPoint (CGAffineTransform *m, float cp1x, float cp1y, float cp2x, float cp2y, float x, float y)      
Append a cubic Bezier curve from the current point to (x,y) with control points (cp1x, cp1y) and (cp2x, cp2y) in path and move the current point to (x, y). If m is non-NULL, then transform all points by m first.

method of CGPath
closeSubpath ()      
Append a line from the current point to the starting point of the current subpath of path and end the subpath.

method of CGPath
addRect (CGAffineTransform *m, CGRect rect)      
Add rect to path. If m is non-NULL, then first transform rect by m before adding it to path.

method of CGPath
addRects (CGAffineTransform *m, CGRect rects[], size_t count)      
Add each rectangle specified by rects, an array of count CGRects, to path. If m is non-NULL, then first transform each rectangle by m before adding it to path.

method of CGPath
addLines (CGAffineTransform *m, CGPoint points[], size_t count)      
Move to the first element of points, an array of count CGPoints, and append a line from each point to the next point in points. If m is non-NULL, then first transform each point by m.

method of CGPath
addArc (CGAffineTransform *m, float x, float y, float radius, float startAngle, float endAngle, bool clockwise)      
Add an arc of a circle to path, possibly preceded by a straight line segment. The arc is approximated by a sequence of cubic Bezier curves. (x, y) is the center of the arc; radius is its radius; startAngle is the angle to the first endpoint of the arc; endAngle is the angle to the second endpoint of the arc; and clockwise is true if the arc is to be drawn clockwise, false otherwise. startAngle and endAngle are measured in radians. If m is non-NULL, then the constructed Bezier curves representing the arc will be transformed by m before they are added to path.

method of CGPath
addArcToPoint (CGAffineTransform *m, float x1, float y1, float x2, float y2, float radius)      
Add an arc of a circle to path, possibly preceded by a straight line segment. The arc is approximated by a sequence of cubic Bezier curves. radius is the radius of the arc. The resulting arc is tangent to the line from the current point of path to (x1, y1), and the line from (x1, y1) to (x2, y2). If m is non-NULL, then the constructed Bezier curves representing the arc will be transformed by m before they are added to path.

method of CGPath
addPath (CGAffineTransform *m, CGPathRef path2)      
Add path2 to path1. If m is non-NULL, then the points in path2 will be transformed by m before they are added to path1.


CGColor

creates CGColor
CGColorCreate(CGColorSpaceRef colorspace, const float components[5])
Create a color in colorspace colorspace with color components (including alpha) specified by components. colorspace may be any colorspace expect a pattern colorspace.

creates CGColor
CGColorCreateWithPattern(CGColorSpaceRef colorspace, CGPatternRef pattern, const float components[5])
Create a color in colorspace colorspace with pattern pattern and components components. colorspace must be a pattern colorspace.

method of CGColor
equalToColor (CGColorRef color2)       returns bool
Return true if color1 is equal to color2 false otherwise.

method of CGColor
getNumberOfComponents ()       returns integer
Return the number of color components (including alpha) associated with color.

method of CGColor
getComponents ()       returns float list
Return the color components associated with color.

method of CGColor
getAlpha ()       returns float
Return the alpha component associated with color.

method of CGColor
getColorSpace ()       returns CGColorSpaceRef
Return the colorspace associated with color.

method of CGColor
getPattern ()       returns CGPatternRef
Return the pattern associated with color, if it's a color in a pattern colorspace; NULL otherwise.


CGColorSpace

creates CGColorSpace
CGColorSpaceCreateDeviceGray()
Use "kCGColorSpaceGenericGray" instead.

creates CGColorSpace
CGColorSpaceCreateDeviceRGB()
Create a DeviceRGB colorspace.

creates CGColorSpace
CGColorSpaceCreateDeviceCMYK()
Create a DeviceCMYK colorspace.

creates CGColorSpace
CGColorSpaceCreateCalibratedGray(const float whitePoint[3], const float blackPoint[3], float gamma)
Create a calibrated gray colorspace. whitePoint is an array of 3 numbers specifying the tristimulus value, in the CIE 1931 XYZ-space, of the diffuse white point. blackPoint is an array of 3 numbers specifying the tristimulus value, in CIE 1931 XYZ-space, of the diffuse black point. gamma defines the gamma for the gray component.

creates CGColorSpace
CGColorSpaceCreateCalibratedRGB(const float whitePoint[3], const float blackPoint[3], const float gamma[3], const float matrix[9])
Create a calibrated RGB colorspace. whitePoint is an array of 3 numbers specifying the tristimulus value, in the CIE 1931 XYZ-space, of the diffuse white point. blackPoint is an array of 3 numbers specifying the tristimulus value, in CIE 1931 XYZ-space, of the diffuse black point. gamma is an array of 3 numbers specifying the gamma for the red, green, and blue components of the color space. matrix is an array of 9 numbers specifying the linear interpretation of the gamma-modified RGB values of the colorspace with respect to the final XYZ representation.

creates CGColorSpace
CGColorSpaceCreateLab(const float whitePoint[3], const float blackPoint[3], const float range[4])
Create an L*a*b* colorspace. whitePoint is an array of 3 numbers specifying the tristimulus value, in the CIE 1931 XYZ-space, of the diffuse white point. blackPoint is an array of 3 numbers specifying the tristimulus value, in CIE 1931 XYZ-space, of the diffuse black point. range is an array of four numbers specifying the range of valid values for the a* and b* components of the color space.

creates CGColorSpace
CGColorSpaceCreateIndexed(CGColorSpaceRef baseSpace, size_t lastIndex, const unsigned char *colorTable)
Create an indexed colorspace. A sample value in an indexed color space is treated as an index into the color table of the color space. base specifies the base color space in which the values in the color table are to be interpreted. lastIndex is an integer which specifies the maximum valid index value; it must be less than or equal to 255. colorTable is an array of m * (lastIndex + 1) bytes, where m is the number of color components in the base color space. Each byte is an unsigned integer in the range 0 to 255 that is scaled to the range of the corresponding color component in the base color space.

creates CGColorSpace
CGColorSpaceCreatePattern(CGColorSpaceRef baseSpace)
Create a pattern colorspace. baseSpace is the underlying colorspace of the pattern colorspace. For colored patterns, baseSpace should be NULL; for uncolored patterns, baseSpace specifies the colorspace of colors which will be painted through the pattern.

creates CGColorSpace
CGColorSpaceCreateWithPlatformColorSpace(void *platformColorSpaceReference)
Create a CGColorSpace using platformColorSpaceReference, a pointer to a platform-specific color space reference. For MacOS X, platformColorSpaceReference should be a pointer to a CMProfileRef.

creates CGColorSpace
CGColorSpaceCreateWithName(CFStringRef name)
Create a colorspace using name as the identifier for the colorspace.

method of CGColorSpace
getNumberOfComponents ()       returns integer
Return the number of color components in the colorspace cs.


CGContext

creates CGContext
CGPatternGetContext (void *handle)
Given a handle returned by CGPatternBegin, returns a context that can be used to define the contents of the pattern cell.

creates CGContext
CGBitmapContextCreateWithColor (size_t width, size_t height, CGColorSpaceRef colorspace, const float color[5], CFDictionaryRef auxInfo = NULL)
Create a bitmap context. The context draws into a bitmap which is width pixels wide and height pixels high. The number of components for each pixel is specified by colorspace, which also may specify a destination color profile. The number of bits for each component of a pixel is specified by bitsPerComponent, which must be 1, 2, 4, or 8. Each row of the bitmap consists of bytesPerRow bytes, which must be at least (width * bitsPerComponent * number of components + 7)/8 bytes. data points a block of memory at least bytesPerRow * height bytes. alphaInfo specifies whether the bitmap should contain an alpha channel, and how it's to be generated.

creates CGContext
CGPDFContextCreateWithFilename (char *filename, const CGRect *mediaBox, CFDictionaryRef auxiliaryInfo = NULL)
Format specifiers for writeToDataConsumer/writeToFile

method of CGContext
saveGState ()      
Push a copy of the current graphics state onto the graphics state stack. Note that the path is not considered part of the gstate, and is not saved.

method of CGContext
restoreGState ()      
Restore the current graphics state from the one on the top of the graphics state stack, popping the graphics state stack in the process.

method of CGContext
scaleCTM (float sx, float sy)      
Scale the current graphics state's transformation matrix (the CTM) by (sx, sy).

method of CGContext
translateCTM (float tx, float ty)      
Translate the current graphics state's transformation matrix (the CTM) by (tx, ty).

method of CGContext
rotateCTM (float angle)      
Rotate the current graphics state's transformation matrix (the CTM) by angle radians.

method of CGContext
concatCTM (CGAffineTransform transform)      
Concatenate the current graphics state's transformation matrix (the CTM) with the affine transform transform.

method of CGContext
getCTM ()       returns CGAffineTransform
Return the current graphics state's transformation matrix.

method of CGContext
setLineWidth (float width)      
Set the line width in the current graphics state to width.

method of CGContext
setLineCap (CGLineCap cap)      
Set the line cap in the current graphics state to cap.

method of CGContext
setLineJoin (CGLineJoin join)      
Set the line join in the current graphics state to join.

method of CGContext
setMiterLimit (float limit)      
Set the miter limit in the current graphics state to limit.

method of CGContext
setLineDash (float phase, float *lengths, size_t count)      
Set the line dash patttern in the current graphics state.

method of CGContext
setFlatness (float flatness)      
Set the path flatness parameter in the current graphics state to flatness.

method of CGContext
setAlpha (float alpha)      
Set the alpha value in the current graphics state to alpha.

method of CGContext
setBlendMode (CGBlendMode mode)      
Set the blend mode of context to mode.

method of CGContext
beginPath ()      
Begin a new path. The old path is discarded.

method of CGContext
moveToPoint (float x, float y)      
Start a new subpath at point (x, y) in the context's path.

method of CGContext
addLineToPoint (float x, float y)      
Append a straight line segment from the current point to (x, y).

method of CGContext
addCurveToPoint (float cp1x, float cp1y, float cp2x, float cp2y, float x, float y)      
Append a cubic Bezier curve from the current point to (x,y), with control points (cp1x, cp1y) and (cp2x, cp2y).

method of CGContext
addQuadCurveToPoint (float cpx, float cpy, float x, float y)      
Append a quadratic curve from the current point to (x, y), with control point (cpx, cpy).

method of CGContext
closePath ()      
Close the current subpath of the context's path.

method of CGContext
addRect (CGRect rect)      
Add a single rect to the context's path.

method of CGContext
addRects (CGRect rects[], size_t count)      
Add a set of rects to the context's path.

method of CGContext
addLines (CGPoint points[], size_t count)      
Add a set of lines to the context's path.

method of CGContext
addEllipseInRect (CGRect rect)      
Add an ellipse inside rect to the current path of context. See the function CGPathAddEllipseInRect for more information on how the path for the ellipse is constructed.

method of CGContext
addArc (float x, float y, float radius, float startAngle, float endAngle, int clockwise)      
Add an arc of a circle to the context's path, possibly preceded by a straight line segment. (x, y) is the center of the arc; radius is its radius; startAngle is the angle to the first endpoint of the arc; endAngle is the angle to the second endpoint of the arc; and clockwise is 1 if the arc is to be drawn clockwise, 0 otherwise. startAngle and endAngle are measured in radians.

method of CGContext
addArcToPoint (float x1, float y1, float x2, float y2, float radius)      
Add an arc of a circle to the context's path, possibly preceded by a straight line segment. radius is the radius of the arc. The arc is tangent to the line from the current point to (x1, y1), and the line from (x1, y1) to (x2, y2).

method of CGContext
addPath (CGPathRef path)      
Add path to the path of context. The points in path are transformed by the CTM of context before they are added.

method of CGContext
replacePathWithStrokedPath ()      
Replace the path in context with the stroked version of the path, using the parameters of context to calculate the stroked path. The resulting path is created such that filling it with the appropriate color will produce the same results as stroking the original path. You can use this path in the same way you can use the path of any context; for example, you can clip to the stroked version of a path by calling this function followed by a call to "CGContextClipPath".

method of CGContext
isPathEmpty ()       returns bool
Return 1 if the context's path contains no elements, 0 otherwise.

method of CGContext
getPathCurrentPoint ()       returns CGPoint
Return the current point of the current subpath of the context's path.

method of CGContext
getPathBoundingBox ()       returns CGRect
Return the bounding box of the context's path. The bounding box is the smallest rectangle completely enclosing all points in the path, including control points for Bezier and quadratic curves.

method of CGContext
pathContainsPoint(CGPoint point, CGPathDrawingMode mode)       returns bool
Return true if point is contained in the current path of context. A point is contained within a context's path if it is inside the painted region when the path is stroked or filled with opaque colors using the path drawing mode mode. point is specified is user space.

method of CGContext
drawPath (CGPathDrawingMode mode)      
Draw the context's path using drawing mode mode.

method of CGContext
fillPath ()      
Fill the context's path using the winding-number fill rule. Any open subpath of the path is implicitly closed.

method of CGContext
eoFillPath ()      
Fill the context's path using the even-odd fill rule. Any open subpath of the path is implicitly closed.

method of CGContext
strokePath ()      
Stroke the context's path.

method of CGContext
fillRect (CGRect rect)      
Fill rect with the current fill color.

method of CGContext
fillRects (CGRect rects[], size_t count)      
Fill rects, an array of count CGRects, with the current fill color.

method of CGContext
strokeRect (CGRect rect)      
Stroke rect with the current stroke color and the current linewidth.

method of CGContext
strokeRectWithWidth (CGRect rect, float width)      
Stroke rect with the current stroke color, using width as the the line width.

method of CGContext
clearRect (CGRect rect)      
Clear rect (that is, set the region within the rect to transparent).

method of CGContext
fillEllipseInRect (CGRect rect)      
Fill an ellipse (an oval) inside rect.

method of CGContext
strokeEllipseInRect (CGRect rect)      
Stroke an ellipse (an oval) inside rect.

method of CGContext
strokeLineSegments (CGPoint points[], size_t count)      
Stroke a sequence of line segments one after another in context. The line segments are specified by points, an array of count CGPoints. This function is equivalent to CGContextBeginPath(context); for (k = 0; k < count; k += 2) { CGContextMoveToPoint(context, s[k].x, s[k].y); CGContextAddLineToPoint(context, s[k+1].x, s[k+1].y); } CGContextStrokePath(context);

method of CGContext
clip ()      
Intersect the context's path with the current clip path and use the resulting path as the clip path for subsequent rendering operations. Use the winding-number fill rule for deciding what's inside the path.

method of CGContext
eoClip ()      
Intersect the context's path with the current clip path and use the resulting path as the clip path for subsequent rendering operations. Use the even-odd fill rule for deciding what's inside the path.

method of CGContext
clipToMask (CGRect rect, CGImageRef mask)      
Add mask transformed to rect to the clipping area of context. The mask, which may be either an image mask or an image, is mapped into the specified rectangle and intersected with the current clipping area of the context. If mask is an image mask, then it clips in a manner identical to the behavior if it were used with "CGContextDrawImage": it indicates an area to be masked out (left unchanged) when drawing. The source samples of the image mask determine which points of the clipping area are changed, acting as an "inverse alpha": if the value of a source sample in the image mask is S, then the corresponding point in the current clipping area will be multiplied by an alpha of (1-S). (For example, if S is 1, then the point in the clipping area becomes clear, while if S is 0, the point in the clipping area is unchanged. If mask is an image, then it serves as alpha mask and is blended with the current clipping area. The source samples of mask determine which points of the clipping area are changed: if the value of the source sample in mask is S, then the corresponding point in the current clipping area will be multiplied by an alpha of S. (For example, if S is 0, then the point in the clipping area becomes clear, while if S is 1, the point in the clipping area is unchanged. If mask is an image, then it must be in the DeviceGray color space, may not have alpha, and may not be masked by an image mask or masking color.

method of CGContext
clipToRect (CGRect rect)      
Intersect the current clipping path with rect. Note that this function resets the context's path to the empty path.

method of CGContext
clipToRects (CGRect rects[], size_t count)      
Intersect the current clipping path with the clipping region formed by creating a path consisting of all rects in rects. Note that this function resets the context's path to the empty path.

method of CGContext
setFillColorWithColor(CGColorRef color)      
Set the current fill color in the context c to color.

method of CGContext
setStrokeColorWithColor(CGColorRef color)      
Set the current stroke color in the context c to color.

method of CGContext
setFillColorSpace (CGColorSpaceRef colorspace)      
Set the current fill colorspace in the context c to colorspace. As a side-effect, set the fill color to a default value appropriate for the colorspace.

method of CGContext
setStrokeColorSpace (CGColorSpaceRef colorspace)      
Set the current stroke colorspace in the context c to colorspace. As a side-effect, set the stroke color to a default value appropriate for the colorspace.

method of CGContext
setFillColor (float components[5])      
Set the components of the current fill color in the context c to the values specifed by components. The number of elements in components must be one greater than the number of components in the current fill colorspace (N color components + 1 alpha component). The current fill colorspace must not be a pattern colorspace.

method of CGContext
setStrokeColor (float components[5])      
Set the components of the current stroke color in the context c to the values specifed by components. The number of elements in components must be one greater than the number of components in the current stroke colorspace (N color components + 1 alpha component). The current stroke colorspace must not be a pattern colorspace.

method of CGContext
setFillPattern (CGPatternRef pattern, float components[5])      
Set the components of the current fill color in the context c to the values specifed by components, and set the current fill pattern to pattern. The number of elements in components must be one greater than the number of components in the current fill colorspace (N color components + 1 alpha component). The current fill colorspace must be a pattern colorspace.

method of CGContext
setStrokePattern (CGPatternRef pattern, float components[5])      
Set the components of the current stroke color in the context c to the values specifed by components, and set the current stroke pattern to pattern. The number of elements in components must be one greater than the number of components in the current stroke colorspace (N color components + 1 alpha component). The current stroke colorspace must be a pattern colorspace.

method of CGContext
setPatternPhase (CGSize phase)      
Set the pattern phase of context c to phase.

method of CGContext
setGrayFillColor (float gray, float alpha)      
Set the current fill colorspace in the context c to DeviceGray and set the components of the current fill color to (gray, alpha).

method of CGContext
setGrayStrokeColor (float gray, float alpha)      
Set the current stroke colorspace in the context c to DeviceGray and set the components of the current stroke color to (gray, alpha).

method of CGContext
setRGBFillColor (float red, float green, float blue, float alpha)      
Set the current fill colorspace in the context c to DeviceRGB and set the components of the current fill color to (red, green, blue, alpha).

method of CGContext
setRGBStrokeColor (float red, float green, float blue, float alpha)      
Set the current stroke colorspace in the context c to DeviceRGB and set the components of the current stroke color to (red, green, blue, alpha).

method of CGContext
setCMYKFillColor (float cyan, float magenta, float yellow, float black, float alpha)      
Set the current fill colorspace in the context c to DeviceCMYK and set the components of the current fill color to (cyan, magenta, yellow, black, alpha).

method of CGContext
setCMYKStrokeColor (float cyan, float magenta, float yellow, float black, float alpha)      
Set the current stroke colorspace in the context c to DeviceCMYK and set the components of the current stroke color to (cyan, magenta, yellow, black, alpha).

method of CGContext
setRenderingIntent (CGColorRenderingIntent intent)      
Set the current rendering intent in the context c to intent.

method of CGContext
drawImage (CGRect rect, CGImageRef image)      
Draw image in the rectangular area specified by rect in the context c. The image is scaled, if necessary, to fit into rect.

method of CGContext
getInterpolationQuality ()       returns CGInterpolationQuality
Return the interpolation quality for image rendering of the context c. The interpolation quality is a gstate-parameter which controls the level of interpolation performed when an image is interpolated (for example, when scaling the image). Note that it is merely a hint to the context: not all contexts support all interpolation quality levels.

method of CGContext
setInterpolationQuality (CGInterpolationQuality quality)      
Set the interpolation quality of the context c to quality.

method of CGContext
setShadowWithColor (CGSize offset, float blur, CGColorRef color)      
Set the shadow parameters in context. offset specifies a translation in base-space; blur is a non-negative number specifying the amount of blur; color specifies the color of the shadow, which may contain a non-opaque alpha value. If color is NULL, it's equivalent to specifying a fully transparent color. The shadow is a gstate parameter. After a shadow is specified, all objects drawn subsequently will be shadowed. To turn off shadowing, set the shadow color to a fully transparent color (or pass NULL as the color), or use the standard gsave/grestore mechanism.

method of CGContext
setShadow (CGSize offset, float blur)      
Equivalent to calling CGContextSetShadowWithColor(context, offset, blur, color) where color is black with 1/3 alpha (i.e., RGBA = {0, 0, 0, 1.0/3.0}) in the DeviceRGB colorspace.

method of CGContext
drawShading (CGShadingRef shading)      
Fill the current clipping region of c with shading.

method of CGContext
setCharacterSpacing (float spacing)      
Set the current character spacing in the context c to spacing. The character spacing is added to the displacement between the origin of one character and the origin of the next.

method of CGContext
setTextPosition (float x, float y)      
Set the user-space point at which text will be drawn in the context c to (x, y).

method of CGContext
getTextPosition ()       returns CGPoint
Return the user-space point at which text will be drawn in the context c.

method of CGContext
setTextMatrix (CGAffineTransform t)      
Set the text matrix in the context c to t.

method of CGContext
getTextMatrix ()       returns CGAffineTransform
Return the text matrix in the context c.

method of CGContext
setTextDrawingMode (CGTextDrawingMode mode)      
Set the current text drawing mode in the context c to mode.

method of CGContext
setFontSize (float size)      
Set the current font size in the context c to size.

method of CGContext
selectFont (string name, float size, CGTextEncoding encoding)      
Attempts to find the font named name for the context c. If successful, scales it to size units in text space. textEncoding specifies how to translate from bytes to glyphs.

method of CGContext
showText (string string, size_t length)      
Draw string, a string of length bytes, at the point specified by the text matrix in the context c. Each byte of the string is mapped through the encoding vector of the current font to obtain the glyph to display.

method of CGContext
showGlyphs (CGGlyph g[], size_t count)      
Draw the glyphs pointed to by g, an array of count glyphs, at the point specified by the text matrix in the context c.

method of CGContext
showTextAtPoint (float x, float y, string string, size_t length)      
Draw string, a string of length bytes, at the point (x, y), specified in user space, in the context c. Each byte of the string is mapped through the encoding vector of the current font to obtain the glyph to display.

method of CGContext
showGlyphsAtPoint (float x, float y, CGGlyph g[], size_t count)      
Display the glyphs pointed to by glyphs, an array of count glyphs, at at the point (x, y), specified in user space, in the context c.

method of CGContext
drawPlainTextInRect (CGDataProviderRef provider, CGRect rect, float fontSize = 0)       returns CGRect
* Text extra convenience functions. Uses the font size from the context gstate when drawing (when greater than zero). *

method of CGContext
drawPDFDocument (CGRect rect, CGPDFDocumentRef document, int page)      
Draw page in document in the rectangular area specified by rect in the context c. The media box of the page is scaled, if necessary, to fit into rect.

method of CGContext
beginPage (CGRect *mediaBox)      
Begin a new page.

method of CGContext
endPage ()      
End the current page.

method of CGContext
flush ()      
Flush all drawing to the destination.

method of CGContext
synchronize ()      
Synchronized drawing.

method of CGContext
setShouldAntialias (bool should)      
Turn on antialiasing if shouldAntialias is true; turn it off otherwise. This parameter is part of the graphics state.

method of CGContext
setAllowsAntialiasing (bool allowsAntialiasing)      
Allow antialiasing in context c if allowsAntialiasing is true; don't allow it otherwise. This parameter is not part of the graphics state. A context will perform antialiasing if both allowsAntialiasing and the graphics state parameter shouldAntialias are true.

method of CGContext
setShouldSmoothFonts (bool should)      
Turn on font smoothing if shouldSmoothFonts is true; turn it off otherwise. This parameter is part of the graphics state.

method of CGContext
beginTransparencyLayer (CFDictionaryRef auxiliaryInfo = NULL)      
Begin a transparency layer. All subsequent drawing operations until a corresponding CGContextEndTransparencyLayer are composited into a fully transparent backdrop (which is treated as a separate destination buffer from the context); after a call to CGContextEndTransparencyLayer, the result is composited into the context using the global alpha and shadow state of the context. This operation respects the clipping region of the context. After a call to this function, all of the parameters in the graphics state remain unchanged with the exception of the following: The global alpha is set to 1. The shadow is turned off. Ending the transparency layer restores these parameters to the values they had before CGContextBeginTransparencyLayer was called. Transparency layers may be nested.

method of CGContext
endTransparencyLayer ()      
End a tranparency layer.

method of CGContext
getUserSpaceToDeviceSpaceTransform ()       returns CGAffineTransform
Return the affine transform mapping the user space (abstract coordinates) of context to device space (pixels).

method of CGContext
convertPointToDeviceSpace (CGPoint point)       returns CGPoint
Transform point from the user space of context to device space.

method of CGContext
convertPointToUserSpace (CGPoint point)       returns CGPoint
Transform point from device space to the user space of context.

method of CGContext
convertSizeToDeviceSpace (CGSize size)       returns CGSize
Transform size from the user space of context to device space.

method of CGContext
convertSizeToUserSpace (CGSize size)       returns CGSize
Transform size from device space to the user space of context.

method of CGContext
CGContextConvertRectToDeviceSpace (CGRect rect)       returns CGRect
Transform rect from the user space of context to device space. Since affine transforms do not preserve rectangles in general, this function returns the smallest rectangle which contains the transformed corner points of rect.

method of CGContext
convertRectToUserSpace (CGRect rect)       returns CGRect
Transform rect from device space to the user space of context. Since affine transforms do not preserve rectangles in general, this function returns the smallest rectangle which contains the transformed corner points of rect.


CGBitmapContext

method of CGBitmapContext
*getData ()      
Return the data associated with the bitmap context c, or NULL if c is not a bitmap context.

method of CGBitmapContext
getWidth ()       returns integer
Return the width of the bitmap context c, or 0 if c is not a bitmap context.

method of CGBitmapContext
getHeight ()       returns integer
Return the height of the bitmap context c, or 0 if c is not a bitmap context.

method of CGBitmapContext
getBitsPerComponent ()       returns integer
Return the bits per component of the bitmap context c, or 0 if c is not a bitmap context.

method of CGBitmapContext
getBitsPerPixel ()       returns integer
Return the bits per pixel of the bitmap context c, or 0 if c is not a bitmap context.

method of CGBitmapContext
getBytesPerRow ()       returns integer
Return the bytes per row of the bitmap context c, or 0 if c is not a bitmap context.

method of CGBitmapContext
getColorSpace ()       returns CGColorSpaceRef
Return the colorspace of the bitmap context c, or NULL if c is not a bitmap context.

method of CGBitmapContext
getAlphaInfo ()       returns CGImageAlphaInfo
Return the alpha info of the bitmap context c, or kCGImageAlphaNone if c is not a bitmap context.

method of CGBitmapContext
createImage ()       returns CGImageRef
Return an image containing the current contents of the bitmap context c.

method of CGBitmapContext
writeToDataConsumer (CGDataConsumerRef consumer, string format, string params)       returns bool
Write an encoded representation of the current contents of the bitmap context c to the data consumer consumer.


CGContext

creates CGContext
CGPatternGetContext (void *handle)
Given a handle returned by CGPatternBegin, returns a context that can be used to define the contents of the pattern cell.

creates CGContext
CGBitmapContextCreateWithColor (size_t width, size_t height, CGColorSpaceRef colorspace, const float color[5], CFDictionaryRef auxInfo = NULL)
Create a bitmap context. The context draws into a bitmap which is width pixels wide and height pixels high. The number of components for each pixel is specified by colorspace, which also may specify a destination color profile. The number of bits for each component of a pixel is specified by bitsPerComponent, which must be 1, 2, 4, or 8. Each row of the bitmap consists of bytesPerRow bytes, which must be at least (width * bitsPerComponent * number of components + 7)/8 bytes. data points a block of memory at least bytesPerRow * height bytes. alphaInfo specifies whether the bitmap should contain an alpha channel, and how it's to be generated.

creates CGContext
CGPDFContextCreateWithFilename (char *filename, const CGRect *mediaBox, CFDictionaryRef auxiliaryInfo = NULL)
Format specifiers for writeToDataConsumer/writeToFile

method of CGContext
setURLForRect (CFURLRef url, CGRect rect)      
Set the URL associated with rect to url in the PDF context context.

method of CGContext
addDestinationAtPoint (CFStringRef name, CGPoint point)      
Create a PDF destination named name at point in the current page of the PDF context context.

method of CGContext
setDestinationForRect (CFStringRef name, CGRect rect)      
Specify a destination named name to jump to when clicking in rect of the current page of the PDF context context.


CGPDFDocument

creates CGPDFDocument
CGPDFDocumentCreateWithProvider(CGDataProviderRef provider)
Create a PDF document, using provider to obtain the document's data.

method of CGPDFDocument
getVersion (int *majorVersion, int *minorVersion)      
Return the major and minor version numbers of document.

method of CGPDFDocument
isEncrypted ()       returns bool
Return true if the PDF file associated with document is encrypted; false otherwise. If the PDF file is encrypted, then a password must be supplied before certain operations are enabled; different passwords may enable different operations.

method of CGPDFDocument
unlockWithPassword (string passwd)       returns bool
Use password to decrypt document and grant permission for certain operations. Returns true if password is a valid password; false otherwise.

method of CGPDFDocument
isUnlocked ()       returns bool
Return true if document is unlocked; false otherwise. A document is unlocked if it isn't encrypted, or if it is encrypted and a valid password was previously specified with CGPDFDocumentUnlockWithPassword.

method of CGPDFDocument
allowsPrinting ()       returns bool
Return true if document allows printing; false otherwise. Typically, this function returns false only if the document is encrypted and the document's current password doesn't grant permission to perform printing.

method of CGPDFDocument
allowsCopying ()       returns bool
Return true if document allows copying; false otherwise. Typically, this function returns false only if the document is encrypted and the document's current password doesn't grant permission to perform copying.

method of CGPDFDocument
getNumberOfPages ()       returns integer
Return the number of pages in document.

method of CGPDFDocument
getPage (size_t pageNumber)       returns CGPDFPageRef
Return the page corresponding to pageNumber, or NULL if no such page exists in the document. Pages are numbered starting at 1.

method of CGPDFDocument
getCatalog ()       returns CGPDFDictionaryRef
Return the document catalog of document.

method of CGPDFDocument
getInfo ()       returns CGPDFDictionaryRef
Return the info dictionary of document.

method of CGPDFDocument
getID ()       returns CGPDFArrayRef
Return the "file identifier" of document.

method of CGPDFDocument
getMediaBox (int page)       returns CGRect
Return the media box of page number page in document.

method of CGPDFDocument
getCropBox (int page)       returns CGRect
Return the crop box of page number page in document.

method of CGPDFDocument
getBleedBox (int page)       returns CGRect
Return the bleed box of page number page in document.

method of CGPDFDocument
getTrimBox (int page)       returns CGRect
Return the trim box of page number page in document.

method of CGPDFDocument
getArtBox (int page)       returns CGRect
Return the art box of page number page in document.

method of CGPDFDocument
getRotationAngle (int page)       returns int
Return the rotation angle (in degrees) of page number page in document.


CGPDFPage

method of CGPDFPage
getDocument ()       returns CGPDFDocumentRef
Return the document of page.

method of CGPDFPage
getPageNumber ()       returns integer
Return the page number of page.

method of CGPDFPage
getBoxRect (CGPDFBox box)       returns CGRect
Return the rectangle associated with box in page. This is the value of the corresponding entry (such as /MediaBox, /ArtBox, and so on) in the page's dictionary.

method of CGPDFPage
getRotationAngle ()       returns int
Return the rotation angle (in degrees) of page. This is the value of the /Rotate entry in the page's dictionary.

method of CGPDFPage
getDrawingTransform (CGPDFBox box, CGRect rect, int rotate, bool preserveAspectRatio)       returns CGAffineTransform
Return a transform mapping the box specified by box to rect as follows: - Compute the effective rect by intersecting the rect associated with box and the /MediaBox entry of the page. - Rotate the effective rect according to the page's /Rotate entry. - Center the resulting rect on rect. If rotation is non-zero, then the rect will rotated clockwise by rotation degrees. rotation must be a multiple of 90. - Scale the rect down, if necessary, so that it coincides with the edges of rect. If preserveAspectRatio is true, then the final rect will coincide with the edges of rect only in the more restrictive dimension.

method of CGPDFPage
getDictionary ()       returns CGPDFDictionaryRef
Return the dictionary of page.


CGPDFArray

method of CGPDFArray
getNull (size_t index)       returns bool
Look up the object at index in array and, if it's a null, return true; otherwise, return false.

method of CGPDFArray
getBoolean (size_t index, CGPDFBoolean *OUTPUT)       returns bool
Look up the object at index in array and, if it's a boolean, return the result in value. Return true on success; false otherwise.

method of CGPDFArray
getInteger (size_t index, CGPDFInteger *OUTPUT)       returns bool
Look up the object at index in array and, if it's an integer, return the result in value. Return true on success; false otherwise.

method of CGPDFArray
getNumber (size_t index, CGPDFReal *OUTPUT)       returns bool
Look up the object at index in array and, if it's a number (real or integer), return the result in value. Return true on success; false otherwise.

method of CGPDFArray
getName (size_t index)       returns string
Look up the object at index in array and, if it's a name, return the result in value. Return true on success; false otherwise.

method of CGPDFArray
getString (size_t index)       returns CGPDFStringRef
Look up the object at index in array and, if it's a string, return the result in value. Return true on success; false otherwise.

method of CGPDFArray
getArray (size_t index)       returns CGPDFArrayRef
Look up the object at index in array and, if it's an array, return it in value. Return true on success; false otherwise.

method of CGPDFArray
getDictionary (size_t index)       returns CGPDFDictionaryRef
Look up the object at index in array and, if it's a dictionary, return it in value. Return true on success; false otherwise.

method of CGPDFArray
getStream (size_t index)       returns CGPDFStreamRef
Look up the object at index in array and, if it's a stream, return it in value. Return true on success; false otherwise.


CGPDFContentStream

creates CGPDFContentStream
CGPDFContentStreamCreateWithPage(CGPDFPageRef page)
Create a content stream from page.

method of CGPDFContentStream
retain ()       returns CGPDFContentStreamRef
Increment the retain count of cs.

method of CGPDFContentStream
release ()      
Decrement the retain count of cs.

method of CGPDFContentStream
getStreams ()       returns CFArrayRef
Return the array of CGPDFStreamRefs comprising the entire content stream of cs.

method of CGPDFContentStream
getResource (string category, string name)       returns CGPDFObjectRef
Return the resource named name in category category of the resource dictionaries of cs.


CGPDFDictionary

method of CGPDFDictionary
getCount ()       returns integer
Return the number of entries in dictionary.

method of CGPDFDictionary
getKeys ()       returns CFTypeRef
Return an array containing all keys defined by dict.

method of CGPDFDictionary
getBoolean (string key, CGPDFBoolean *OUTPUT)       returns bool
Look up the object associated with key in dict and, if it's a boolean, return the result in value. Return true on success; false otherwise.

method of CGPDFDictionary
getInteger (string key, CGPDFInteger *OUTPUT)       returns bool
Look up the object associated with key in dict and, if it's an integer, return the result in value. Return true on success; false otherwise.

method of CGPDFDictionary
getNumber (string key, CGPDFReal *OUTPUT)       returns bool
Look up the object associated with key in dict and, if it's a number (real or integer), return the result in value. Return true on success; false otherwise.

method of CGPDFDictionary
getName (string key)       returns string
Look up the object associated with key in dict and, if it's a name, return the result in value. Return true on success; false otherwise.

method of CGPDFDictionary
getString (string key)       returns CGPDFStringRef
Look up the object associated with key in dict and, if it's a string, return the result in value. Return true on success; false otherwise.

method of CGPDFDictionary
getArray (string key)       returns CGPDFArrayRef
Look up the object associated with key in dict and, if it's an array, return the result in value. Return true on success; false otherwise.

method of CGPDFDictionary
getDictionary (string key)       returns CGPDFDictionaryRef
Look up the object associated with key in dict and, if it's a dictionary, return the result in value. Return true on success; false otherwise.

method of CGPDFDictionary
getStream (string key)       returns CGPDFStreamRef
Look up the object associated with key in dict and, if it's a stream, return the result in value. Return true on success; false otherwise.


CGPDFStream

method of CGPDFStream
getDictionary ()       returns CGPDFDictionaryRef
Return the dictionary of stream.

method of CGPDFStream
copyDataToConsumer (CGDataConsumerRef consumer)       returns CGPDFDataFormat
Return the data of stream.


CGPDFOperatorTable

creates CGPDFOperatorTable
CGPDFOperatorTableCreate()
Return an empty operator table.

method of CGPDFOperatorTable
retain ()       returns CGPDFOperatorTableRef
Increment the retain count of table.

method of CGPDFOperatorTable
release ()      
Decrement the retain count of table.

method of CGPDFOperatorTable
setCallback (string name, CGPDFOperatorCallback callback)      
Set the callback for the operator named name to callback


CGPDFScanner

creates CGPDFScanner
CGPDFScannerCreate(CGPDFContentStreamRef cs, CGPDFOperatorTableRef table, void *info)
Create a scanner.

method of CGPDFScanner
retain ()       returns CGPDFScannerRef
Retain scanner.

method of CGPDFScanner
release ()      
Release scanner.

method of CGPDFScanner
scan ()       returns bool
Scan the content stream of scanner. Returns true if the entire stream was scanned successfully; false if scanning failed for some reason (for example, if the stream's data is corrupted).

method of CGPDFScanner
getContentStream ()       returns CGPDFContentStreamRef
Return the content stream associated with scanner.

method of CGPDFScanner
popObject (CGPDFObjectRef *value)       returns bool
Pop an object from the stack of scanner and return it in value.

method of CGPDFScanner
popBoolean (CGPDFBoolean *value)       returns bool
Pop an object from the stack of scanner and, if it's a boolean, return it in value. Return false if the top of the stack isn't a boolean.

method of CGPDFScanner
popInteger (CGPDFInteger *value)       returns bool
Pop an object from the stack of scanner and, if it's an integer, return it in value. Return false if the top of the stack isn't an integer.

method of CGPDFScanner
popNumber (CGPDFReal *value)       returns bool
Pop an object from the stack of scanner and, if it's a number, return it in value. Return false if the top of the stack isn't a number.

method of CGPDFScanner
popName (string *value)       returns bool
Pop an object from the stack of scanner and, if it's a name, return it in value. Return false if the top of the stack isn't a name.

method of CGPDFScanner
popString (CGPDFStringRef *value)       returns bool
Pop an object from the stack of scanner and, if it's a string, return it in value. Return false if the top of the stack isn't a string.

method of CGPDFScanner
popArray (CGPDFArrayRef *value)       returns bool
Pop an object from the stack of scanner and, if it's an array, return it in value. Return false if the top of the stack isn't an array.

method of CGPDFScanner
popDictionary (CGPDFDictionaryRef *value)       returns bool
Pop an object from the stack of scanner and, if it's a dictionary, return it in value. Return false if the top of the stack isn't a dictionary.

method of CGPDFScanner
createImage ()       returns CGImageRef
Scan an inline image from scanner and return it. Return NULL if it's not possible to build the inline image for any reason.

method of CGPDFScanner
skipImage ()      
Skip past an inline image in scanner.


CGPSConverter

creates CGPSConverter
CGPSConverterCreateWithoutCallbacks ()
Create a new CGPSConverter object.

method of CGPSConverter
convert (CGDataProviderRef provider, CGDataConsumerRef consumer)       returns bool
Use converter to convert PostScript data to PDF data. The PostScript data is supplied by provider the resulting PDF is written to consumer. Returns true if the conversion succeeded; false otherwise.

method of CGPSConverter
abort (void)       returns bool
Tell the converter to abort conversion at the next possible opportunity.

method of CGPSConverter
isConverting (void)       returns bool
Return true if converter is currently converting data.


QDPict

creates QDPict
QDPictCreateWithProvider (CGDataProviderRef provider)
Create a QDPict reference, using provider to obtain the QDPict's data. It is assumed that either the first byte or the 513th byte of data in the file referenced by the URL is the first byte of the picture header. If the URL does not begin PICT data at one of these places in the data fork then the QDPictRef returned will be NULL.

creates QDPict
QDPictCreateWithFilename (const char *filename)
Create a QDPict reference from filename. It is assumed that either the first byte or the 513th byte of data in the file referenced by the filename is the first byte of the picture header. If the file does not begin PICT data at one of these places in the data fork then the QDPictRef returned will be NULL.

method of QDPict
getBounds ()       returns CGRect
Return the Picture Bounds of the QuickDraw picture represented by pictRef. This rectangle is in the default user space with one unit = 1/72 inch.

method of QDPict
getResolution ()       returns CGPoint
Return the resolution of the QuickDraw picture represented by pictRef. This data, together with the CGRect returned by QDPictGetBounds, can be used to compute the size of the picture in pixels, which is what QuickDraw really records into pictures.

method of QDPict
drawToCGContext (CGContext *ctx, CGRect rect)       returns bool
Draw pictRef in the rectangular area specified by rect. The PICT bounds of the page is scaled, if necessary, to fit into rect. To get unscaled results, supply a rect the size of the rect returned by QDPictGetBounds.