home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / gfx / misc / imagefx_sdk / sas / examples / hooks / antique.c next >
Encoding:
C/C++ Source or Header  |  1992-10-02  |  1.9 KB  |  80 lines

  1. /*
  2.  * Simple ImageFX Hook Example
  3.  *
  4.  * Performs an "antique" color tint on the current image buffer.
  5.  *
  6.  */
  7.  
  8. #include <scan/hooks.h>
  9.  
  10. /*
  11.  * Compiler specifics.  Gee, isn't it nice to have a portable language?
  12.  */
  13. #define __SAVEDS
  14.  
  15. #ifdef LATTICE
  16.  #undef __SAVEDS
  17.  #define __SAVEDS(A,B)     A __saveds B
  18. #endif
  19. #ifdef _DCC
  20.  #undef __SAVEDS
  21.  #define __SAVEDS(A,B)     __geta4 A B
  22. #endif
  23.  
  24.  
  25. /*
  26.  * This information is required by the "start.o" startup code.
  27.  */
  28. char *HookVersion = "$VER: Antique 1.00.05 (2.10.92)";
  29. char *HookName = "Antique";
  30. char *HookText = "Hook_Antique";
  31. int   HookTextCount = 1;
  32.  
  33.  
  34.  
  35. /*
  36.  * This callback function is used by EasyProcess() to actually
  37.  * perform the color operation.  Be sure to restore your A4
  38.  * register if you are using small data model!
  39.  *
  40.  * Note: we don't need a greyscale callback since we can never
  41.  * work on a greyscale buffer.
  42.  *
  43.  */
  44. __SAVEDS(void, rgb) (UBYTE *r, UBYTE *g, UBYTE *b, short i, short j)
  45. {
  46.    *g = ((int)*g * 215) >> 8;
  47.    *b = ((int)*b * 174) >> 8;
  48. }
  49.  
  50. /*********************************************************************
  51.  *
  52.  * Main hook entry point is here.  Notice the use of the function
  53.  * GetStr() to handle text; this will see if an alternate text
  54.  * file has been specified for this hook and use the text from it.
  55.  *
  56.  */
  57. void hook_main (int argc, char **argv)
  58. {
  59.    /*
  60.     * First make sure we have a buffer to work on.
  61.     */
  62.    if (ScanBase->MainBuffer == NULL)
  63.       hook_fail(GetStr(0, "No buffer to work on."));
  64.  
  65.    /*
  66.     * Make sure it's not greyscale; we can't operate on greyscale.
  67.     */
  68.    if (ScanBase->MainBuffer->Depth == 1)
  69.       hook_fail(GetStr(1, "Buffer must be color."));
  70.  
  71.    /*
  72.     * Now call the EasyProcess() function to do the actual work of
  73.     * the antique.  EasyProcess() takes care of a number of things
  74.     * for us, including regionalized processing, feathering, etc., so
  75.     * you should consider using it where possible.
  76.     */
  77.    if (!EasyProcess(GetStr(2, "Antique"), rgb, NULL)) Error();
  78. }
  79.  
  80.