PictUtils.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:15k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       PictUtils.h
  3.  
  4.      Contains:   Picture Utilities Interfaces.
  5.  
  6.      Version:    Technology: Mac OS 8.5
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1990-2001 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __PICTUTILS__
  18. #define __PICTUTILS__
  19. #ifndef __MACTYPES__
  20. #include "MacTypes.h"
  21. #endif
  22. #ifndef __PALETTES__
  23. #include "Palettes.h"
  24. #endif
  25. #if PRAGMA_ONCE
  26. #pragma once
  27. #endif
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #if PRAGMA_IMPORT
  32. #pragma import on
  33. #endif
  34. #if PRAGMA_STRUCT_ALIGN
  35.     #pragma options align=mac68k
  36. #elif PRAGMA_STRUCT_PACKPUSH
  37.     #pragma pack(push, 2)
  38. #elif PRAGMA_STRUCT_PACK
  39.     #pragma pack(2)
  40. #endif
  41. /* verbs for the GetPictInfo, GetPixMapInfo, and NewPictInfo calls */
  42. enum {
  43.     returnColorTable            = 0x0001,
  44.     returnPalette               = 0x0002,
  45.     recordComments              = 0x0004,
  46.     recordFontInfo              = 0x0008,
  47.     suppressBlackAndWhite       = 0x0010
  48. };
  49. enum {
  50.                                                                 /* color pick methods */
  51.     systemMethod                = 0,                            /* system color pick method */
  52.     popularMethod               = 1,                            /* method that chooses the most popular set of colors */
  53.     medianMethod                = 2                             /* method that chooses a good average mix of colors */
  54. };
  55. enum {
  56.                                                                 /* color bank types */
  57.     ColorBankIsCustom           = -1,
  58.     ColorBankIsExactAnd555      = 0,
  59.     ColorBankIs555              = 1
  60. };
  61. typedef long                            PictInfoID;
  62. struct CommentSpec {
  63.     short                           count;                      /* number of occurrances of this comment ID */
  64.     short                           ID;                         /* ID for the comment in the picture */
  65. };
  66. typedef struct CommentSpec              CommentSpec;
  67. typedef CommentSpec *                   CommentSpecPtr;
  68. typedef CommentSpecPtr *                CommentSpecHandle;
  69. struct FontSpec {
  70.     short                           pictFontID;                 /* ID of the font in the picture */
  71.     short                           sysFontID;                  /* ID of the same font in the current system file */
  72.     long                            size[4];                    /* bit array of all the sizes found (1..127) (bit 0 means > 127) */
  73.     short                           style;                      /* combined style of all occurrances of the font */
  74.     long                            nameOffset;                 /* offset into the fontNamesHdl handle for the font's name */
  75. };
  76. typedef struct FontSpec                 FontSpec;
  77. typedef FontSpec *                      FontSpecPtr;
  78. typedef FontSpecPtr *                   FontSpecHandle;
  79. struct PictInfo {
  80.     short                           version;                    /* this is always zero, for now */
  81.     long                            uniqueColors;               /* the number of actual colors in the picture(s)/pixmap(s) */
  82.     PaletteHandle                   thePalette;                 /* handle to the palette information */
  83.     CTabHandle                      theColorTable;              /* handle to the color table */
  84.     Fixed                           hRes;                       /* maximum horizontal resolution for all the pixmaps */
  85.     Fixed                           vRes;                       /* maximum vertical resolution for all the pixmaps */
  86.     short                           depth;                      /* maximum depth for all the pixmaps (in the picture) */
  87.     Rect                            sourceRect;                 /* the picture frame rectangle (this contains the entire picture) */
  88.     long                            textCount;                  /* total number of text strings in the picture */
  89.     long                            lineCount;                  /* total number of lines in the picture */
  90.     long                            rectCount;                  /* total number of rectangles in the picture */
  91.     long                            rRectCount;                 /* total number of round rectangles in the picture */
  92.     long                            ovalCount;                  /* total number of ovals in the picture */
  93.     long                            arcCount;                   /* total number of arcs in the picture */
  94.     long                            polyCount;                  /* total number of polygons in the picture */
  95.     long                            regionCount;                /* total number of regions in the picture */
  96.     long                            bitMapCount;                /* total number of bitmaps in the picture */
  97.     long                            pixMapCount;                /* total number of pixmaps in the picture */
  98.     long                            commentCount;               /* total number of comments in the picture */
  99.     long                            uniqueComments;             /* the number of unique comments in the picture */
  100.     CommentSpecHandle               commentHandle;              /* handle to all the comment information */
  101.     long                            uniqueFonts;                /* the number of unique fonts in the picture */
  102.     FontSpecHandle                  fontHandle;                 /* handle to the FontSpec information */
  103.     Handle                          fontNamesHandle;            /* handle to the font names */
  104.     long                            reserved1;
  105.     long                            reserved2;
  106. };
  107. typedef struct PictInfo                 PictInfo;
  108. typedef PictInfo *                      PictInfoPtr;
  109. typedef PictInfoPtr *                   PictInfoHandle;
  110. typedef CALLBACK_API( OSErr , InitPickMethodProcPtr )(SInt16 colorsRequested, UInt32 *dataRef, SInt16 *colorBankType);
  111. typedef CALLBACK_API( OSErr , RecordColorsProcPtr )(UInt32 dataRef, RGBColor *colorsArray, SInt32 colorCount, SInt32 *uniqueColors);
  112. typedef CALLBACK_API( OSErr , CalcColorTableProcPtr )(UInt32 dataRef, SInt16 colorsRequested, void *colorBankPtr, CSpecArray resultPtr);
  113. typedef CALLBACK_API( OSErr , DisposeColorPickMethodProcPtr )(UInt32 dataRef);
  114. typedef STACK_UPP_TYPE(InitPickMethodProcPtr)                   InitPickMethodUPP;
  115. typedef STACK_UPP_TYPE(RecordColorsProcPtr)                     RecordColorsUPP;
  116. typedef STACK_UPP_TYPE(CalcColorTableProcPtr)                   CalcColorTableUPP;
  117. typedef STACK_UPP_TYPE(DisposeColorPickMethodProcPtr)           DisposeColorPickMethodUPP;
  118. #if OPAQUE_UPP_TYPES
  119.     EXTERN_API(InitPickMethodUPP)
  120.     NewInitPickMethodUPP           (InitPickMethodProcPtr   userRoutine);
  121.     EXTERN_API(RecordColorsUPP)
  122.     NewRecordColorsUPP             (RecordColorsProcPtr     userRoutine);
  123.     EXTERN_API(CalcColorTableUPP)
  124.     NewCalcColorTableUPP           (CalcColorTableProcPtr   userRoutine);
  125.     EXTERN_API(DisposeColorPickMethodUPP)
  126.     NewDisposeColorPickMethodUPP    (DisposeColorPickMethodProcPtr userRoutine);
  127.     EXTERN_API(void)
  128.     DisposeInitPickMethodUPP       (InitPickMethodUPP       userUPP);
  129.     EXTERN_API(void)
  130.     DisposeRecordColorsUPP         (RecordColorsUPP         userUPP);
  131.     EXTERN_API(void)
  132.     DisposeCalcColorTableUPP       (CalcColorTableUPP       userUPP);
  133.     EXTERN_API(void)
  134.     DisposeDisposeColorPickMethodUPP    (DisposeColorPickMethodUPP userUPP);
  135.     EXTERN_API(OSErr)
  136.     InvokeInitPickMethodUPP        (SInt16                  colorsRequested,
  137.                                     UInt32 *                dataRef,
  138.                                     SInt16 *                colorBankType,
  139.                                     InitPickMethodUPP       userUPP);
  140.     EXTERN_API(OSErr)
  141.     InvokeRecordColorsUPP          (UInt32                  dataRef,
  142.                                     RGBColor *              colorsArray,
  143.                                     SInt32                  colorCount,
  144.                                     SInt32 *                uniqueColors,
  145.                                     RecordColorsUPP         userUPP);
  146.     EXTERN_API(OSErr)
  147.     InvokeCalcColorTableUPP        (UInt32                  dataRef,
  148.                                     SInt16                  colorsRequested,
  149.                                     void *                  colorBankPtr,
  150.                                     CSpecArray              resultPtr,
  151.                                     CalcColorTableUPP       userUPP);
  152.     EXTERN_API(OSErr)
  153.     InvokeDisposeColorPickMethodUPP    (UInt32              dataRef,
  154.                                     DisposeColorPickMethodUPP userUPP);
  155. #else
  156.     enum { uppInitPickMethodProcInfo = 0x00000FA0 };                /* pascal 2_bytes Func(2_bytes, 4_bytes, 4_bytes) */
  157.     enum { uppRecordColorsProcInfo = 0x00003FE0 };                  /* pascal 2_bytes Func(4_bytes, 4_bytes, 4_bytes, 4_bytes) */
  158.     enum { uppCalcColorTableProcInfo = 0x00003EE0 };                /* pascal 2_bytes Func(4_bytes, 2_bytes, 4_bytes, 4_bytes) */
  159.     enum { uppDisposeColorPickMethodProcInfo = 0x000000E0 };        /* pascal 2_bytes Func(4_bytes) */
  160.     #define NewInitPickMethodUPP(userRoutine)                       (InitPickMethodUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppInitPickMethodProcInfo, GetCurrentArchitecture())
  161.     #define NewRecordColorsUPP(userRoutine)                         (RecordColorsUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppRecordColorsProcInfo, GetCurrentArchitecture())
  162.     #define NewCalcColorTableUPP(userRoutine)                       (CalcColorTableUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppCalcColorTableProcInfo, GetCurrentArchitecture())
  163.     #define NewDisposeColorPickMethodUPP(userRoutine)               (DisposeColorPickMethodUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDisposeColorPickMethodProcInfo, GetCurrentArchitecture())
  164.     #define DisposeInitPickMethodUPP(userUPP)                       DisposeRoutineDescriptor(userUPP)
  165.     #define DisposeRecordColorsUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  166.     #define DisposeCalcColorTableUPP(userUPP)                       DisposeRoutineDescriptor(userUPP)
  167.     #define DisposeDisposeColorPickMethodUPP(userUPP)               DisposeRoutineDescriptor(userUPP)
  168.     #define InvokeInitPickMethodUPP(colorsRequested, dataRef, colorBankType, userUPP)  (OSErr)CALL_THREE_PARAMETER_UPP((userUPP), uppInitPickMethodProcInfo, (colorsRequested), (dataRef), (colorBankType))
  169.     #define InvokeRecordColorsUPP(dataRef, colorsArray, colorCount, uniqueColors, userUPP)  (OSErr)CALL_FOUR_PARAMETER_UPP((userUPP), uppRecordColorsProcInfo, (dataRef), (colorsArray), (colorCount), (uniqueColors))
  170.     #define InvokeCalcColorTableUPP(dataRef, colorsRequested, colorBankPtr, resultPtr, userUPP)  (OSErr)CALL_FOUR_PARAMETER_UPP((userUPP), uppCalcColorTableProcInfo, (dataRef), (colorsRequested), (colorBankPtr), (resultPtr))
  171.     #define InvokeDisposeColorPickMethodUPP(dataRef, userUPP)       (OSErr)CALL_ONE_PARAMETER_UPP((userUPP), uppDisposeColorPickMethodProcInfo, (dataRef))
  172. #endif
  173. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  174. #define NewInitPickMethodProc(userRoutine)                      NewInitPickMethodUPP(userRoutine)
  175. #define NewRecordColorsProc(userRoutine)                        NewRecordColorsUPP(userRoutine)
  176. #define NewCalcColorTableProc(userRoutine)                      NewCalcColorTableUPP(userRoutine)
  177. #define NewDisposeColorPickMethodProc(userRoutine)              NewDisposeColorPickMethodUPP(userRoutine)
  178. #define CallInitPickMethodProc(userRoutine, colorsRequested, dataRef, colorBankType) InvokeInitPickMethodUPP(colorsRequested, dataRef, colorBankType, userRoutine)
  179. #define CallRecordColorsProc(userRoutine, dataRef, colorsArray, colorCount, uniqueColors) InvokeRecordColorsUPP(dataRef, colorsArray, colorCount, uniqueColors, userRoutine)
  180. #define CallCalcColorTableProc(userRoutine, dataRef, colorsRequested, colorBankPtr, resultPtr) InvokeCalcColorTableUPP(dataRef, colorsRequested, colorBankPtr, resultPtr, userRoutine)
  181. #define CallDisposeColorPickMethodProc(userRoutine, dataRef)    InvokeDisposeColorPickMethodUPP(dataRef, userRoutine)
  182. EXTERN_API( OSErr )
  183. GetPictInfo                     (PicHandle              thePictHandle,
  184.                                  PictInfo *             thePictInfo,
  185.                                  short                  verb,
  186.                                  short                  colorsRequested,
  187.                                  short                  colorPickMethod,
  188.                                  short                  version)                            THREEWORDINLINE(0x303C, 0x0800, 0xA831);
  189. EXTERN_API( OSErr )
  190. GetPixMapInfo                   (PixMapHandle           thePixMapHandle,
  191.                                  PictInfo *             thePictInfo,
  192.                                  short                  verb,
  193.                                  short                  colorsRequested,
  194.                                  short                  colorPickMethod,
  195.                                  short                  version)                            THREEWORDINLINE(0x303C, 0x0801, 0xA831);
  196. EXTERN_API( OSErr )
  197. NewPictInfo                     (PictInfoID *           thePictInfoID,
  198.                                  short                  verb,
  199.                                  short                  colorsRequested,
  200.                                  short                  colorPickMethod,
  201.                                  short                  version)                            THREEWORDINLINE(0x303C, 0x0602, 0xA831);
  202. EXTERN_API( OSErr )
  203. RecordPictInfo                  (PictInfoID             thePictInfoID,
  204.                                  PicHandle              thePictHandle)                      THREEWORDINLINE(0x303C, 0x0403, 0xA831);
  205. EXTERN_API( OSErr )
  206. RecordPixMapInfo                (PictInfoID             thePictInfoID,
  207.                                  PixMapHandle           thePixMapHandle)                    THREEWORDINLINE(0x303C, 0x0404, 0xA831);
  208. EXTERN_API( OSErr )
  209. RetrievePictInfo                (PictInfoID             thePictInfoID,
  210.                                  PictInfo *             thePictInfo,
  211.                                  short                  colorsRequested)                    THREEWORDINLINE(0x303C, 0x0505, 0xA831);
  212. EXTERN_API( OSErr )
  213. DisposePictInfo                 (PictInfoID             thePictInfoID)                      THREEWORDINLINE(0x303C, 0x0206, 0xA831);
  214. #if OLDROUTINENAMES
  215. #define DisposPictInfo(thePictInfoID) DisposePictInfo(thePictInfoID)
  216. #endif  /* OLDROUTINENAMES */
  217. #if PRAGMA_STRUCT_ALIGN
  218.     #pragma options align=reset
  219. #elif PRAGMA_STRUCT_PACKPUSH
  220.     #pragma pack(pop)
  221. #elif PRAGMA_STRUCT_PACK
  222.     #pragma pack()
  223. #endif
  224. #ifdef PRAGMA_IMPORT_OFF
  225. #pragma import off
  226. #elif PRAGMA_IMPORT
  227. #pragma import reset
  228. #endif
  229. #ifdef __cplusplus
  230. }
  231. #endif
  232. #endif /* __PICTUTILS__ */