#ifndef ARTEFFECT_AE_PLUGIN_H
#define ARTEFFECT_AE_PLUGIN_H

/*
**    $VER: ae_plugin.h 1.0 (18.12.96)
**    Include Release 1
**
**    AEPlugIn library structures and constants
**
**    (C) Copyright 1992-1996 A. Pratsch
**        All Rights Reserved
**
**    This library does all necessary things to automatically create
**    plugins with simple GUIs for ArtEffect. This includes all
**    necessary message communication.
*/

#ifndef EXEC_PORTS_H
#include <exec/ports.h>
#endif

#ifndef UTILITY_TAGITEM_H
#include <utility/tagitem.h>
#endif

/*------------------------------------------------------------------------------------------------*/
/*
**    Output types for ReadLine and WriteLine operations
**    X means don't care, this byte entry will be ignored.
**    for reading this means this byte is undefined.
*/
#define BITMAP_TYPE_RGB     0
#define BITMAP_TYPE_RGBA    1
#define BITMAP_TYPE_RGBX    2
#define BITMAP_TYPE_ARGB    3   /* only for WriteLine implemented                                                  */
#define BITMAP_TYPE_XRGB    4   /* only for WriteLine implemented                                                  */
#define BITMAP_TYPE_GRAY8   5
#define BITMAP_TYPE_RED     6   /* reads/writes only the red part (readline/writeline only)                        */
#define BITMAP_TYPE_GREEN   7   /* reads/writes only the green part (readline/writeline only)                      */
#define BITMAP_TYPE_BLUE    8   /* reads/writes only the blue part (readline/writeline only)                       */
#define BITMAP_TYPE_INDEX   9   /* reads/writes index color data (color table must be correctly set for this type) */
#define BITMAP_TYPE_MONO   10   /* reads/writes monochrome data (bits: 0 black, 1 white)                           */
#define BITMAP_TYPE_ALPHA  11   /* reads/writes alpha channel only                                                 */

/* extra modes for AE_WriteHLine only */
#define BITMAP_TYPE_INDEX2 20   /* writes index color data with 2bits/pixel (color table must be correctly set for this type) */
#define BITMAP_TYPE_INDEX4 21   /* writes index color data with 4bits/pixel (color table must be correctly set for this type) */


/*------------------------------------------------------------------------------------------------*/
/*==================================== AE_AllocPicture types =====================================*/
/*------------------------------------------------------------------------------------------------*/

#define PIC_MONOCHROME  0
#define PIC_GRAYSCALE   1
#define PIC_INDEX       2
#define PIC_RGB         3       /* obsolete values are 24,32, they are accepted only for reason of compatibility */
#define PIC_CMYK        4
#define PIC_CIE         5

/*
**  Only allowed for writing (reading is only possible with access cache)
**  (cchan might be 3 or 0, achan might be 1 or 0 in release 2).
*/
#define BITMAP_TYPE_NATIVE(cchan,achan) ((cchan<<24) | (achan<<16) | 0xffff)


/*------------------------------------------------------------------------------------------------*/
/*========================================= plugin types =========================================*/
/*------------------------------------------------------------------------------------------------*/

typedef enum {
        PLUGIN_TYPE_UNDEFINED = 0,
        PLUGIN_TYPE_LOADER_SAVER,       /* Picture/Brush loader & saver            */
        PLUGIN_TYPE_LOADER,             /* Picture/Brush loading only              */
        PLUGIN_TYPE_SAVER,              /* Picture/Brush saving only               */
        PLUGIN_TYPE_CREATOR,            /* Picture creator (e.g. a fraktal plugin) */
        PLUGIN_TYPE_FILTER,             /* Filter/...                              */
        PLUGIN_TYPE_SCANNER,            /* Project/Aquire                          */
        PLUGIN_TYPE_PRINTER,            /* Project/Print                           */
        PLUGIN_TYPE_ERROR = 100
} Type;


/*------------------------------------------------------------------------------------------------*/
/*======================================= filter sub types =======================================*/
/*------------------------------------------------------------------------------------------------*/

typedef enum {
        PLUGIN_FILTER_OTHER = 0,
        PLUGIN_FILTER_COLOR,
        PLUGIN_FILTER_BLUR,
        PLUGIN_FILTER_SHARPEN,
        PLUGIN_FILTER_NOISE,
        PLUGIN_FILTER_STYLIZE,
        PLUGIN_FILTER_DISTORTION,
        PLUGIN_FILTER_PIXELATE,
        PLUGIN_FILTER_VIDEO,
        PLUGIN_FILTER_CUSTOM
} SubType;


/*------------------------------------------------------------------------------------------------*/
/*================== captibilities for loaders/savers (not implemented for now) ==================*/
/*------------------------------------------------------------------------------------------------*/

#define PLUGIN_CAPATIBILITIES_DPI           (1<<0)  /* supports dpi entry                                               */
#define PLUGIN_CAPATIBILITIES_LOSSY         (1<<1)  /* is a lossy compression format (for warning on save)              */

#define PLUGIN_CAPATIBILITIES_STENCIL       (1<<8)  /* plugin supports bitmask=0/1 stencils                             */
#define PLUGIN_CAPATIBILITIES_ALPHA         (1<<9)  /* plugin supports alpha channel stencils                           */
#define PLUGIN_CAPATIBILITIES_NEEDALPHA     (1<<10) /* plugin always save alpha channel/bitmask stencil                 */
#define PLUGIN_CAPATIBILITIES_MULTIALPHA    (1<<11) /* plugin is capable of saving multiple alpha channels              */
#define PLUGIN_CAPATIBILITIES_SAVEALPHA     (1<<12) /* plugin is configured to save alpha channel/bitmask stencil       */

#define PLUGIN_CAPATIBILITIES_LAYERS        (1<<16) /* plugin supports saving of layers                                 */
#define PLUGIN_CAPATIBILITIES_SAVELAYERS    (1<<17) /* plugin is configured to save layers                              */

#define PLUGIN_CAPATIBILITIES_NO24          (1<<24) /* does not support 24bit color (quantization process is necessary) */
#define PLUGIN_CAPATIBILITIES_INDEXCOLOR    (1<<25) /* does support indexed color loading/saving                        */
#define PLUGIN_CAPATIBILITIES_MONOCHROMATIC (1<<26) /* does support monochromatic loading/saving                        */

#define PLUGIN_CAPATIBILITIES_DIRECT        (1<<31) /* PRIVATE! if the bitmap access functions are NOT used             */


/*------------------------------------------------------------------------------------------------*/
/*======================================== plugin events =========================================*/
/*------------------------------------------------------------------------------------------------*/

#define PLUGIN_EVENT_GADGET         1   /* gadget was used                                    */
#define PLUGIN_EVENT_REXXCMD        2   /* rexx command was sent                              */
#define PLUGIN_EVENT_EXECUTE        3   /* automatically created execute or one of your       */
                                        /* action/grab buttons was pressed                    */
#define PLUGIN_EVENT_RECALC_PREVIEW 4   /* recalculate your preview                           */
#define PLUGIN_EVENT_SETTINGS       5   /* this message is optional, if you want to receive   */
                                        /* specify PLUGIN_INFO_SEND_SETTINGS tag (data=TRUE). */
#define PLUGIN_EVENT_LOAD           10  /* load the supplied object (or pop up settings)      */
#define PLUGIN_EVENT_SAVE           11  /* save the supplied object (or pop up settings)      */
#define PLUGIN_EVENT_PRINT          12  /* print the supplied object (or pop up settings)     */
#define PLUGIN_EVENT_CLOSE          20  /* window close event                                 */
#define PLUGIN_EVENT_QUIT           21  /* event what signals you application to quit         */


/*------------------------------------------------------------------------------------------------*/
/*==================================== PlugIn GUI definitions ====================================*/
/*------------------------------------------------------------------------------------------------*/

#define DEFMATRIX(w,h)  ((w<<8)+h)

#define CTFLG_RGB       (1<<0)      /* RGB conversion table (incl. buttons) */
#define CTFLG_HSV       (1<<1)      /* HSV conversion table (incl. buttons) */
#define CTFLG_GRAY      (1<<2)      /* GRAY (may be other transformations too) (excluding buttons) */
#define CTFLG_FREE      (1<<3)      /* allow free manipulation */
#define CTFLG_SPLINE    (1<<4)      /* allow spline manipulation */

/* Then a GUI is created its gadgets are automatically numbered.
 * If you want to alter any gadget value. You have to use this ID
 * tag to specify the gadget to alter. (starting with 1 at the
 * first gadget). Note: a matrix gadget has only one gadget id.
 */
#define PLUGIN_INFO_DUMMY             (TAG_USER + 32)

#define PLUGIN_INFO_ID                (PLUGIN_INFO_DUMMY + 1)
#define PLUGIN_INFO_NAME              (PLUGIN_INFO_DUMMY + 2)   /* Title for effect window and name                   */
#define PLUGIN_INFO_MENUTITLE         (PLUGIN_INFO_DUMMY + 3)   /* override for menutitle for effect window           */
#define PLUGIN_INFO_TITLE             (PLUGIN_INFO_DUMMY + 4)   /* override for title of window or requester          */
#define PLUGIN_INFO_COPYRIGHT         (PLUGIN_INFO_DUMMY + 5)   /* copyright string                                   */
#define PLUGIN_INFO_PARSESTRING       (PLUGIN_INFO_DUMMY + 6)   /* parse string to identify files (loaders only)      */
#define PLUGIN_INFO_MAKRO_ARGS        (PLUGIN_INFO_DUMMY + 7)   /* arexx parse string if supported by the plugin      */
#define PLUGIN_INFO_GUI               (PLUGIN_INFO_DUMMY + 8)   /* TRUE has GUI, FALSE has no GUI (if TRUE an         */
                                                                /* execute button will be created and the setup       */
                                                                /* list will be searched for GUI tags)                */
#define PLUGIN_INFO_PRIORITY          (PLUGIN_INFO_DUMMY + 9)   /* plugin priority if a plugin is searched you may    */
                                                                /* e.g. set its priority to let it be searched first  */
                                                                /* or last                                            */
#define PLUGIN_INFO_FILTERTYPE        (PLUGIN_INFO_DUMMY + 10)
#define PLUGIN_INFO_CUSTOMFILTER      (PLUGIN_INFO_DUMMY + 11)
#define PLUGIN_INFO_LOCALE_FILE       (PLUGIN_INFO_DUMMY + 12)
#define PLUGIN_INFO_MAKRO_ARRAYSIZE   (PLUGIN_INFO_DUMMY + 13)  /* the size of a dos.library/ReadArgs compatible      */
                                                                /* structure to receive rexx args in bytes            */
#define PLUGIN_INFO_CONFIG            (PLUGIN_INFO_DUMMY + 14)  /* a special config structure, which is automatically */
                                                                /* loaded and saved with the plugin, the first entry  */
                                                                /* is an ULONG describing the length of the structure */
                                                                /* (including the length field)                       */
#define PLUGIN_INFO_CAPATIBILITIY_FLAGS (PLUGIN_INFO_DUMMY+15)  /* specify your capatibilite flags here see above)    */
#define PLUGIN_INFO_SEND_SETTINGS     (PLUGIN_INFO_DUMMY + 16)  /* if TRUE you will receive settings messages.        */
#define PLUGIN_INFO_MAKRO_GUI         (PLUGIN_INFO_DUMMY + 17)

#define PLUGIN_MIM_POPUP    1
#define PLUGIN_MIM_ADJUST   2
#define PLUGIN_MIM_EXEC     4

#define PLUGIN_INFO_BEGIN_HGROUP      (PLUGIN_INFO_DUMMY + 100) /* start a horizontal group of elements */
#define PLUGIN_INFO_END_GROUP         (PLUGIN_INFO_DUMMY + 101) /* end a horizontal group of elements   */
#define PLUGIN_INFO_BEGIN_VGROUP      (PLUGIN_INFO_DUMMY + 102) /* start a vertical group of elements   */
#define PLUGIN_INFO_SEPARATOR         (PLUGIN_INFO_DUMMY + 103) /* separates gadgets by a bar           */
#define PLUGIN_INFO_TITLE_SEPARATOR   (PLUGIN_INFO_DUMMY + 104) /* separates gadgets by a bar with text */

/*
** useful layout macros
*/
#define AE_HGroup       PLUGIN_INFO_BEGIN_HGROUP,0
#define AE_VGroup       PLUGIN_INFO_BEGIN_VGROUP,0
#define AE_EndGroup     PLUGIN_INFO_END_GROUP,0
#define AE_Bar          PLUGIN_INFO_SEPARATOR,0
#define AE_Title(name)  PLUGIN_INFO_TITLE_SEPARATOR,(ULONG)name

/* supports preview: TRUE (1) or not: FALSE (0)
 * (normally this should be the first gadget)
 * custom previews are little display areas, that may be handled
 * completly by yourself. They are handled mostly identical to
 * standard previews, except that you will receive an empty bitmap
 * from create preview.
 * Edit areas are the same as custom previews, except that they also
 * handle mouse events for you and report them to your application
 * see above (PLUGIN_EVENT_MOUSE...) for more information.
 */
#define PLUGIN_INFO_PREVIEW           (PLUGIN_INFO_DUMMY + 112)
#define PLUGIN_INFO_CUSTOM_PREVIEW    (PLUGIN_INFO_DUMMY + 113)
#define PLUGIN_INFO_EDITAREA          (PLUGIN_INFO_DUMMY + 114)

#define PLUGIN_INFO_VALUE_MIN         (PLUGIN_INFO_DUMMY + 120) /* if specified you get a slider with a integer gadget, */
#define PLUGIN_INFO_VALUE_MAX         (PLUGIN_INFO_DUMMY + 121) /* otherwise you only get a integer gadget              */
#define PLUGIN_INFO_VALUE_HOOK        (PLUGIN_INFO_DUMMY + 122) /* may be specified (not supported in release 1)        */
#define PLUGIN_INFO_VALUE_DEF         (PLUGIN_INFO_DUMMY + 123) /* defaults to min therefore it may NOT be specified    */
                                                                /* before the VALUE_MIN tag                             */
#define PLUGIN_INFO_VALUE             (PLUGIN_INFO_DUMMY + 124) /* last item to be specified (data pointer to label)    */

/* Pointer to array of strings terminated by NULL.
 * The first entry is the title of the option group
 * (it may be NULL without terminating the list
 * if there is no title)
 */
#define PLUGIN_INFO_HRADIO            (PLUGIN_INFO_DUMMY + 125) /* if the GUI renderer is changed this */
                                                                /* gadget may also be vertical grouped */
#define PLUGIN_INFO_RADIO             (PLUGIN_INFO_DUMMY + 126) /* standard vertical radio gadgets     */
#define PLUGIN_INFO_CYCLE             (PLUGIN_INFO_DUMMY + 127) /* cycle gadget (with popup)           */
#define PLUGIN_INFO_CHECKBOX          (PLUGIN_INFO_DUMMY + 128) /* pointer to label                    */
#define PLUGIN_INFO_ACTIVE            (PLUGIN_INFO_DUMMY + 129) /* for HRADIO/RADIO/POPUP[0..n] and    */
                                                                /* also for CHECKBOX[0,1]              */

/* start a method of the plugin (if not specified
 * a default apply button of type PLUGIN_INFO_EXECUTE will be created).
 * BUTTON is the same as GRAB and ACTION, except that BUTTON does not
 * supply the picture to the plugin. ACTION requires that you UPDATE
 * THE PICTURE after processing even if you do not change the data. If
 * you know that the data is not changed use GRAB.
 */
#define PLUGIN_INFO_GRAB              (PLUGIN_INFO_DUMMY + 140) /* pointer to label */
#define PLUGIN_INFO_ACTION            (PLUGIN_INFO_DUMMY + 141)
#define PLUGIN_INFO_BUTTON            (PLUGIN_INFO_DUMMY + 142)

/* for a custom convolution matrix (width, height) */
#define PLUGIN_INFO_MATRIX_DATA       (PLUGIN_INFO_DUMMY + 150)
#define PLUGIN_INFO_MATRIX            (PLUGIN_INFO_DUMMY + 151) /* data = DEFMATRIX(w,h) */
#define PLUGIN_INFO_COLOR_DATA        (PLUGIN_INFO_DUMMY + 152)
#define PLUGIN_INFO_COLOR_TABLE       (PLUGIN_INFO_DUMMY + 153) /* see flag list above CTFLG_... */

/* shows reset button for matrix or color table element */
#define PLUGIN_INFO_RESET_BUTTON      (PLUGIN_INFO_DUMMY + 160)

#define PLUGIN_INFO_ANGLE_INPUT       (PLUGIN_INFO_DUMMY + 161)
#define PLUGIN_INFO_CURVE_INPUT       (PLUGIN_INFO_DUMMY + 162)
#define PLUGIN_INFO_TABLE_INPUT       (PLUGIN_INFO_DUMMY + 163)


/*------------------------------------------------------------------------------------------------*/
/*===================================== application related ======================================*/
/*------------------------------------------------------------------------------------------------*/

#ifdef __cplusplus
class CPlugInWin;
#else
typedef void *CPlugInWin;
#endif

#define ARTEFFECT_VERSION 2

typedef struct {
    /*
    ** public
    */
    long Version;

    struct MsgPort *UserPort;
    long Percent;               /* current progress state (update for your own manipulations) */
    BOOL Abort;                 /* may be read after BeginOperation to                        */
                                /* check if an operation should be aborted                    */
    char *PubScreenName;        /* name of ArtEffects Public Screen                           */
    BOOL Quiet;
} AE_AppObj;

typedef AE_AppObj *AE_AppObjPtr;


/*------------------------------------------------------------------------------------------------*/
/*============================ dialog related (PRIVATE do not access) ============================*/
/*------------------------------------------------------------------------------------------------*/

typedef struct {
    CPlugInWin *dl_Window;
    struct TagItem *dl_Tags;
} AE_Dialog;

typedef AE_Dialog *AE_DialogPtr;


/*------------------------------------------------------------------------------------------------*/
/*==================================== brush/picture related =====================================*/
/*------------------------------------------------------------------------------------------------*/

typedef struct { UBYTE Red, Green, Blue, Alpha; } CLUTEntry;

typedef struct {
    /*
    **  Version of the object structure. This is included
    **  for future extensions. And will be 2 for ArtEffect II.
    **  ATTENTION! The first ArtEffect release had a completly
    **  different structure.
    */
    long Version;

    /*
    ** width & height of this object
    */
    long ObjWidth, ObjHeight;

    /*
    **  preview scaling in promille or 0 if the picture itself
    **  is rendered.(ATTENTION was percent!)
    */
    long ObjScale;

    /*
    **  the following rectangle describes the biggest region,
    **  which is at least partially not covered by a mask.
    **  Color data may not be changed outside this region.
    **  ReadHLine/WriteHLine and ReadVLine/WriteHLine and
    **  all other functions except for ReadPixel/WritePixel
    **  and AccessCache functions do handle these information
    **  automatically.
    **
    **  ATTENTION: Before ArtEffect 2 also ReadPixel/WritePixel
    **  handles these Values automatically. For the reason of
    **  speed this task has been transfered to the plugin itself.
    */
    long LeftEdge, TopEdge;
    long Width, Height;

    /*
    **  width & height of the picture, this bitmap is taken
    **  from (useful for calculating correct previews, or
    **  delivering correct dimensions).
    */
    long PicWidth, PicHeight;

    /*
    **  The following entry contains the name of the picture
    **  this object belongs to. Creaters may change this entry
    **  to give a name to the picture they created.
    */
    char *ObjName;
} AE_Obj;

typedef AE_Obj *AE_ObjPtr;


/*------------------------------------------------------------------------------------------------*/
/*=========================================== Settings ===========================================*/
/*------------------------------------------------------------------------------------------------*/
/*
**  You may access all the entries in the settings
**  structure if Version >= AE_SETTINGS_VERSION.
*/
#define AE_SETTINGS_VERSION ARTEFFECT_VERSION     /* obsolete */

enum antialiasing { AA_NONE=0, AA_GOOD, AA_BEST };

typedef struct AE_Settings {
    UWORD Version;
    UWORD AntiAliasing;
    ULONG FGColor;
    ULONG BGColor;
    long ColorCount;            /* number of colors in RangeColors [0,number[ */
    ULONG RangeColors[256];
} AE_Settings;

typedef AE_Settings *AE_SettingsPtr;


/*------------------------------------------------------------------------------------------------*/
/*============================================ Event =============================================*/
/*------------------------------------------------------------------------------------------------*/

#define EVENTFLG_INCL_ALPHA_CHANNEL       (1<<0)
#define EVENTFLG_INCL_ALL_ALPHA_CHANNELS  (1<<1)
#define EVENTFLG_INCL_LAYERS              (1<<2)

typedef struct {
    /*
    ** private area (DO NOT TOUCH THESE FIELDS!)
    */
    struct Message ev_Message;
    void *PlugIn;
    long AbortCode;
    long reserved[10];

    /*
    ** public area
    */

    long Error;             /* return an error of type PLUGIN_ERROR here (see below for codes)                       */
    UWORD Type;             /* event type: e.g. PLUGIN_EVENT_LOAD                                                    */
    UWORD ID;               /* gadget id 1 - ... (starting with your first gadget) or EVENTFLG for PLUGIN_EVENT_SAVE */

    /*
    **  result for a gadget:
    **  - checkbox 0=off / 1=on
    **  - radio 0,1,... (starting with your first entry)
    **  - value or filename for LOAD/SAVE EVENTS, or matrix ptr for MATRIX object
    */
    LONG Value;               

    /*
    **  preview bitmap to apply the effect to
    **  (if NULL do not create a preview!).
    */
    AE_ObjPtr Object;
} AE_Event;

typedef AE_Event *AE_EventPtr;


/*------------------------------------------------------------------------------------------------*/
/*====================================== Convolution Matrix ======================================*/
/*------------------------------------------------------------------------------------------------*/
/*
**  width, height - are describing the size of the matrix
**  bias - is a value to add to the calculation result
**  entries - is the matrix itself its center is always at
**      entries[10][10]. ALL unused entries should be set
**      to zero.
*/
typedef struct {
    UWORD version;
    UWORD width, height, bias, divisor;
    WORD entries[21][21];
} AE_Matrix;

typedef AE_Matrix *AE_MatrixPtr;


/*------------------------------------------------------------------------------------------------*/
/*======================== ColorProcessor, ColorSpaceProcessor, Histogram ========================*/
/*------------------------------------------------------------------------------------------------*/

typedef UBYTE AE_ColorTable[256];
typedef WORD AE_HueTable[384];

/*
**  only the first 256 fields are filled for CSP_FLG_(VAL/SAT)PROC
**  the rest is only used for CSP_FLG_(VAL/SAT)PROC_HUE
*/
typedef WORD AE_CSpaceTable[384];

#define HISTOFLG_WANT_RED   (1<<0)
#define HISTOFLG_WANT_GREEN (1<<1)
#define HISTOFLG_WANT_BLUE  (1<<2)
#define HISTOFLG_WANT_GRAY  (1<<3)    /* rf,gf or bf has to be unequal zero                        */
#define HISTOFLG_WANT_LUM   (1<<4)    /* luminance is calculated (max(r, g, b) - min(r, g, b)) / 2 */

typedef struct {
    ULONG Flags;                            /* HISTOFLG's        */
    ULONG red[256], green[256], blue[256];  /* r,g,b pixel count */

    long rf, gf, bf;                        /* luminance pixel count (r,g,b weights could be given in rf, gf, bf) */
    ULONG luminance[256];
} AE_Histogram;

typedef struct {
    long X,Y;
} AE_Points;

typedef AE_Points *AE_PointsPtr;

#define CSP_FLG_HUESHIFT    (1<<0)
#define CSP_FLG_SATPROC     (1<<1)
#define CSP_FLG_VALPROC     (1<<2)
#define CSP_FLG_SATPROC_HUE (1<<3)
#define CSP_FLG_VALPROC_HUE (1<<4)

#define DUP_FLG_READ_ONLY   (1<<0)


/*------------------------------------------------------------------------------------------------*/
/*========================================== Distortion ==========================================*/
/*------------------------------------------------------------------------------------------------*/

#define SPECIAL_FLG_ANTI_ALIASED (1<<0)

typedef struct {
    long sx, sy;    /* source pixel position (integer or interger/fractional) */
    long dx, dy;    /* result pixel position                                  */
} AE_DistortMsg;

typedef AE_DistortMsg *AE_DistortMsgPtr;

/*
** distort quality (QUICK does no anti-aliasing rendering at all, otherwise set
** this value to the antialiasing value you got from arteffect)
*/
#define DISTORTION_QUICK            (0<<0)
#define DISTORTION_ANTIALIASING1    (1<<0)
#define DISTORTION_ANTIALIASING3    (3<<0)

/*
** if your hook's results may be out of the picture's coordinate system
** this enables the range check see the following defines to set
** the action which should be taken if a pixel is out of range
*/
#define DISTORTION_RANGECHECK       (1<<2)

#define DISTORTION_RANGE_FAIL_MODES (7<<3)

#define DISTORTION_NO_CHANGE    (0<<3)      /* copy the pixel from the other side of the picture. */
#define DISTORTION_BACKGROUND   (1<<3)      /* copy the background color to the pixels position   */
#define DISTORTION_WRAP         (2<<3)      /* leave the pixel color unchanged                    */

/*
** if you specify this flag you get the source coordinates sx,sy and
** have to calculate the destination coordintes dx,dy. Otherwise you
** get dx,dy and have to calculate sx,sy. The later case is always
** to be prefered because it insures that no pixel is forgotten.
*/
#define DISTORTION_CALC_DEST    (1<<6)


/*------------------------------------------------------------------------------------------------*/
/*====================================== Parser for LOADERs ======================================*/
/*------------------------------------------------------------------------------------------------*/
/*
**  PICSCAN_CHAR and PICSCAN_SKIP are or'd with its length,
**  but if you write PICSCAN_CHAR|0 the length is in the following
**  UWORD.
**
**  example sequences
**
**  PICSCAN_WILDCARD, '#','?','.','q','r','t',0, PICSCAN_END
**  accepts all files which filenames match "#?.qrt".
**
**  PICSCAN_CHAR|4, 'F','O','R','M',PICSCAN_SKIP|4,PICSCAN_CHAR|4, 'I','L','B','M',PICSCAN_END
**  accepts all IFF-ILBM files.
*/
#define PICSCAN_MASK      (7<<5)
#define PICSCAN_VALUE     (~(7<<5))
#define PICSCAN_END       (0<<5)          /* if parsing was successfull until PICSCAN_END it will be accepted */
#define PICSCAN_CHAR      (1<<5)          /* PICSCAN_CHAR|x: compare the next x bytes which follow            */
#define PICSCAN_BYTE      PICSCAN_CHAR    /* alias                                                            */
#define PICSCAN_SKIP      (2<<5)          /* PICSCAN_SKIP|x: skip the next x bytes                            */
#define PICSCAN_NEW       (3<<5)          /* a new alternative parsing sequence follows                       */
#define PICSCAN_WILDCARD  (4<<5)          /* a wildcard string follows                                        */
#define PICSCAN_UNUSED1   (5<<5)
#define PICSCAN_UNUSED2   (6<<5)
#define PICSCAN_UNUSED3   (7<<5)


/*------------------------------------------------------------------------------------------------*/
/*========================================= error codes ==========================================*/
/*------------------------------------------------------------------------------------------------*/

#define PLUGIN_ERROR_NONE           0
#define PLUGIN_ERROR_INITIALIZATION 1
#define PLUGIN_ERROR_MEMORY         2

#define PLUGIN_ERROR_OPEN           10
#define PLUGIN_ERROR_READ           11
#define PLUGIN_ERROR_WRITE          12

/*
**  If the parsing sequence is not sufficient to exactly check
**  if a file is loadable by your loader, you may use a more
**  general parsing sequence (e.g. #?) and return UNKNOWN_FORMAT
**  or UNKNOWN_SUB_TYPE if your loader does not know the file. Then
**  this error occurs, ArtEffect automatically invokes the next
**  possible loader available. But generally the parsing sequence
**  should be sufficient and so it SHOULD be used for the reason of
**  speed (it slows down loading if every loader has to be invoked,
**  especially if you have many of them).
*/
#define PLUGIN_ERROR_UNKNOWN_FORMAT     20
#define PLUGIN_ERROR_UNKNOWN_SUB_TYPE   21
#define PLUGIN_ERROR_CORRUPT_FILE       22

/*
**  When you are able to give a more detailed error message you might
**  return this error, so arteffect does not popup another error
**  requester.
*/
#define PLUGIN_ERROR_CUSTOM     23
#define PLUGIN_ERROR_ABORTED    50
#define PLUGIN_ERROR_DEBUG      100


/*------------------------------------------------------------------------------------------------*/
/*============================= requester types for AE_DoRequestTags =============================*/
/*------------------------------------------------------------------------------------------------*/

#define AER_TYPE_OPTIONS    1
#define AER_TYPE_INFO       2


/*------------------------------------------------------------------------------------------------*/
/*============================= requester tags for AE_DoRequestTags ==============================*/
/*------------------------------------------------------------------------------------------------*/

#define AER_Dummy       TAG_USER+99
#define AER_BodyText    (AER_Dummy + 0x01)
#define AER_Options     (AER_Dummy + 0x02)
#define AER_TitleText   (AER_Dummy + 0x03)


/*------------------------------------------------------------------------------------------------*/
/*========================================= Access Cache =========================================*/
/*------------------------------------------------------------------------------------------------*/
/*
** access cache error codes
*/
#define AC_ILLEGAL_PARAMETER    -1
#define AC_METHOD_NOT_SUPPORTED -2

/*
** access cache flagset
*/
#define AC_CHANNEL_MASK           ((1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6))
#define AC_ALPHA_CHANNELS         (1<<0)
#define AC_COLOR_CHANNELS         (1<<1)
#define AC_STORAGE_CHANNELS       (1<<2)
#define AC_PAPER_CHANNELS         (1<<3)

#define AC_LINE_TYPE_MASK         ((1<<7)|(1<<8)|(1<<9))
#define AC_HLINE_CACHE            (0<<7)
#define AC_VLINE_CACHE            (1<<7)
#define AC_PIXEL_CACHE            (2<<7)

#define AC_COLOR_TYPE_MASK        ((1<<10)|(1<<11)|(1<<12))
#define AC_NEED_NO_SPECIAL_COLOR  (0<<10)
#define AC_NEED_RGB               (1<<10)
#define AC_NEED_HSB               (2<<10)
#define AC_NEED_CMYK              (3<<10)

#define AC_INIT_ONLY              (1<<13)
#define AC_READ_ONLY              (1<<14)


#ifdef __PPC__
typedef ULONG (*CalcFkt)(void *UserData, AE_ObjPtr, double sx, double sy, double *dx, double *dy);
#endif

#endif  /* LIBRARIES_AEPLUGIN_PROTOS_H */

