PictUtils.pas 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. {
  2. File: PictUtils.p
  3. Contains: Picture Utilities Interfaces.
  4. Version: Technology: Mac OS 8.5
  5. Release: Universal Interfaces 3.4.2
  6. Copyright: © 1990-2002 by Apple Computer, Inc., all rights reserved
  7. Bugs?: For bug reports, consult the following page on
  8. the World Wide Web:
  9. http://www.freepascal.org/bugs.html
  10. }
  11. {
  12. Modified for use with Free Pascal
  13. Version 200
  14. Please report any bugs to <[email protected]>
  15. }
  16. {$mode macpas}
  17. {$packenum 1}
  18. {$macro on}
  19. {$inline on}
  20. {$CALLING MWPASCAL}
  21. unit PictUtils;
  22. interface
  23. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  24. {$setc GAP_INTERFACES_VERSION := $0200}
  25. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  26. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  27. {$endc}
  28. {$ifc defined CPUPOWERPC and defined CPUI386}
  29. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  30. {$endc}
  31. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  32. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  33. {$endc}
  34. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  35. {$setc __ppc__ := 1}
  36. {$elsec}
  37. {$setc __ppc__ := 0}
  38. {$endc}
  39. {$ifc not defined __i386__ and defined CPUI386}
  40. {$setc __i386__ := 1}
  41. {$elsec}
  42. {$setc __i386__ := 0}
  43. {$endc}
  44. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  45. {$error Conflicting definitions for __ppc__ and __i386__}
  46. {$endc}
  47. {$ifc defined __ppc__ and __ppc__}
  48. {$setc TARGET_CPU_PPC := TRUE}
  49. {$setc TARGET_CPU_X86 := FALSE}
  50. {$elifc defined __i386__ and __i386__}
  51. {$setc TARGET_CPU_PPC := FALSE}
  52. {$setc TARGET_CPU_X86 := TRUE}
  53. {$elsec}
  54. {$error Neither __ppc__ nor __i386__ is defined.}
  55. {$endc}
  56. {$setc TARGET_CPU_PPC_64 := FALSE}
  57. {$ifc defined FPC_BIG_ENDIAN}
  58. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  59. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  60. {$elifc defined FPC_LITTLE_ENDIAN}
  61. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  62. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  63. {$elsec}
  64. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  65. {$endc}
  66. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  67. {$setc CALL_NOT_IN_CARBON := FALSE}
  68. {$setc OLDROUTINENAMES := FALSE}
  69. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  70. {$setc OPAQUE_UPP_TYPES := TRUE}
  71. {$setc OTCARBONAPPLICATION := TRUE}
  72. {$setc OTKERNEL := FALSE}
  73. {$setc PM_USE_SESSION_APIS := TRUE}
  74. {$setc TARGET_API_MAC_CARBON := TRUE}
  75. {$setc TARGET_API_MAC_OS8 := FALSE}
  76. {$setc TARGET_API_MAC_OSX := TRUE}
  77. {$setc TARGET_CARBON := TRUE}
  78. {$setc TARGET_CPU_68K := FALSE}
  79. {$setc TARGET_CPU_MIPS := FALSE}
  80. {$setc TARGET_CPU_SPARC := FALSE}
  81. {$setc TARGET_OS_MAC := TRUE}
  82. {$setc TARGET_OS_UNIX := FALSE}
  83. {$setc TARGET_OS_WIN32 := FALSE}
  84. {$setc TARGET_RT_MAC_68881 := FALSE}
  85. {$setc TARGET_RT_MAC_CFM := FALSE}
  86. {$setc TARGET_RT_MAC_MACHO := TRUE}
  87. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  88. {$setc TYPE_BOOL := FALSE}
  89. {$setc TYPE_EXTENDED := FALSE}
  90. {$setc TYPE_LONGLONG := TRUE}
  91. uses MacTypes,Quickdraw,Palettes;
  92. {$ALIGN MAC68K}
  93. { verbs for the GetPictInfo, GetPixMapInfo, and NewPictInfo calls }
  94. const
  95. returnColorTable = $0001;
  96. returnPalette = $0002;
  97. recordComments = $0004;
  98. recordFontInfo = $0008;
  99. suppressBlackAndWhite = $0010;
  100. { color pick methods }
  101. systemMethod = 0; { system color pick method }
  102. popularMethod = 1; { method that chooses the most popular set of colors }
  103. medianMethod = 2; { method that chooses a good average mix of colors }
  104. { color bank types }
  105. ColorBankIsCustom = -1;
  106. ColorBankIsExactAnd555 = 0;
  107. ColorBankIs555 = 1;
  108. type
  109. PictInfoID = SInt32;
  110. CommentSpecPtr = ^CommentSpec;
  111. CommentSpec = record
  112. count: SInt16; { number of occurrances of this comment ID }
  113. ID: SInt16; { ID for the comment in the picture }
  114. end;
  115. CommentSpecHandle = ^CommentSpecPtr;
  116. FontSpecPtr = ^FontSpec;
  117. FontSpec = record
  118. pictFontID: SInt16; { ID of the font in the picture }
  119. sysFontID: SInt16; { ID of the same font in the current system file }
  120. size: array [0..3] of SInt32; { bit array of all the sizes found (1..127) (bit 0 means > 127) }
  121. style: SInt16; { combined style of all occurrances of the font }
  122. nameOffset: SInt32; { offset into the fontNamesHdl handle for the fontÕs name }
  123. end;
  124. FontSpecHandle = ^FontSpecPtr;
  125. PictInfoPtr = ^PictInfo;
  126. PictInfo = record
  127. version: SInt16; { this is always zero, for now }
  128. uniqueColors: SInt32; { the number of actual colors in the picture(s)/pixmap(s) }
  129. thePalette: PaletteHandle; { handle to the palette information }
  130. theColorTable: CTabHandle; { handle to the color table }
  131. hRes: Fixed; { maximum horizontal resolution for all the pixmaps }
  132. vRes: Fixed; { maximum vertical resolution for all the pixmaps }
  133. depth: SInt16; { maximum depth for all the pixmaps (in the picture) }
  134. sourceRect: Rect; { the picture frame rectangle (this contains the entire picture) }
  135. textCount: SInt32; { total number of text strings in the picture }
  136. lineCount: SInt32; { total number of lines in the picture }
  137. rectCount: SInt32; { total number of rectangles in the picture }
  138. rRectCount: SInt32; { total number of round rectangles in the picture }
  139. ovalCount: SInt32; { total number of ovals in the picture }
  140. arcCount: SInt32; { total number of arcs in the picture }
  141. polyCount: SInt32; { total number of polygons in the picture }
  142. regionCount: SInt32; { total number of regions in the picture }
  143. bitMapCount: SInt32; { total number of bitmaps in the picture }
  144. pixMapCount: SInt32; { total number of pixmaps in the picture }
  145. commentCount: SInt32; { total number of comments in the picture }
  146. uniqueComments: SInt32; { the number of unique comments in the picture }
  147. commentHandle: CommentSpecHandle; { handle to all the comment information }
  148. uniqueFonts: SInt32; { the number of unique fonts in the picture }
  149. fontHandle: FontSpecHandle; { handle to the FontSpec information }
  150. fontNamesHandle: Handle; { handle to the font names }
  151. reserved1: SInt32;
  152. reserved2: SInt32;
  153. end;
  154. PictInfoHandle = ^PictInfoPtr;
  155. {$ifc TYPED_FUNCTION_POINTERS}
  156. InitPickMethodProcPtr = function(colorsRequested: SInt16; var dataRef: UInt32; var colorBankType: SInt16): OSErr;
  157. {$elsec}
  158. InitPickMethodProcPtr = ProcPtr;
  159. {$endc}
  160. {$ifc TYPED_FUNCTION_POINTERS}
  161. RecordColorsProcPtr = function(dataRef: UInt32; var colorsArray: RGBColor; colorCount: SInt32; var uniqueColors: SInt32): OSErr;
  162. {$elsec}
  163. RecordColorsProcPtr = ProcPtr;
  164. {$endc}
  165. {$ifc TYPED_FUNCTION_POINTERS}
  166. CalcColorTableProcPtr = function(dataRef: UInt32; colorsRequested: SInt16; colorBankPtr: UnivPtr; var resultPtr: CSpecArray): OSErr;
  167. {$elsec}
  168. CalcColorTableProcPtr = ProcPtr;
  169. {$endc}
  170. {$ifc TYPED_FUNCTION_POINTERS}
  171. DisposeColorPickMethodProcPtr = function(dataRef: UInt32): OSErr;
  172. {$elsec}
  173. DisposeColorPickMethodProcPtr = ProcPtr;
  174. {$endc}
  175. {$ifc OPAQUE_UPP_TYPES}
  176. InitPickMethodUPP = ^SInt32; { an opaque UPP }
  177. {$elsec}
  178. InitPickMethodUPP = UniversalProcPtr;
  179. {$endc}
  180. {$ifc OPAQUE_UPP_TYPES}
  181. RecordColorsUPP = ^SInt32; { an opaque UPP }
  182. {$elsec}
  183. RecordColorsUPP = UniversalProcPtr;
  184. {$endc}
  185. {$ifc OPAQUE_UPP_TYPES}
  186. CalcColorTableUPP = ^SInt32; { an opaque UPP }
  187. {$elsec}
  188. CalcColorTableUPP = UniversalProcPtr;
  189. {$endc}
  190. {$ifc OPAQUE_UPP_TYPES}
  191. DisposeColorPickMethodUPP = ^SInt32; { an opaque UPP }
  192. {$elsec}
  193. DisposeColorPickMethodUPP = UniversalProcPtr;
  194. {$endc}
  195. const
  196. uppInitPickMethodProcInfo = $00000FA0;
  197. uppRecordColorsProcInfo = $00003FE0;
  198. uppCalcColorTableProcInfo = $00003EE0;
  199. uppDisposeColorPickMethodProcInfo = $000000E0;
  200. {
  201. * NewInitPickMethodUPP()
  202. *
  203. * Availability:
  204. * Non-Carbon CFM: available as macro/inline
  205. * CarbonLib: in CarbonLib 1.0 and later
  206. * Mac OS X: in version 10.0 and later
  207. }
  208. function NewInitPickMethodUPP(userRoutine: InitPickMethodProcPtr): InitPickMethodUPP; external name '_NewInitPickMethodUPP'; { old name was NewInitPickMethodProc }
  209. {
  210. * NewRecordColorsUPP()
  211. *
  212. * Availability:
  213. * Non-Carbon CFM: available as macro/inline
  214. * CarbonLib: in CarbonLib 1.0 and later
  215. * Mac OS X: in version 10.0 and later
  216. }
  217. function NewRecordColorsUPP(userRoutine: RecordColorsProcPtr): RecordColorsUPP; external name '_NewRecordColorsUPP'; { old name was NewRecordColorsProc }
  218. {
  219. * NewCalcColorTableUPP()
  220. *
  221. * Availability:
  222. * Non-Carbon CFM: available as macro/inline
  223. * CarbonLib: in CarbonLib 1.0 and later
  224. * Mac OS X: in version 10.0 and later
  225. }
  226. function NewCalcColorTableUPP(userRoutine: CalcColorTableProcPtr): CalcColorTableUPP; external name '_NewCalcColorTableUPP'; { old name was NewCalcColorTableProc }
  227. {
  228. * NewDisposeColorPickMethodUPP()
  229. *
  230. * Availability:
  231. * Non-Carbon CFM: available as macro/inline
  232. * CarbonLib: in CarbonLib 1.0 and later
  233. * Mac OS X: in version 10.0 and later
  234. }
  235. function NewDisposeColorPickMethodUPP(userRoutine: DisposeColorPickMethodProcPtr): DisposeColorPickMethodUPP; external name '_NewDisposeColorPickMethodUPP'; { old name was NewDisposeColorPickMethodProc }
  236. {
  237. * DisposeInitPickMethodUPP()
  238. *
  239. * Availability:
  240. * Non-Carbon CFM: available as macro/inline
  241. * CarbonLib: in CarbonLib 1.0 and later
  242. * Mac OS X: in version 10.0 and later
  243. }
  244. procedure DisposeInitPickMethodUPP(userUPP: InitPickMethodUPP); external name '_DisposeInitPickMethodUPP';
  245. {
  246. * DisposeRecordColorsUPP()
  247. *
  248. * Availability:
  249. * Non-Carbon CFM: available as macro/inline
  250. * CarbonLib: in CarbonLib 1.0 and later
  251. * Mac OS X: in version 10.0 and later
  252. }
  253. procedure DisposeRecordColorsUPP(userUPP: RecordColorsUPP); external name '_DisposeRecordColorsUPP';
  254. {
  255. * DisposeCalcColorTableUPP()
  256. *
  257. * Availability:
  258. * Non-Carbon CFM: available as macro/inline
  259. * CarbonLib: in CarbonLib 1.0 and later
  260. * Mac OS X: in version 10.0 and later
  261. }
  262. procedure DisposeCalcColorTableUPP(userUPP: CalcColorTableUPP); external name '_DisposeCalcColorTableUPP';
  263. {
  264. * DisposeDisposeColorPickMethodUPP()
  265. *
  266. * Availability:
  267. * Non-Carbon CFM: available as macro/inline
  268. * CarbonLib: in CarbonLib 1.0 and later
  269. * Mac OS X: in version 10.0 and later
  270. }
  271. procedure DisposeDisposeColorPickMethodUPP(userUPP: DisposeColorPickMethodUPP); external name '_DisposeDisposeColorPickMethodUPP';
  272. {
  273. * InvokeInitPickMethodUPP()
  274. *
  275. * Availability:
  276. * Non-Carbon CFM: available as macro/inline
  277. * CarbonLib: in CarbonLib 1.0 and later
  278. * Mac OS X: in version 10.0 and later
  279. }
  280. function InvokeInitPickMethodUPP(colorsRequested: SInt16; var dataRef: UInt32; var colorBankType: SInt16; userRoutine: InitPickMethodUPP): OSErr; external name '_InvokeInitPickMethodUPP'; { old name was CallInitPickMethodProc }
  281. {
  282. * InvokeRecordColorsUPP()
  283. *
  284. * Availability:
  285. * Non-Carbon CFM: available as macro/inline
  286. * CarbonLib: in CarbonLib 1.0 and later
  287. * Mac OS X: in version 10.0 and later
  288. }
  289. function InvokeRecordColorsUPP(dataRef: UInt32; var colorsArray: RGBColor; colorCount: SInt32; var uniqueColors: SInt32; userRoutine: RecordColorsUPP): OSErr; external name '_InvokeRecordColorsUPP'; { old name was CallRecordColorsProc }
  290. {
  291. * InvokeCalcColorTableUPP()
  292. *
  293. * Availability:
  294. * Non-Carbon CFM: available as macro/inline
  295. * CarbonLib: in CarbonLib 1.0 and later
  296. * Mac OS X: in version 10.0 and later
  297. }
  298. function InvokeCalcColorTableUPP(dataRef: UInt32; colorsRequested: SInt16; colorBankPtr: UnivPtr; var resultPtr: CSpecArray; userRoutine: CalcColorTableUPP): OSErr; external name '_InvokeCalcColorTableUPP'; { old name was CallCalcColorTableProc }
  299. {
  300. * InvokeDisposeColorPickMethodUPP()
  301. *
  302. * Availability:
  303. * Non-Carbon CFM: available as macro/inline
  304. * CarbonLib: in CarbonLib 1.0 and later
  305. * Mac OS X: in version 10.0 and later
  306. }
  307. function InvokeDisposeColorPickMethodUPP(dataRef: UInt32; userRoutine: DisposeColorPickMethodUPP): OSErr; external name '_InvokeDisposeColorPickMethodUPP'; { old name was CallDisposeColorPickMethodProc }
  308. {
  309. * GetPictInfo()
  310. *
  311. * Availability:
  312. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  313. * CarbonLib: in CarbonLib 1.0 and later
  314. * Mac OS X: in version 10.0 and later
  315. }
  316. function GetPictInfo(thePictHandle: PicHandle; var thePictInfo: PictInfo; verb: SInt16; colorsRequested: SInt16; colorPickMethod: SInt16; version: SInt16): OSErr; external name '_GetPictInfo';
  317. {
  318. * GetPixMapInfo()
  319. *
  320. * Availability:
  321. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  322. * CarbonLib: in CarbonLib 1.0 and later
  323. * Mac OS X: in version 10.0 and later
  324. }
  325. function GetPixMapInfo(thePixMapHandle: PixMapHandle; var thePictInfo: PictInfo; verb: SInt16; colorsRequested: SInt16; colorPickMethod: SInt16; version: SInt16): OSErr; external name '_GetPixMapInfo';
  326. {
  327. * NewPictInfo()
  328. *
  329. * Availability:
  330. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  331. * CarbonLib: in CarbonLib 1.0 and later
  332. * Mac OS X: in version 10.0 and later
  333. }
  334. function NewPictInfo(var thePictInfoID: PictInfoID; verb: SInt16; colorsRequested: SInt16; colorPickMethod: SInt16; version: SInt16): OSErr; external name '_NewPictInfo';
  335. {
  336. * RecordPictInfo()
  337. *
  338. * Availability:
  339. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  340. * CarbonLib: in CarbonLib 1.0 and later
  341. * Mac OS X: in version 10.0 and later
  342. }
  343. function RecordPictInfo(thePictInfoID: PictInfoID; thePictHandle: PicHandle): OSErr; external name '_RecordPictInfo';
  344. {
  345. * RecordPixMapInfo()
  346. *
  347. * Availability:
  348. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  349. * CarbonLib: in CarbonLib 1.0 and later
  350. * Mac OS X: in version 10.0 and later
  351. }
  352. function RecordPixMapInfo(thePictInfoID: PictInfoID; thePixMapHandle: PixMapHandle): OSErr; external name '_RecordPixMapInfo';
  353. {
  354. * RetrievePictInfo()
  355. *
  356. * Availability:
  357. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  358. * CarbonLib: in CarbonLib 1.0 and later
  359. * Mac OS X: in version 10.0 and later
  360. }
  361. function RetrievePictInfo(thePictInfoID: PictInfoID; var thePictInfo: PictInfo; colorsRequested: SInt16): OSErr; external name '_RetrievePictInfo';
  362. {
  363. * DisposePictInfo()
  364. *
  365. * Availability:
  366. * Non-Carbon CFM: in InterfaceLib 7.1 and later
  367. * CarbonLib: in CarbonLib 1.0 and later
  368. * Mac OS X: in version 10.0 and later
  369. }
  370. function DisposePictInfo(thePictInfoID: PictInfoID): OSErr; external name '_DisposePictInfo';
  371. {$ifc OLDROUTINENAMES}
  372. {$ifc CALL_NOT_IN_CARBON}
  373. {
  374. * DisposPictInfo()
  375. *
  376. * Availability:
  377. * Non-Carbon CFM: not available
  378. * CarbonLib: not available
  379. * Mac OS X: not available
  380. }
  381. function DisposPictInfo(thePictInfoID: PictInfoID): OSErr; external name '_DisposPictInfo';
  382. {$endc} {CALL_NOT_IN_CARBON}
  383. {$endc} {OLDROUTINENAMES}
  384. {$ALIGN MAC68K}
  385. end.