home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Gamma Fade Stuff / Test App / gamma.h < prev    next >
Encoding:
Text File  |  1993-03-13  |  4.6 KB  |  99 lines  |  [TEXT/KAHL]

  1. // File "gamma.h" - Header for Altering the Gamma Tables of GDevices
  2.  
  3. // * ****************************************************************************** *
  4. //
  5. //    This library is intended as a general tool for manipulating the Gamma Tables
  6. //        of Graphics Devices, to ramp them up or down in order to achieve smooth
  7. //        screen fades. The source is included for programmers who want to convert
  8. //        the library to A4-based, but it is not commented for public consumption.
  9. //    The library defines 2 globals to save state data, but the entire Table 
  10. //        manipulation is performed with unlocked handles to be easy on your heap.
  11. //        The typical memory chunk is about 600 bytes for a 13" Monitor in 8-bit 
  12. //        depth, or about 1700 bytes for one in 24-bit color. Usage will vary.
  13. //    Of course, the Classic Mac cannot use Gamma Fades, only Mac II or later machines
  14. //        with attached monitors. (I don't know about the Color Classic tho’!). Also,
  15. //        GDevice manipulation needs to follow InitGraf() & InitWindows() calls.
  16. //    Please use the listed functions to see if you can use this code before you set
  17. //        it up. As usual, this stuff is not warranteed, guaranteed, or anything--
  18. //        use it at your own risk. It is not Apple-recommended for anything, but it
  19. //        worked for me, so there!
  20. //    
  21. //        Written:    12/17/92, Matt Slot, fprefect@engin.umich.edu                
  22. //        
  23. //        Updated:     3/13/93, MJS                                                
  24. //                        •>    Updated the GammaAvail calls to be more honest.
  25. //                            Actually check to see if Grafix Devices are supported
  26. //                            on this machine w/o using Gestalt. Also, used the 
  27. //                            std. Toolbox calls to test the GDevice attributes.
  28. //                        •>    Removed extraneous calls to lock handles in several
  29. //                            locations.
  30. //                        •>    Fixed bug in DoOneGammaFade which failed if the device
  31. //                            could not be found in the list.
  32. //                        •>    Changed function prototypes to be more intuitive.
  33. //                        •>    Update descriptions in header file.
  34. //        
  35. //    
  36. //        Oh yeah, this stuff is free to anyone interested in it.
  37. //
  38. // * ****************************************************************************** *
  39.  
  40. //    A quick signature
  41. #define kGammaUtilsSig    'GAMA'
  42.  
  43. //    To help check for compatibility
  44. #define kGetDeviceListTrapNum        0xAA29
  45.  
  46. // * ****************************************************************************** *
  47.  
  48. //    Internal data storage
  49. typedef struct globalGammas {
  50.     short size, dataOffset;
  51.     GammaTblHandle saved, hacked;
  52.     GDHandle theGDevice;
  53.     struct globalGammas **next;
  54.     } globalGammas, *globalGammasPtr, **globalGammasHdl;
  55.     
  56. // * ****************************************************************************** *
  57. // * ****************************************************************************** *
  58. // Function Prototypes
  59.  
  60. Boolean IsGammaAvailable(void);
  61. Boolean IsOneGammaAvailable(GDHandle theGDevice);
  62.  
  63. //    These routines help you determine whether you can use the Gamma Table Utils
  64. //        on the current machine. The first checks all attached monitors, and the 
  65. //        second just checks the indicated monitor. Each returns TRUE if you can 
  66. //        use the functions, or FALSE if you can't. • Note: Before calling any other
  67. //        Gamma Table function below, use this function to see if you are allowed.
  68.  
  69. // * ****************************************************************************** *
  70.  
  71. OSErr SetupGammaTools(void);
  72. OSErr DisposeGammaTools(void);
  73.  
  74. //    These routines must bracket any calls to the Gamma Table functions, perhaps
  75. //        at the head and tail of your main(). The first sets up the data structures
  76. //        necessary to save and restore the state of your monitors. The second
  77. //        disposes of all the internal data structures, but does not reset the
  78. //        monitors to their original states. Both return the error code if some
  79. //        part failed. 
  80.  
  81. // * ****************************************************************************** *
  82.  
  83. OSErr DoGammaFade(short percent);
  84. OSErr DoOneGammaFade(GDHandle theGDevice, short percent);
  85.  
  86. //    Use the first function to Fade each of your monitors to some percentage of their
  87. //        initial brightness (100 = bright, 0 = dim). Repeatedly call this to ramp your
  88. //        monitors up or down. The second function performs the same function, but only
  89. //        for the specified monitor. Both return any applicable error codes.
  90. //    Be sure to set up the necessary save-state data structures before you start by
  91. //        calling the compatibility and initialization functions. 
  92.  
  93. // * ****************************************************************************** *
  94.  
  95. OSErr GetDevGammaTable(GDHandle theGDevice, GammaTblPtr *theTable);
  96. OSErr SetDevGammaTable(GDHandle theGDevice, GammaTblPtr *theTable);
  97.  
  98. //    These routines are low-level interfaces to the device drivers for the monitors.
  99. //        Use them at your own risk.