home *** CD-ROM | disk | FTP | other *** search
- /*
- * Skeleton Saver Module, on which to base other savers
- * Written by Thomas Krehbiel
- *
- * Things To Remember When Writing A Saver:
- *
- * Handle out of memory gracefully.
- * Handle disk write failures (eg. disk full)!
- * Remember Seek() can fail on a full disk, too.
- * Delete partial files when a failure occurs.
- * Provide a cancel gadget in the status bar.
- * Provide arexx options for all requesters.
- */
-
- #include <exec/types.h>
- #include <dos/dos.h>
- #include <libraries/iffparse.h>
- #include <devices/clipboard.h>
- #include <clib/dos_protos.h>
- #include <clib/exec_protos.h>
-
- #include <scan/modall.h>
- #include <scan/loadsave.h>
-
-
- // this include file is created by "str" in the makefile:
- #include "skeleton_strings.h"
-
-
- /**************************************************************************
- *
- * SM_SaveTrue()
- *
- * Write out a true color image buffer in the format that this module
- * saves in.
- *
- * The Buffer structure is defined in scan/buf.h.
- *
- **************************************************************************/
-
- BOOL __saveds __asm SM_SaveTrue (register __a0 char *fname,
- register __a1 struct Buffer *buf,
- register __d0 int id,
- register __a2 LONG *args)
- {
- if (args[0])
- // COMPRESS arg specified.
- if (args[1])
- // FRAME arg specified... frame = atoi((char *)args[1])
-
- InfoRequest(TXT(M_SM_SaveTrue));
- ReturnError(ERR_UserCancel, FALSE);
- }
-
- /*************************************************************************
- *
- * SM_SaveMapped()
- *
- * Save out a rendered image in the format that this saver saves in.
- *
- * The MappedImage structure is defined in scan/loadsave.h.
- *
- *************************************************************************/
-
- BOOL __saveds __asm SM_SaveMapped (register __a0 char *fname,
- register __a1 struct MappedImage *img,
- register __d0 int id,
- register __a2 LONG *args)
- {
- if (args[0])
- // COMPRESS arg specified.
- if (args[1])
- // FRAME arg specified... frame = atoi((char *)args[1])
-
- InfoRequest(TXT(M_SM_SaveMapped));
- ReturnError(ERR_UserCancel, FALSE);
- }
-
-
- /**************************************************************************
- *
- * SM_SavePalette()
- *
- * Save just a palette in the format that this module saves in. Currently
- * ImageFX never saves a palette in anything but ILBM, but one never
- * knows about the future.
- *
- * The Palette structure is defined in scan/loadsave.h.
- *
- **************************************************************************/
-
- BOOL __saveds __asm SM_SavePalette (register __a0 char *fname,
- register __a1 struct Palette *palette,
- register __d0 int id)
- {
- // unless your saver is called ILBM, this will never be called
- return(FALSE);
- }
-
-
- /*
- * This array is passed back to ImageFX to tell it what kinds of
- * file formats we can save. It also tells Image Scan whether or not
- * we can handle True Color Buffers, Rendered Images, or Palettes, or
- * any combination thereof. See the include file scan/loadsave.h for
- * details about the SaveFormat structure and its arguments.
- */
- static
- struct SaveFormat saveformats[] =
- {
- { "Skeleton", SAV_TRUE | SAV_MAPPED, 0 },
- { NULL }
- };
-
- /************************************************************************
- *
- * SM_Signatures()
- *
- * Tell ImageFX what kinds of formats we can save.
- *
- ************************************************************************/
-
- struct SaveFormat * __saveds SM_Signatures (void)
- {
- return(saveformats);
- }
-
-
- /**********************************************************************\
-
- Library Functions and Initialization Stuff
-
- \**********************************************************************/
-
-
- RXCMD RexxTable =
- {
- NULL, NULL, "Compress/S,Frame/N" // arexx args for this saver
- };
-
-
- /************************************************************************
- * Function table. Referenced in "lib.o".
- *
- * The first four entries are the standard library vectors, defined
- * in "lib.o", the remaining entries define functions specific to
- * this module.
- *
- * The table ends with -1.
- *
- */
- ULONG FuncTable[] = {
- /* These four MUST be present */
- (ULONG) LibOpen,
- (ULONG) LibClose,
- (ULONG) LibExpunge,
- (ULONG) LibNull,
-
- (ULONG) 0, // reserved
- (ULONG) SM_SaveTrue,
- (ULONG) SM_SaveMapped,
- (ULONG) SM_SavePalette,
- (ULONG) SM_Signatures,
-
- (ULONG) 0, // reserved
-
- /* End with -1L */
- (ULONG) -1L
- };
-
- /************************************************************************
- * ID string for this module. References in "lib.o".
- *
- * Should be given in the standard 2.0 version string style.
- */
- UBYTE LibraryID[] = "\0$VER: Skeleton 2.0.2 (15.2.95)";
-
- /************************************************************************
- * Type of module. Referenced in "lib.o".
- *
- * Should be one of the NT_* defines in <scan/mod.h>
- *
- */
- UBYTE LibraryType = NT_SAVER;
-
- /************************************************************************
- * Module initialization code. Referenced by "lib.o".
- *
- * This is where you would initialize the ModuleBase structure that
- * is passed to you.
- *
- * Returns TRUE if all went well, or FALSE if something went wrong and
- * the module open should fail.
- *
- */
- LONG __saveds __stdargs UserOpen (struct ModuleBase *modbase)
- {
- modbase->Language = "Saver_Skeleton";
- modbase->LangCount = TXT_COUNT;
- modbase->Text = Default_Strings;
- modbase->CmdTable = &RexxTable;
- return(TRUE);
- }
-
- /************************************************************************
- * Module cleanup code. Referenced by "lib.o".
- *
- * This should cleanup anything you allocated or opened in UserOpen()
- * above.
- *
- * Always return TRUE.
- *
- */
- LONG __saveds __stdargs UserClose (struct ModuleBase *modbase)
- {
- return(TRUE);
- }
-
-