home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / gfx / misc / imagefx_sdk / sas / examples / savers / skeleton.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-15  |  5.9 KB  |  219 lines

  1. /*
  2.  * Skeleton Saver Module, on which to base other savers
  3.  * Written by Thomas Krehbiel
  4.  *
  5.  * Things To Remember When Writing A Saver:
  6.  *
  7.  *    Handle out of memory gracefully.
  8.  *    Handle disk write failures (eg. disk full)!
  9.  *    Remember Seek() can fail on a full disk, too.
  10.  *    Delete partial files when a failure occurs.
  11.  *    Provide a cancel gadget in the status bar.
  12.  *    Provide arexx options for all requesters.
  13.  */
  14.  
  15. #include <exec/types.h>
  16. #include <dos/dos.h>
  17. #include <libraries/iffparse.h>
  18. #include <devices/clipboard.h>
  19. #include <clib/dos_protos.h>
  20. #include <clib/exec_protos.h>
  21.  
  22. #include <scan/modall.h>
  23. #include <scan/loadsave.h>
  24.  
  25.  
  26. // this include file is created by "str" in the makefile:
  27. #include "skeleton_strings.h"
  28.  
  29.  
  30. /**************************************************************************
  31.  *
  32.  * SM_SaveTrue()
  33.  *
  34.  * Write out a true color image buffer in the format that this module
  35.  * saves in.
  36.  *
  37.  * The Buffer structure is defined in scan/buf.h.
  38.  *
  39.  **************************************************************************/
  40.  
  41. BOOL __saveds __asm SM_SaveTrue (register __a0 char *fname,
  42.                                  register __a1 struct Buffer *buf,
  43.                                  register __d0 int id,
  44.                                  register __a2 LONG *args)
  45. {
  46.    if (args[0])
  47.       // COMPRESS arg specified.
  48.    if (args[1])
  49.       // FRAME arg specified... frame = atoi((char *)args[1])
  50.  
  51.    InfoRequest(TXT(M_SM_SaveTrue));
  52.    ReturnError(ERR_UserCancel, FALSE);
  53. }
  54.  
  55. /*************************************************************************
  56.  *
  57.  * SM_SaveMapped()
  58.  *
  59.  * Save out a rendered image in the format that this saver saves in.
  60.  *
  61.  * The MappedImage structure is defined in scan/loadsave.h.
  62.  *
  63.  *************************************************************************/
  64.  
  65. BOOL __saveds __asm SM_SaveMapped (register __a0 char *fname,
  66.                                    register __a1 struct MappedImage *img,
  67.                                    register __d0 int id,
  68.                                    register __a2 LONG *args)
  69. {
  70.    if (args[0])
  71.       // COMPRESS arg specified.
  72.    if (args[1])
  73.       // FRAME arg specified... frame = atoi((char *)args[1])
  74.  
  75.    InfoRequest(TXT(M_SM_SaveMapped));
  76.    ReturnError(ERR_UserCancel, FALSE);
  77. }
  78.  
  79.  
  80. /**************************************************************************
  81.  *
  82.  * SM_SavePalette()
  83.  *
  84.  * Save just a palette in the format that this module saves in.  Currently
  85.  * ImageFX never saves a palette in anything but ILBM, but one never
  86.  * knows about the future.
  87.  *
  88.  * The Palette structure is defined in scan/loadsave.h.
  89.  *
  90.  **************************************************************************/
  91.  
  92. BOOL __saveds __asm SM_SavePalette (register __a0 char *fname,
  93.                                     register __a1 struct Palette *palette,
  94.                                     register __d0 int id)
  95. {
  96.    // unless your saver is called ILBM, this will never be called
  97.    return(FALSE);
  98. }
  99.  
  100.  
  101. /*
  102.  * This array is passed back to ImageFX to tell it what kinds of
  103.  * file formats we can save.  It also tells Image Scan whether or not
  104.  * we can handle True Color Buffers, Rendered Images, or Palettes, or
  105.  * any combination thereof.  See the include file scan/loadsave.h for
  106.  * details about the SaveFormat structure and its arguments.
  107.  */
  108. static
  109. struct SaveFormat saveformats[] =
  110. {
  111.    { "Skeleton", SAV_TRUE | SAV_MAPPED,   0 },
  112.    { NULL }
  113. };
  114.  
  115. /************************************************************************
  116.  *
  117.  * SM_Signatures()
  118.  *
  119.  * Tell ImageFX what kinds of formats we can save.
  120.  *
  121.  ************************************************************************/
  122.  
  123. struct SaveFormat * __saveds SM_Signatures (void)
  124. {
  125.    return(saveformats);
  126. }
  127.  
  128.  
  129. /**********************************************************************\
  130.  
  131.                Library Functions and Initialization Stuff
  132.  
  133. \**********************************************************************/
  134.  
  135.  
  136. RXCMD RexxTable =
  137. {
  138.    NULL, NULL, "Compress/S,Frame/N"       // arexx args for this saver
  139. };
  140.  
  141.  
  142. /************************************************************************
  143.  * Function table.  Referenced in "lib.o".
  144.  *
  145.  * The first four entries are the standard library vectors, defined
  146.  * in "lib.o", the remaining entries define functions specific to
  147.  * this module.
  148.  *
  149.  * The table ends with -1.
  150.  *
  151.  */
  152. ULONG FuncTable[] = {
  153.    /* These four MUST be present */
  154.    (ULONG) LibOpen,
  155.    (ULONG) LibClose,
  156.    (ULONG) LibExpunge,
  157.    (ULONG) LibNull,
  158.  
  159.    (ULONG) 0,              // reserved
  160.    (ULONG) SM_SaveTrue,
  161.    (ULONG) SM_SaveMapped,
  162.    (ULONG) SM_SavePalette,
  163.    (ULONG) SM_Signatures,
  164.  
  165.    (ULONG) 0,              // reserved
  166.  
  167.    /* End with -1L */
  168.    (ULONG) -1L
  169. };
  170.  
  171. /************************************************************************
  172.  * ID string for this module.  References in "lib.o".
  173.  *
  174.  * Should be given in the standard 2.0 version string style.
  175.  */
  176. UBYTE LibraryID[]    = "\0$VER: Skeleton 2.0.2 (15.2.95)";
  177.  
  178. /************************************************************************
  179.  * Type of module.  Referenced in "lib.o".
  180.  *
  181.  * Should be one of the NT_* defines in <scan/mod.h>
  182.  *
  183.  */
  184. UBYTE LibraryType    = NT_SAVER;
  185.  
  186. /************************************************************************
  187.  * Module initialization code.  Referenced by "lib.o".
  188.  *
  189.  * This is where you would initialize the ModuleBase structure that
  190.  * is passed to you.
  191.  *
  192.  * Returns TRUE if all went well, or FALSE if something went wrong and
  193.  * the module open should fail.
  194.  *
  195.  */
  196. LONG __saveds __stdargs UserOpen (struct ModuleBase *modbase)
  197. {
  198.    modbase->Language = "Saver_Skeleton";
  199.    modbase->LangCount = TXT_COUNT;
  200.    modbase->Text = Default_Strings;
  201.    modbase->CmdTable = &RexxTable;
  202.    return(TRUE);
  203. }
  204.  
  205. /************************************************************************
  206.  * Module cleanup code.  Referenced by "lib.o".
  207.  *
  208.  * This should cleanup anything you allocated or opened in UserOpen()
  209.  * above.
  210.  *
  211.  * Always return TRUE.
  212.  *
  213.  */
  214. LONG __saveds __stdargs UserClose (struct ModuleBase *modbase)
  215. {
  216.    return(TRUE);
  217. }
  218.  
  219.