home *** CD-ROM | disk | FTP | other *** search
- /*
- * Maximum.
- *
- */
-
- #include <exec/types.h>
- #include <scan/modall.h>
- #include <scan/drawinfo.h>
- #include <string.h>
- #include "common.h"
-
- #define Channel (ScanBase->sb_Channel)
-
- /**********************************************************************\
-
- Library Vectors
-
- \**********************************************************************/
-
- /*
- * XDM_Attr:
- *
- * Return to ImageFX some information about the Drawing Style (eg.
- * whether Options are needed, whether we work on greyscale or
- * color, etc.). Called when ImageFX first scans the drawing
- * style directory.
- *
- */
- ULONG __saveds __asm XDS_Attr (register __a0 struct XDrawAttr *attr)
- {
- attr->Flags = 0;
- attr->Priority = 117;
- return(0);
- }
-
- /*
- * XDS_Begin:
- *
- * Prepare before a pixel affecting operation.
- *
- */
- int __saveds __asm XDS_Begin (register __a0 struct IDrawInfo *di)
- {
- di->SPrivate = (APTR)ScanBase->MainBuffer;
- return(1);
- }
-
- /*
- * XDS_End:
- *
- * Cleanup after a pixel affecting operation.
- *
- */
- void __saveds __asm XDS_End (register __a0 struct IDrawInfo *di)
- {
- }
-
- /*
- * XDS_Get:
- *
- *
- */
- int __saveds __asm XDS_Get (register __a0 struct IDrawInfo *di)
- {
- struct Buffer *buf = (struct Buffer *)di->SPrivate;
-
- if (!buf) return(0);
-
- GetFromBuf(buf, di);
-
- return(1);
- }
-
-
- #define MAX(a,b) ((a) > (b) ? (a) : (b))
-
- BOOL __regargs MaxPutToBuf (struct Buffer *buf, struct IDrawInfo *di)
- {
- UBYTE *sr, *sg, *sb;
- UBYTE *dr, *dg, *db;
- UBYTE *red, *grn, *blu;
- UBYTE *mask;
- int i, j, x, y, mx, my;
- int left, top;
- short drawpart = (ScanBase->sb_DrawBlend * 255 / 100);
- int mix;
- short r, g, b;
- UBYTE *alphapix;
- struct Buffer *abuf = ScanBase->Alpha;
-
- if (!buf) return(FALSE);
-
- left = di->LE;
- top = di->TE;
-
- /*
- * Put the pixels into the buffer, applying blending and masking.
- * Also clip to buffer boundaries.
- */
- for (y = top, j = 0; j < di->Height; j++, y++) {
- if (y >= 0 && y < buf->Height) {
- GetBufLine(di->BOut, &sr, &sg, &sb, j);
- GetBufLine(di->BMask, &mask, NULL, NULL, j);
- GetBufLine(buf, &red, &grn, &blu, y);
- if (buf->Mask) my = y - buf->Mask->OffsetY;
- dr = red + left;
- dg = grn + left;
- db = blu + left;
- for (x = left, i = 0; i < di->Width; i++, x++) {
- mix = *mask;
- if (buf->Mask) mx = x - buf->Mask->OffsetX;
- if (x >= 0 && x < buf->Width) {
- if (CheckMask(buf->Mask, mx, my)) {
- if (mix && !CheckCloseness(*dr,*dg,*db)) {
- switch(ScanBase->sb_DrawAlpha)
- {
- case 0 : /* alpha = off */
- r = mixer(*sr, *dr, mixer(drawpart,0,mix));
- g = mixer(*sg, *dg, mixer(drawpart,0,mix));
- b = mixer(*sb, *db, mixer(drawpart,0,mix));
- break;
- case 1 : /* alpha = frisket */
- GetBufLine(abuf, &alphapix, NULL, NULL, y % abuf->Height);
- mix = mixer(mix, 0, alphapix[x % abuf->Width]);
- r = mixer(*sr, *dr, mixer(drawpart,0,mix));
- g = mixer(*sg, *dg, mixer(drawpart,0,mix));
- b = mixer(*sb, *db, mixer(drawpart,0,mix));
- break;
- case 2 : /* alpha = texture */
- GetBufLine(abuf, &alphapix, NULL, NULL, y % abuf->Height);
- r = *sr + alphapix[x % abuf->Width] - 128; if (r < 0) r = 0; else if (r > 255) r = 255;
- g = *sg + alphapix[x % abuf->Width] - 128; if (g < 0) g = 0; else if (g > 255) g = 255;
- b = *sb + alphapix[x % abuf->Width] - 128; if (b < 0) b = 0; else if (b > 255) b = 255;
- r = mixer(r, *dr, mixer(drawpart,0,mix));
- g = mixer(g, *dg, mixer(drawpart,0,mix));
- b = mixer(b, *db, mixer(drawpart,0,mix));
- break;
- }
- if (buf->Depth == 1 || (Channel & CHAN_RED)) { *dr = MAX(r,*dr); }
- if (buf->Depth > 1)
- {
- if (Channel & CHAN_GRN) { *dg = MAX(g,*dg); }
- if (Channel & CHAN_BLU) { *db = MAX(b,*db); }
- }
- }
- }
- }
- dr++; dg++; db++;
- sr++; sg++; sb++;
- mask++;
- }
- PutBufLine(buf);
- }
- }
- }
-
- /*
- * XDS_Put:
- *
- *
- */
- int __saveds __asm XDS_Put (register __a0 struct IDrawInfo *di)
- {
- struct Buffer *buf = (struct Buffer *)di->SPrivate;
-
- if (!buf) return(0);
-
- MaxPutToBuf(buf, di);
-
- return(1);
- }
-
- /*
- * XDS_Options:
- *
- * Present a window to the user allowing him to adjust drawing style
- * options. Arguments may optionally be passed from an Arexx command.
- *
- */
- int __saveds __asm XDS_Options (register __a0 LONG *args)
- {
- return(0);
- }
-
- /*
- * XDS_LoadPrefs:
- *
- * Set preferences according to information loaded from disk.
- *
- */
- int __saveds __asm XDS_LoadPrefs (register __a0 void *prefs)
- {
- return(1);
- }
-
- /*
- * XDS_SavePrefs:
- *
- * Request preferences settings that are about to be saved to disk.
- *
- */
- int __saveds __asm XDS_SavePrefs (register __a0 void *prefs)
- {
- return(1);
- }
-
- int __saveds __asm XDS_Init (void)
- {
- return(1);
- }
-
- void __saveds __asm XDS_Cleanup (void)
- {
- }
-
-
- /**********************************************************************\
-
- 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) XDS_Attr,
- (ULONG) XDS_Begin,
- (ULONG) XDS_End,
- (ULONG) XDS_Get,
- (ULONG) XDS_Put,
- (ULONG) XDS_Options,
- (ULONG) XDS_LoadPrefs,
- (ULONG) XDS_SavePrefs,
- (ULONG) 0,
- (ULONG) 0,
- (ULONG) XDS_Init,
- (ULONG) XDS_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: Maximum Drawing Style 2.0.3 (15.2.95)";
- UBYTE LibraryType = NT_XDRAWSTYLE;
-
- /*
- * 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);
- }
-
-