2
File: QD/QDPictToCGContext.h
4
Contains: API to draw Quickdraw PICTs into CoreGraphics context
6
Version: Quickdraw-150~1
8
Copyright: � 2001-2003 by Apple Computer, Inc., all rights reserved.
10
Bugs?: For bug reports, consult the following page on
13
http://www.freepascal.org/bugs.html
16
{ Pascal Translation: Peter N Lewis, <peter@stairways.com.au>, 2004 }
20
Modified for use with Free Pascal
22
Please report any bugs to <gpc@microbizz.nl>
31
unit QDPictToCGContext;
33
{$setc UNIVERSAL_INTERFACES_VERSION := $0342}
34
{$setc GAP_INTERFACES_VERSION := $0210}
36
{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
37
{$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
40
{$ifc defined CPUPOWERPC and defined CPUI386}
41
{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
43
{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
44
{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
47
{$ifc not defined __ppc__ and defined CPUPOWERPC}
52
{$ifc not defined __i386__ and defined CPUI386}
58
{$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
59
{$error Conflicting definitions for __ppc__ and __i386__}
62
{$ifc defined __ppc__ and __ppc__}
63
{$setc TARGET_CPU_PPC := TRUE}
64
{$setc TARGET_CPU_X86 := FALSE}
65
{$elifc defined __i386__ and __i386__}
66
{$setc TARGET_CPU_PPC := FALSE}
67
{$setc TARGET_CPU_X86 := TRUE}
69
{$error Neither __ppc__ nor __i386__ is defined.}
71
{$setc TARGET_CPU_PPC_64 := FALSE}
73
{$ifc defined FPC_BIG_ENDIAN}
74
{$setc TARGET_RT_BIG_ENDIAN := TRUE}
75
{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
76
{$elifc defined FPC_LITTLE_ENDIAN}
77
{$setc TARGET_RT_BIG_ENDIAN := FALSE}
78
{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
80
{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
82
{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
83
{$setc CALL_NOT_IN_CARBON := FALSE}
84
{$setc OLDROUTINENAMES := FALSE}
85
{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
86
{$setc OPAQUE_UPP_TYPES := TRUE}
87
{$setc OTCARBONAPPLICATION := TRUE}
88
{$setc OTKERNEL := FALSE}
89
{$setc PM_USE_SESSION_APIS := TRUE}
90
{$setc TARGET_API_MAC_CARBON := TRUE}
91
{$setc TARGET_API_MAC_OS8 := FALSE}
92
{$setc TARGET_API_MAC_OSX := TRUE}
93
{$setc TARGET_CARBON := TRUE}
94
{$setc TARGET_CPU_68K := FALSE}
95
{$setc TARGET_CPU_MIPS := FALSE}
96
{$setc TARGET_CPU_SPARC := FALSE}
97
{$setc TARGET_OS_MAC := TRUE}
98
{$setc TARGET_OS_UNIX := FALSE}
99
{$setc TARGET_OS_WIN32 := FALSE}
100
{$setc TARGET_RT_MAC_68881 := FALSE}
101
{$setc TARGET_RT_MAC_CFM := FALSE}
102
{$setc TARGET_RT_MAC_MACHO := TRUE}
103
{$setc TYPED_FUNCTION_POINTERS := TRUE}
104
{$setc TYPE_BOOL := FALSE}
105
{$setc TYPE_EXTENDED := FALSE}
106
{$setc TYPE_LONGLONG := TRUE}
107
uses MacTypes,CGContext,CGGeometry,CGDataProvider,CFURL;
111
QDPictRef = ^SInt32; { an opaque 32-bit type }
114
Note: QuickDraw picture data typically comes in two forms: a PICT resource
115
that begins the picture header data at the beginning of the resource and PICT
116
files that begin with 512 bytes of arbitrary data, followed by
117
the picture header data. For this reason, the routines that create a QDPictRef
118
attempt to find the picture header data beginning at either the first byte
119
of the data provided or at byte 513 of the data provided.
121
Additionally the Picture Bounds must not be an empty rect.
123
{ Create a QDPict reference, using `provider' to obtain the QDPict's data.
124
* It is assumed that either the first byte or the 513th byte of data
125
* in the file referenced by the URL is the first byte of the
126
* picture header. If the URL does not begin PICT data at one
127
* of these places in the data fork then the QDPictRef returned will be NULL.
130
* QDPictCreateWithProvider()
133
* Mac OS X: in version 10.1 and later in ApplicationServices.framework
134
* CarbonLib: not available
135
* Non-Carbon CFM: not available
137
// AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
138
function QDPictCreateWithProvider( provider: CGDataProviderRef ): QDPictRef; external name '_QDPictCreateWithProvider';
141
{ Create a QDPict reference from `url'.
142
* It is assumed that either the first byte or the 513th byte of data
143
* in the file referenced by the URL is the first byte of the
144
* picture header. If the URL does not begin PICT data at one
145
* of these places in the data fork then the QDPictRef returned will be NULL.
148
* QDPictCreateWithURL()
151
* Mac OS X: in version 10.1 and later in ApplicationServices.framework
152
* CarbonLib: not available
153
* Non-Carbon CFM: not available
155
// AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
156
function QDPictCreateWithURL( url: CFURLRef ): QDPictRef; external name '_QDPictCreateWithURL';
159
{ Increment the retain count of `pictRef' and return it. All
160
* pictRefs are created with an initial retain count of 1. }
165
* Mac OS X: in version 10.1 and later in ApplicationServices.framework
166
* CarbonLib: not available
167
* Non-Carbon CFM: not available
169
// AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
170
function QDPictRetain( pictRef: QDPictRef ): QDPictRef; external name '_QDPictRetain';
173
{ Decrement the retain count of `pictRef'. If the retain count reaches 0,
174
* then free it and any associated resources. }
179
* Mac OS X: in version 10.1 and later in ApplicationServices.framework
180
* CarbonLib: not available
181
* Non-Carbon CFM: not available
183
// AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
184
procedure QDPictRelease( pictRef: QDPictRef ); external name '_QDPictRelease';
187
{ Return the Picture Bounds of the QuickDraw picture represented by `pictRef'. This
188
rectangle is in the default user space with one unit = 1/72 inch.
194
* Mac OS X: in version 10.1 and later in ApplicationServices.framework
195
* CarbonLib: not available
196
* Non-Carbon CFM: not available
198
// AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
199
function QDPictGetBounds( pictRef: QDPictRef ): CGRect; external name '_QDPictGetBounds';
202
{ Return the resolution of the QuickDraw picture represented by `pictRef'.
203
This data, together with the CGRect returned by QDPictGetBounds, can be
204
used to compute the size of the picture in pixels, which is what QuickDraw
205
really records into pictures.
208
* QDPictGetResolution()
211
* Mac OS X: in version 10.1 and later in ApplicationServices.framework
212
* CarbonLib: not available
213
* Non-Carbon CFM: not available
215
// AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
216
procedure QDPictGetResolution( pictRef: QDPictRef; var xRes, yRes: Float32 ); external name '_QDPictGetResolution';
219
{ Draw `pictRef' in the rectangular area specified by `rect'.
220
* The PICT bounds of the page is scaled, if necessary, to fit into
221
* `rect'. To get unscaled results, supply a rect the size of the rect
222
* returned by QDPictGetBounds.
225
* QDPictDrawToCGContext()
228
* Mac OS X: in version 10.1 and later in ApplicationServices.framework
229
* CarbonLib: not available
230
* Non-Carbon CFM: not available
232
// AVAILABLE_MAC_OS_X_VERSION_10_1_AND_LATER
233
function QDPictDrawToCGContext( ctx: CGContextRef; rect: CGRect; pictRef: QDPictRef ): OSStatus; external name '_QDPictDrawToCGContext';