home *** CD-ROM | disk | FTP | other *** search
- /*
- * Simple ImageFX Hook Example
- *
- * Performs an "antique" color tint on the current image buffer.
- *
- */
-
- #include <scan/hooks.h>
-
- /*
- * Compiler specifics. Gee, isn't it nice to have a portable language?
- */
- #define __SAVEDS
-
- #ifdef LATTICE
- #undef __SAVEDS
- #define __SAVEDS(A,B) A __saveds B
- #endif
- #ifdef _DCC
- #undef __SAVEDS
- #define __SAVEDS(A,B) __geta4 A B
- #endif
-
-
- /*
- * This information is required by the "start.o" startup code.
- */
- char *HookVersion = "$VER: Antique 1.00.05 (2.10.92)";
- char *HookName = "Antique";
- char *HookText = "Hook_Antique";
- int HookTextCount = 1;
-
-
-
- /*
- * This callback function is used by EasyProcess() to actually
- * perform the color operation. Be sure to restore your A4
- * register if you are using small data model!
- *
- * Note: we don't need a greyscale callback since we can never
- * work on a greyscale buffer.
- *
- */
- __SAVEDS(void, rgb) (UBYTE *r, UBYTE *g, UBYTE *b, short i, short j)
- {
- *g = ((int)*g * 215) >> 8;
- *b = ((int)*b * 174) >> 8;
- }
-
- /*********************************************************************
- *
- * Main hook entry point is here. Notice the use of the function
- * GetStr() to handle text; this will see if an alternate text
- * file has been specified for this hook and use the text from it.
- *
- */
- void hook_main (int argc, char **argv)
- {
- /*
- * First make sure we have a buffer to work on.
- */
- if (ScanBase->MainBuffer == NULL)
- hook_fail(GetStr(0, "No buffer to work on."));
-
- /*
- * Make sure it's not greyscale; we can't operate on greyscale.
- */
- if (ScanBase->MainBuffer->Depth == 1)
- hook_fail(GetStr(1, "Buffer must be color."));
-
- /*
- * Now call the EasyProcess() function to do the actual work of
- * the antique. EasyProcess() takes care of a number of things
- * for us, including regionalized processing, feathering, etc., so
- * you should consider using it where possible.
- */
- if (!EasyProcess(GetStr(2, "Antique"), rgb, NULL)) Error();
- }
-
-