/*
 * Scan 'C' Header File
 * Written by Thomas Krehbiel
 *
 * Loaders/savers.
 *
 */

#ifndef SCAN_LOADSAVE_H


#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif

#ifndef EXEC_NODES_H
#include <exec/nodes.h>
#endif

#ifndef EXEC_LISTS_H
#include <exec/lists.h>
#endif

/* why is this here?  becuase render modules usually include loadsave.h */
#ifndef SCAN_REND_H
#include <scan/rend.h>
#endif


/************************************************************************
 * The loader passes back an array of these structures to identify
 * what kinds of files it can load.  The end of the array is signified
 * by a NULL Identifier field.  The Identifier is a string of bytes that
 * must be matched at the beginning of the file, for Length bytes.
 */

struct LoadFormat {
   char    *Identifier;             /* Variable-length identifier bytes */
   int      Length;                 /* Length of identifier string */
   char    *Name;                   /* Name of format (for user) */
   int      ID;                     /* Loader-specific ID code */
   UWORD    Flags;                  /* Various flags (see below) */
};

/* flags for LoadFormat: */
#define LOA_NOFILE   (0x0200)       /* Tell ImageFX not to ask for filename
                                       when loading this format - this is
                                       used by the clipboard loader */

#define LOA_MULTI    (0x1000)       /* This file format contains multiple
                                       images (eg. animation) - used to
                                       determine whether a file is an
                                       animation or not. */

/*
 * A list of these is maintained by Image Scan.
 */

struct LoadNode {
   struct Node       Node;          /* Exec-standard node */
   struct LoadFormat Format;        /* Format information */
   char              Loader[128];   /* Loader to open and call */
   int               Bytes;         /* Length of node in bytes */
   char              Name[60];      /* Name of the loader */
   char              Text[1];       /* Text is allocated here */
};

struct LoadList {
   struct List       List;          /* List of loader nodes */
   int               MaxLength;     /* Bytes to read from file */
};


/*
 * The saver simply passes back an array of string pointers which
 * indicate the names of the various "flavors" of the particular
 * file format the saver handles.  The list is terminated by a
 * NULL String.
 *
 * For example, an ILBM saver might pass back the strings:
 *
 *       "ILBM (standard)"
 *       "ILBM (with XBMI)"
 */

struct SaveFormat {
   char             *Name;
   ULONG             Flags;
   int               ID;
};

/* flags for SaveFormat: */
#define SAV_TRUE     (0x0001)       /* Can save 8- or 24-bit true color */
#define SAV_MAPPED   (0x0002)       /* Can save a BitMap/ViewPort */
#define SAV_PALETTE  (0x0004)       /* Can save a 24-bit palette */
#define SAV_CMYK     (0x0008)       /* Can handle CMYK format images */
#define SAV_NOREQ    (0x0080)       /* Don't ask to overwrite... we'll do it */
#define SAV_NOMASK   (0x0100)       /* Format does not support a mask */
#define SAV_NOFILE   (0x0200)       /* This format does not require a filename (eg. clipboard) */
#define SAV_NOICON   (0x0400)       /* Do not save an icon with this file */
#define SAV_NOPIC    (0x0800)       /* Format does not require a render picture */
#define SAV_MULTI    (0x1000)       /* Format contains multiple images (ie. anim) */

struct SaveNode {
   struct MinNode    Node;          /* Exec standard node */
   struct Node       TrueNode;      /* Node for True list */
   struct Node       MappedNode;    /* Node for Mapped list */
   struct Node       PalNode;       /* Node for Palette list */
   struct Node       SepNode;       /* Node for Color Separation list */
   struct SaveFormat Format;        /* Save format name */
   char              Saver[128];    /* Name of saver module */
   int               Bytes;         /* Length of node in bytes */
   char              Text[1];       /* Text is allocated here */
};

/*
 * Palette() - A 24-bit color palette to save.
 */

struct Palette {
   short             Depth;         /* Bitplanes in palette */
   short             Count;         /* Count of palette entries, will
                                       usually be 2 ^ Depth */
   UBYTE            *Table;         /* Array of palette entries, arranged
                                       as 3 bytes each of Red, Green,
                                       Blue. */
   short             NumRanges;     /* Number of color ranges in palette */
   short             pad0;
   short            *LowRange;      /* Array of lower limit of ranges */
   short            *HighRange;     /* Array of upper limit of ranges */
   short            *RangeLocked;   /* Array of locked indicators */
};

/*
 * MappedImage - This is passed to the Saver module SM_SaveMapped()
 *               function to write out a mapped image.
 */

struct MappedImage {
   short             Width;         /* True image pixel width */
   short             Height;        /* True image pixel height */
   struct BitMap    *BitMap;        /* Image bitmap, up to 8 bitplanes */
   struct ViewPort  *ViewPort;      /* Obsolete - set to NULL */
   UBYTE            *Copper;        /* Palette for each scanline (UNUSED) */
   struct Palette    Palette;       /* True image palette, see above */
   ULONG             Modes;         /* ViewModes - use instead of ViewPort */
   UWORD             AspectX,       /* X & Y pixel aspect ratio */
                     AspectY;       /* (used to fill in BMHD) */
   ULONG             pad[7];        /* reserved */
};

/*
 * FileStats - structure a loader can fill in containing basic
 * information about a file.
 *
 * (UNUSED)
 *
 */
struct FileStats {
   ULONG    Flags;
   LONG     Width, Height, Depth;   /* depth in BITPLANES */
   WORD     AspectX, AspectY;
   WORD     DPIX, DPIY;
   LONG     reserved[4];
};

#define FS_UNKNOWN   (-1)

#define FSF_MULTI    0x0001      /* Multiple "frames" */


#define SCAN_LOADSAVE_H
#endif
