home *** CD-ROM | disk | FTP | other *** search
- /*
- * A Sharpen Enhanced Drawing Mode for ImageFX 2.0
- *
- */
-
- #include <exec/types.h>
- #include <scan/modall.h>
- #include <scan/drawinfo.h>
-
-
- UBYTE __regargs do_sharp (UBYTE *pix, int brow)
- {
- int val;
- int a1, a2, a3, a4;
-
- a1 = (int)(*(pix-brow));
- a2 = (int)(*(pix+brow));
- a3 = (int)(*(pix-1));
- a4 = (int)(*(pix+1));
-
- val = ( (int)(*(pix)) * 5 ) - a1 - a2 - a3 - a4;
- // val = ( (int)(*(pix)) * 3 ) - a1 - a2;
-
- // kprintf("a1=%ld,a2=%ld,a3=%ld,a4=%ld,val=%ld\n", a1,a2,a3,a4,val);
-
- if (val < 0) val = 0;
- else if (val > 255) val = 255;
-
- val = (val + *(pix)) >> 1; /* soften it a bit */
-
- return((UBYTE)val);
- }
-
- /**********************************************************************\
-
- Library Vectors
-
- \**********************************************************************/
-
- /*
- * XDM_Attr:
- *
- * Return to ImageFX some information about the Drawing Mode (eg.
- * whether Options are needed, whether we work on greyscale or
- * color, etc.). Called when ImageFX first scans the drawing
- * mode directory.
- *
- */
- ULONG __saveds __asm XDM_Attr (register __a0 struct XDrawAttr *da)
- {
- da->Flags = XDMF_NoPen;
- da->Priority = 117;
- da->HorizOffs = 1;
- da->VertOffs = 1;
- return(0);
- }
-
- /*
- * XDM_Init:
- *
- * Initialize the drawing mode.
- *
- */
- int __saveds __asm XDM_Init (void)
- {
- return(1);
- }
-
- /*
- * XDM_Cleanup:
- *
- * Cleanup the drawing mode.
- *
- */
- void __saveds __asm XDM_Cleanup (void)
- {
- }
-
- /*
- * XDM_Begin:
- *
- * Prepare before a pixel affecting operation.
- *
- */
- int __saveds __asm XDM_Begin (register __a0 struct IDrawInfo *di)
- {
- return(1);
- }
-
- /*
- * XDM_End:
- *
- * Cleanup after a pixel affecting operation.
- *
- */
- void __saveds __asm XDM_End (register __a0 struct IDrawInfo *di)
- {
- }
-
- /*
- * XDM_Affect:
- *
- * Affect a block of pixels. We may also affect some of the
- * parameters of the IDrawInfo structure, such as the X & Y
- * location of the block of pixels.
- *
- */
- void __saveds __asm XDM_Affect (register __a0 struct IDrawInfo *di)
- {
- #ifdef USE_BUFFERS
-
- int i, j;
- UBYTE *ored, *ogrn, *oblu;
- UBYTE *ired, *igrn, *iblu;
-
- for (j = 0; j < di->Height; j++) {
- GetBufLines(di->BBuf, &ired, &igrn, &iblu, j, 3);
- ired += di->BufW + 1;
- igrn += di->BufW + 1;
- iblu += di->BufW + 1;
- GetBufLine(di->BOut, &ored, &ogrn, &oblu, j);
- for (i = 0; i < di->Width; i++) {
-
- *ored++ = do_sharp(ired, di->BufW);
- *ogrn++ = do_sharp(igrn, di->BufW);
- *oblu++ = do_sharp(iblu, di->BufW);
-
- ired++; igrn++; iblu++;
- }
- PutBufLine(di->BOut);
- }
-
- #else
-
- int i, j;
- UBYTE *ored, *ogrn, *oblu;
- UBYTE *ired, *igrn, *iblu;
-
- ored = di->OutR;
- ogrn = di->OutG;
- oblu = di->OutB;
-
- for (j = 0; j < di->Height; j++) {
- ired = di->BufR + (j * di->BufW);
- igrn = di->BufG + (j * di->BufW);
- iblu = di->BufB + (j * di->BufW);
- for (i = 0; i < di->Width; i++) {
-
- *ored++ = do_sharp(ired, di->BufW);
- *ogrn++ = do_sharp(igrn, di->BufW);
- *oblu++ = do_sharp(iblu, di->BufW);
-
- ired++; igrn++; iblu++;
- }
- }
-
- #endif
-
- }
-
- /*
- * XDM_Options:
- *
- * Present a window to the user allowing him to adjust drawing mode
- * options. Arguments may optionally be passed from an Arexx command.
- * This function will only be called if the flag XDMF_AreOptions is
- * returned from XDM_Attr().
- *
- */
- int __saveds __asm XDM_Options (register __a0 LONG *args)
- {
- return(0);
- }
-
- /*
- * XDM_LoadPrefs:
- *
- * Set preferences according to information loaded from disk.
- *
- */
- int __saveds __asm XDM_LoadPrefs (register __a0 void *prefs)
- {
- return(1);
- }
-
- /*
- * XDM_SavePrefs:
- *
- * Request preferences settings that are about to be saved to disk.
- *
- */
- int __saveds __asm XDM_SavePrefs (register __a0 void *prefs)
- {
- return(1);
- }
-
-
- /**********************************************************************\
-
- Library Initialization Stuff
-
- \**********************************************************************/
-
- /*
- * This is the table of all the functions that can be called in this
- * module. The first four (Open, Close, Expunge, and Null) are reserved
- * for system use and MUST be specified in the order shown. The actual
- * functions are in the standard module startup code.
- */
- ULONG FuncTable[] = {
- /* These four MUST be present in this order */
- (ULONG) LibOpen,
- (ULONG) LibClose,
- (ULONG) LibExpunge,
- (ULONG) LibNull,
-
- /* Specific to the module */
- (ULONG) XDM_Attr,
- (ULONG) XDM_Begin,
- (ULONG) XDM_End,
- (ULONG) XDM_Affect,
- (ULONG) XDM_Options,
- (ULONG) XDM_LoadPrefs,
- (ULONG) XDM_SavePrefs,
- (ULONG) 0,
- (ULONG) 0,
- (ULONG) XDM_Init,
- (ULONG) XDM_Cleanup,
-
- /* End with -1L */
- (ULONG) -1L
- };
-
- /*
- * These are used by the standard module startup code.
- * LibraryName is the name of the library, and LibraryID is a short
- * description of the library. Both of these are largely irrelavent,
- * but they are included just for completeness.
- */
- UBYTE LibraryID[] = "$VER: Sharpen Extended Drawing Mode 2.0.19 (15.2.95)";
- UBYTE LibraryType = NT_XDRAWMODE;
-
- /*
- * This is called by the standard module startup code when Image Scan
- * first opens the module. Here we should fill in the NumGads,
- * NewGad, Language, and LangCount fields of the provided ModuleBase
- * structure if necessary.
- */
- long __asm UserOpen (register __a6 struct ModuleBase *modbase)
- {
- return(TRUE);
- }
-
- /*
- * This is called by the standard module startup code when Image Scan
- * closes the module. It should cleanup anything allocated or obtained
- * in the UserOpen() function.
- */
- long __asm UserClose (register __a6 struct ModuleBase *modbase)
- {
- return(TRUE);
- }
-
-