home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / ImageMagick-4.0.6.tar.gz / ImageMagick-4.0.6.tar / ImageMagick-4.0.6 / animate.c < prev    next >
C/C++ Source or Header  |  1998-04-22  |  35KB  |  959 lines

  1. /*
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. %                                                                             %
  4. %                                                                             %
  5. %                                                                             %
  6. %              AAA   N   N  IIIII  M   M   AAA   TTTTT  EEEEE                 %
  7. %             A   A  NN  N    I    MM MM  A   A    T    E                     %
  8. %             AAAAA  N N N    I    M M M  AAAAA    T    EEE                   %
  9. %             A   A  N  NN    I    M   M  A   A    T    E                     %
  10. %             A   A  N   N  IIIII  M   M  A   A    T    EEEEE                 %
  11. %                                                                             %
  12. %                                                                             %
  13. %                 Interactively Animate an Image Sequence.                    %
  14. %                                                                             %
  15. %                                                                             %
  16. %                           Software Design                                   %
  17. %                             John Cristy                                     %
  18. %                              July 1992                                      %
  19. %                                                                             %
  20. %                                                                             %
  21. %  Copyright 1998 E. I. du Pont de Nemours and Company                        %
  22. %                                                                             %
  23. %  Permission is hereby granted, free of charge, to any person obtaining a    %
  24. %  copy of this software and associated documentation files ("ImageMagick"),  %
  25. %  to deal in ImageMagick without restriction, including without limitation   %
  26. %  the rights to use, copy, modify, merge, publish, distribute, sublicense,   %
  27. %  and/or sell copies of ImageMagick, and to permit persons to whom the       %
  28. %  ImageMagick is furnished to do so, subject to the following conditions:    %
  29. %                                                                             %
  30. %  The above copyright notice and this permission notice shall be included in %
  31. %  all copies or substantial portions of ImageMagick.                         %
  32. %                                                                             %
  33. %  The software is provided "as is", without warranty of any kind, express or %
  34. %  implied, including but not limited to the warranties of merchantability,   %
  35. %  fitness for a particular purpose and noninfringement.  In no event shall   %
  36. %  E. I. du Pont de Nemours and Company be liable for any claim, damages or   %
  37. %  other liability, whether in an action of contract, tort or otherwise,      %
  38. %  arising from, out of or in connection with ImageMagick or the use or other %
  39. %  dealings in ImageMagick.                                                   %
  40. %                                                                             %
  41. %  Except as contained in this notice, the name of the E. I. du Pont de       %
  42. %  Nemours and Company shall not be used in advertising or otherwise to       %
  43. %  promote the sale, use or other dealings in ImageMagick without prior       %
  44. %  written authorization from the E. I. du Pont de Nemours and Company.       %
  45. %                                                                             %
  46. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  47. %
  48. %  Animate displays a sequence of images in the MIFF format on any
  49. %  workstation display running an X server.  Animate first determines the
  50. %  hardware capabilities of the workstation.  If the number of unique
  51. %  colors in an image is less than or equal to the number the workstation
  52. %  can support, the image is displayed in an X window.  Otherwise the
  53. %  number of colors in the image is first reduced to match the color
  54. %  resolution of the workstation before it is displayed.
  55. %
  56. %  This means that a continuous-tone 24 bits-per-pixel image can display on a
  57. %  8 bit pseudo-color device or monochrome device.  In most instances the
  58. %  reduced color image closely resembles the original.  Alternatively, a
  59. %  monochrome or pseudo-color image can display on a continuous-tone 24
  60. %  bits-per-pixel device.
  61. %
  62. %  The Animate program command syntax is:
  63. %
  64. %  Usage: animate [options ...] file [ [options ...] file ...]
  65. %
  66. %  Where options include:
  67. %    -backdrop            display image centered on a backdrop
  68. %    -colormap type       Shared or Private
  69. %    -colors value        preferred number of colors in the image
  70. %    -colorspace type     alternate image colorspace
  71. %    -crop geometry       preferred size and location of the cropped image
  72. %    -delay value         display the next image after pausing
  73. %    -density geometry    vertical and horizontal density of the image
  74. %    -display server      display image to this X server
  75. %    -dither              apply Floyd/Steinberg error diffusion to image
  76. %    -gamma value         level of gamma correction
  77. %    -geometry geometry   preferred size and location of the Image window
  78. %    -interlace type      None, Line, Plane, or Partition
  79. %    -map type            display image using this Standard Colormap
  80. %    -matte               store matte channel if the image has one
  81. %    -monochrome          transform image to black and white
  82. %    -remote command      execute a command in an remote display process
  83. %    -rotate degrees      apply Paeth rotation to the image
  84. %    -scene value         image scene number
  85. %    -size geometry       width and height of image
  86. %    -treedepth value     depth of the color classification tree
  87. %    -verbose             print detailed information about the image
  88. %    -visual type         display image using this visual type
  89. %    -window id           display image to background of this window
  90. %
  91. %  In addition to those listed above, you can specify these standard X
  92. %  resources as command line options:  -background, -bordercolor,
  93. %  -borderwidth, -font, -foreground, -iconGeometry, -iconic, -name,
  94. %  -mattecolor, -shared_memory, or -title.
  95. %
  96. %  By default, the image format of `file' is determined by its magic
  97. %  number.  To specify a particular image format, precede the filename
  98. %  with an image format name and a colon (i.e. ps:image) or specify the
  99. %  image type as the filename suffix (i.e. image.ps).  Specify 'file' as
  100. %  '-' for standard input or output.
  101. %
  102. %  Buttons:
  103. %    Press any button to map or unmap the Command widget.
  104. %
  105. %
  106. */
  107.  
  108. /*
  109.   Include declarations.
  110. */
  111. #include "magick.h"
  112. #include "version.h"
  113.  
  114. /*
  115. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  116. %                                                                             %
  117. %                                                                             %
  118. %                                                                             %
  119. %   U s a g e                                                                 %
  120. %                                                                             %
  121. %                                                                             %
  122. %                                                                             %
  123. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  124. %
  125. %  Function Usage displays the program command syntax.
  126. %
  127. %  The format of the Usage routine is:
  128. %
  129. %      Usage(client_name)
  130. %
  131. %  A description of each parameter follows:
  132. %
  133. %    o client_name: a character string representing the name of the client
  134. %      program.
  135. %
  136. %
  137. */
  138. static void Usage(const char *client_name)
  139. {
  140.   char
  141.     **p;
  142.  
  143.   static char
  144.     *buttons[]=
  145.     {
  146.       "Press any button to map or unmap the Command widget",
  147.       (char *) NULL
  148.     },
  149.     *options[]=
  150.     {
  151.       "-backdrop            display image centered on a backdrop",
  152.       "-colormap type       Shared or Private",
  153.       "-colors value        preferred number of colors in the image",
  154.       "-colorspace type     alternate image colorspace",
  155.       "-crop geometry       preferred size and location of the cropped image",
  156.       "-delay value         display the next image after pausing",
  157.       "-density geometry    vertical and horizontal density of the image",
  158.       "-display server      display image to this X server",
  159.       "-dither              apply Floyd/Steinberg error diffusion to image",
  160.       "-gamma value         level of gamma correction",
  161.       "-geometry geometry   preferred size and location of the Image window",
  162.       "-interlace type      None, Line, Plane, or Partition",
  163.       "-matte               store matte channel if the image has one",
  164.       "-map type            display image using this Standard Colormap",
  165.       "-monochrome          transform image to black and white",
  166.       "-remote command      execute a command in an remote display process",
  167.       "-rotate degrees      apply Paeth rotation to the image",
  168.       "-scene value         image scene number",
  169.       "-size geometry       width and height of image",
  170.       "-treedepth value     depth of the color classification tree",
  171.       "-verbose             print detailed information about the image",
  172.       "-visual type         display image using this visual type",
  173.       "-window id          display image to background of this window",
  174.       (char *) NULL
  175.     };
  176.  
  177.   (void) printf("Version: %s\n",Version);
  178.   (void) printf("Copyright: %s\n\n",Copyright);
  179.   (void) printf(
  180.     "Usage: %s [-options ...] file [ [-options ...] file ...]\n",client_name);
  181.   (void) printf("\nWhere options include: \n");
  182.   for (p=options; *p != (char *) NULL; p++)
  183.     (void) printf("  %s\n",*p);
  184.   (void) printf(
  185.     "\nIn addition to those listed above, you can specify these standard X\n");
  186.   (void) printf(
  187.     "resources as command line options:  -background, -bordercolor,\n");
  188.   (void) printf(
  189.     "-borderwidth, -font, -foreground, -iconGeometry, -iconic, -name,\n");
  190.   (void) printf("-mattecolor, -shared_memory, or -title.\n");
  191.   (void) printf(
  192.     "\nBy default, the image format of `file' is determined by its magic\n");
  193.   (void) printf(
  194.     "number.  To specify a particular image format, precede the filename\n");
  195.   (void) printf(
  196.     "with an image format name and a colon (i.e. ps:image) or specify the\n");
  197.   (void) printf(
  198.     "image type as the filename suffix (i.e. image.ps).  Specify 'file' as\n");
  199.   (void) printf("'-' for standard input or output.\n");
  200.   (void) printf("\nButtons: \n");
  201.   for (p=buttons; *p != (char *) NULL; p++)
  202.     (void) printf("  %s\n",*p);
  203.   Exit(0);
  204. }
  205.  
  206. /*
  207. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  208. %                                                                             %
  209. %                                                                             %
  210. %                                                                             %
  211. %    M a i n                                                                  %
  212. %                                                                             %
  213. %                                                                             %
  214. %                                                                             %
  215. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  216. %
  217. %
  218. */
  219.  
  220. #if defined(WIN32)
  221. int WINAPI WinMain(HINSTANCE instance,HINSTANCE last,LPSTR command,int state)
  222. {
  223.   char
  224.     **argv;
  225.   
  226.   int
  227.     argc,
  228.     main(int,char **);
  229.   
  230.   argv=StringToArgv(command,&argc);
  231.   return(main(argc,argv));
  232. }
  233. #endif
  234.  
  235. int main(int argc,char **argv)
  236. {
  237.   char
  238.     *client_name,
  239.     *option,
  240.     *resource_value,
  241.     *server_name;
  242.  
  243.   Display
  244.     *display;
  245.  
  246.   Image
  247.     *image,
  248.     *loaded_image,
  249.     *next_image,
  250.     *p;
  251.  
  252.   ImageInfo
  253.     *image_info;
  254.  
  255.   int
  256.     i,
  257.     x;
  258.  
  259.   QuantizeInfo
  260.     *quantize_info;
  261.  
  262.   unsigned int
  263.     first_scene,
  264.     last_scene,
  265.     scene;
  266.  
  267.   XResourceInfo
  268.     resource_info;
  269.  
  270.   XrmDatabase
  271.     resource_database;
  272.  
  273.   /*
  274.     Set defaults.
  275.   */
  276. #if defined(WIN32)
  277.   SetErrorHandler(NTErrorHandler);
  278.   SetWarningHandler(NTWarningHandler);
  279. #endif
  280.   ReadCommandlLine(argc,&argv);
  281.   client_name=SetClientName(*argv);
  282.   display=(Display *) NULL;
  283.   first_scene=0;
  284.   image=(Image *) NULL;
  285.   last_scene=0;
  286.   /*
  287.     Check for server name specified on the command line.
  288.   */
  289.   ExpandFilenames(&argc,&argv);
  290.   server_name=(char *) NULL;
  291.   for (i=1; i < argc; i++)
  292.   {
  293.     /*
  294.       Check command line for server name.
  295.     */
  296.     option=argv[i];
  297.     if ((Extent(option) == 1) || ((*option != '-') && (*option != '+')))
  298.       continue;
  299.     if (strcmp("display",option+1) == 0)
  300.       {
  301.         /*
  302.           User specified server name.
  303.         */
  304.         i++;
  305.         if (i == argc)
  306.           MagickError(OptionError,"Missing server name",option);
  307.         server_name=argv[i];
  308.         break;
  309.       }
  310.     if (strncmp("help",option+1,2) == 0)
  311.       Usage(client_name);
  312.   }
  313.   /*
  314.     Get user defaults from X resource database.
  315.   */
  316.   display=XOpenDisplay(server_name);
  317.   if (display == (Display *) NULL)
  318.     MagickError(XServerError,"Unable to connect to X server",
  319.       XDisplayName(server_name));
  320.   XSetErrorHandler(XError);
  321.   resource_database=XGetResourceDatabase(display,client_name);
  322.   XGetResourceInfo(resource_database,client_name,&resource_info);
  323.   resource_info.delay=0;
  324.   resource_info.pause=0;
  325.   resource_value=
  326.     XGetResourceInstance(resource_database,client_name,"delay","6");
  327.   (void) XParseGeometry(resource_value,&x,&x,&resource_info.delay,
  328.     &resource_info.pause);
  329.   image_info=(&resource_info.image_info);
  330.   image_info->density=
  331.     XGetResourceInstance(resource_database,client_name,"density",(char *) NULL);
  332.   if (image_info->density == (char *) NULL)
  333.     image_info->density=XGetScreenDensity(display);
  334.   resource_value=
  335.     XGetResourceInstance(resource_database,client_name,"interlace","none");
  336.   image_info->interlace=UndefinedInterlace;
  337.   if (Latin1Compare("None",resource_value) == 0)
  338.     image_info->interlace=NoInterlace;
  339.   if (Latin1Compare("Line",resource_value) == 0)
  340.     image_info->interlace=LineInterlace;
  341.   if (Latin1Compare("Plane",resource_value) == 0)
  342.     image_info->interlace=PlaneInterlace;
  343.   if (Latin1Compare("Partition",resource_value) == 0)
  344.     image_info->interlace=PartitionInterlace;
  345.   if (image_info->interlace == UndefinedInterlace)
  346.     MagickWarning(OptionWarning,"Unrecognized interlace type",resource_value);
  347.   resource_value=
  348.     XGetResourceInstance(resource_database,client_name,"verbose","False");
  349.   image_info->verbose=IsTrue(resource_value);
  350.   quantize_info=(&resource_info.quantize_info);
  351.   /*
  352.     Parse command line.
  353.   */
  354.   for (i=1; i <= argc; i++)
  355.   {
  356.     if (i < argc)
  357.       option=argv[i];
  358.     else
  359.       if (image != (Image *) NULL)
  360.         break;
  361.       else
  362.         if (!isatty(STDIN_FILENO))
  363.           option="-";
  364.         else
  365.           option="logo:Untitled";
  366.     if ((Extent(option) > 1) && ((*option == '-') || (*option == '+')))
  367.       switch (*(option+1))
  368.       {
  369.         case 'b':
  370.         {
  371.           if (strncmp("backdrop",option+1,5) == 0)
  372.             {
  373.               resource_info.backdrop=(*option == '-');
  374.               break;
  375.             }
  376.           if (strncmp("background",option+1,5) == 0)
  377.             {
  378.               resource_info.background_color=(char *) NULL;
  379.               if (*option == '-')
  380.                 {
  381.                   i++;
  382.                   if (i == argc)
  383.                     MagickError(OptionError,"Missing color",option);
  384.                   resource_info.background_color=argv[i];
  385.                 }
  386.               break;
  387.             }
  388.           if (strncmp("bordercolor",option+1,7) == 0)
  389.             {
  390.               resource_info.border_color=(char *) NULL;
  391.               if (*option == '-')
  392.                 {
  393.                   i++;
  394.                   if (i == argc)
  395.                     MagickError(OptionError,"Missing color",option);
  396.                   resource_info.border_color=argv[i];
  397.                 }
  398.               break;
  399.             }
  400.           if (strncmp("borderwidth",option+1,7) == 0)
  401.             {
  402.               resource_info.border_width=0;
  403.               if (*option == '-')
  404.                 {
  405.                   i++;
  406.                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
  407.                     MagickError(OptionError,"Missing width",option);
  408.                   resource_info.border_width=atoi(argv[i]);
  409.                 }
  410.               break;
  411.             }
  412.           MagickError(OptionError,"Unrecognized option",option);
  413.           break;
  414.         }
  415.         case 'c':
  416.         {
  417.           if (strncmp("colormap",option+1,6) == 0)
  418.             {
  419.               resource_info.colormap=PrivateColormap;
  420.               if (*option == '-')
  421.                 {
  422.                   i++;
  423.                   if (i == argc)
  424.                     MagickError(OptionError,"Missing type",option);
  425.                   option=argv[i];
  426.                   resource_info.colormap=UndefinedColormap;
  427.                   if (Latin1Compare("private",option) == 0)
  428.                     resource_info.colormap=PrivateColormap;
  429.                   if (Latin1Compare("shared",option) == 0)
  430.                     resource_info.colormap=SharedColormap;
  431.                   if (resource_info.colormap == UndefinedColormap)
  432.                     MagickError(OptionError,"Invalid colormap type",option);
  433.                 }
  434.               break;
  435.             }
  436.           if (strncmp("colors",option+1,7) == 0)
  437.             {
  438.               quantize_info->number_colors=0;
  439.               if (*option == '-')
  440.                 {
  441.                   i++;
  442.                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
  443.                     MagickError(OptionError,"Missing colors",option);
  444.                   quantize_info->number_colors=atoi(argv[i]);
  445.                 }
  446.               break;
  447.             }
  448.           if (strncmp("colorspace",option+1,7) == 0)
  449.             {
  450.               quantize_info->colorspace=RGBColorspace;
  451.               if (*option == '-')
  452.                 {
  453.                   i++;
  454.                   if (i == argc)
  455.                     MagickError(OptionError,"Missing type",option);
  456.                   option=argv[i];
  457.                   quantize_info->colorspace=UndefinedColorspace;
  458.                   if (Latin1Compare("cmyk",option) == 0)
  459.                     quantize_info->colorspace=CMYKColorspace;
  460.                   if (Latin1Compare("gray",option) == 0)
  461.                     {
  462.                       quantize_info->colorspace=GRAYColorspace;
  463.                       quantize_info->number_colors=256;
  464.                       quantize_info->tree_depth=8;
  465.                     }
  466.                   if (Latin1Compare("ohta",option) == 0)
  467.                     quantize_info->colorspace=OHTAColorspace;
  468.                   if (Latin1Compare("rgb",option) == 0)
  469.                     quantize_info->colorspace=RGBColorspace;
  470.                   if (Latin1Compare("transparent",option) == 0)
  471.                     quantize_info->colorspace=TransparentColorspace;
  472.                   if (Latin1Compare("xyz",option) == 0)
  473.                     quantize_info->colorspace=XYZColorspace;
  474.                   if (Latin1Compare("ycbcr",option) == 0)
  475.                     quantize_info->colorspace=YCbCrColorspace;
  476.                   if (Latin1Compare("yiq",option) == 0)
  477.                     quantize_info->colorspace=YIQColorspace;
  478.                   if (Latin1Compare("ypbpr",option) == 0)
  479.                     quantize_info->colorspace=YPbPrColorspace;
  480.                   if (Latin1Compare("yuv",option) == 0)
  481.                     quantize_info->colorspace=YUVColorspace;
  482.                   if (quantize_info->colorspace == UndefinedColorspace)
  483.                     MagickError(OptionError,"Invalid colorspace type",option);
  484.                 }
  485.               break;
  486.             }
  487.           if (strncmp("crop",option+1,2) == 0)
  488.             {
  489.               if (*option == '-')
  490.                 {
  491.                   i++;
  492.                   if ((i == argc) || !IsGeometry(argv[i]))
  493.                     MagickError(OptionError,"Missing geometry",option);
  494.                 }
  495.               break;
  496.             }
  497.           MagickError(OptionError,"Unrecognized option",option);
  498.           break;
  499.         }
  500.         case 'd':
  501.         {
  502.           if (strncmp("debug",option+1,3) == 0)
  503.             {
  504.               resource_info.debug=(*option == '-');
  505.               break;
  506.             }
  507.           if (strncmp("delay",option+1,3) == 0)
  508.             {
  509.               resource_info.delay=0;
  510.               resource_info.pause=0;
  511.               if (*option == '-')
  512.                 {
  513.                   i++;
  514.                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
  515.                     MagickError(OptionError,"Missing seconds",option);
  516.                   (void) XParseGeometry(argv[i],&x,&x,&resource_info.delay,
  517.                     &resource_info.pause);
  518.                 }
  519.               break;
  520.             }
  521.           if (strncmp("density",option+1,3) == 0)
  522.             {
  523.               image_info->density=(char *) NULL;
  524.               if (*option == '-')
  525.                 {
  526.                   i++;
  527.                   if ((i == argc) || !IsGeometry(argv[i]))
  528.                     MagickError(OptionError,"Missing geometry",option);
  529.                   image_info->density=argv[i];
  530.                 }
  531.               break;
  532.             }
  533.           if (strcmp("display",option+1) == 0)
  534.             {
  535.               image_info->server_name=(char *) NULL;
  536.               if (*option == '-')
  537.                 {
  538.                   i++;
  539.                   if (i == argc)
  540.                     MagickError(OptionError,"Missing server name",option);
  541.                   image_info->server_name=argv[i];
  542.                 }
  543.               break;
  544.             }
  545.           if (strncmp("dither",option+1,3) == 0)
  546.             {
  547.               quantize_info->dither=(*option == '-');
  548.               break;
  549.             }
  550.           MagickError(OptionError,"Unrecognized option",option);
  551.           break;
  552.         }
  553.         case 'f':
  554.         {
  555.           if (strncmp("font",option+1,3) == 0)
  556.             {
  557.               image_info->font=(char *) NULL;
  558.               if (*option == '-')
  559.                 {
  560.                   i++;
  561.                   if (i == argc)
  562.                     MagickError(OptionError,"Missing font name",option);
  563.                   image_info->font=argv[i];
  564.                 }
  565.               resource_info.font=image_info->font;
  566.               break;
  567.             }
  568.           if (strncmp("foreground",option+1,3) == 0)
  569.             {
  570.               resource_info.foreground_color=(char *) NULL;
  571.               if (*option == '-')
  572.                 {
  573.                   i++;
  574.                   if (i == argc)
  575.                     MagickError(OptionError,"Missing foreground",option);
  576.                   resource_info.foreground_color=argv[i];
  577.                 }
  578.               break;
  579.             }
  580.           MagickError(OptionError,"Unrecognized option",option);
  581.           break;
  582.         }
  583.         case 'g':
  584.         {
  585.           if (strncmp("gamma",option+1,2) == 0)
  586.             {
  587.               i++;
  588.               if ((i == argc) || !sscanf(argv[i],"%f",(float *) &x))
  589.                 MagickError(OptionError,"Missing value",option);
  590.               break;
  591.             }
  592.           if (strncmp("geometry",option+1,2) == 0)
  593.             {
  594.               resource_info.image_geometry=(char *) NULL;
  595.               if (*option == '-')
  596.                 {
  597.                   i++;
  598.                   if ((i == argc) || !IsGeometry(argv[i]))
  599.                     MagickError(OptionError,"Missing geometry",option);
  600.                   resource_info.image_geometry=argv[i];
  601.                 }
  602.               break;
  603.             }
  604.           MagickError(OptionError,"Unrecognized option",option);
  605.           break;
  606.         }
  607.         case 'h':
  608.         {
  609.           if (strncmp("help",option+1,2) == 0)
  610.             {
  611.               Usage(client_name);
  612.               break;
  613.             }
  614.           MagickError(OptionError,"Unrecognized option",option);
  615.           break;
  616.         }
  617.         case 'i':
  618.         {
  619.           if (strncmp("iconGeometry",option+1,5) == 0)
  620.             {
  621.               resource_info.icon_geometry=(char *) NULL;
  622.               if (*option == '-')
  623.                 {
  624.                   i++;
  625.                   if ((i == argc) || !IsGeometry(argv[i]))
  626.                     MagickError(OptionError,"Missing geometry",option);
  627.                   resource_info.icon_geometry=argv[i];
  628.                 }
  629.               break;
  630.             }
  631.           if (strncmp("iconic",option+1,5) == 0)
  632.             {
  633.               resource_info.iconic=(*option == '-');
  634.               break;
  635.             }
  636.           if (strncmp("interlace",option+1,3) == 0)
  637.             {
  638.               if (*option == '-')
  639.                 {
  640.                   i++;
  641.                   if (i == argc)
  642.                     MagickError(OptionError,"Missing type",option);
  643.                   option=argv[i];
  644.                   image_info->interlace=UndefinedInterlace;
  645.                   if (Latin1Compare("None",option) == 0)
  646.                     image_info->interlace=NoInterlace;
  647.                   if (Latin1Compare("Line",option) == 0)
  648.                     image_info->interlace=LineInterlace;
  649.                   if (Latin1Compare("Plane",option) == 0)
  650.                     image_info->interlace=PlaneInterlace;
  651.                   if (Latin1Compare("Partition",option) == 0)
  652.                     image_info->interlace=PartitionInterlace;
  653.                   if (image_info->interlace == UndefinedInterlace)
  654.                     MagickError(OptionError,"Invalid interlace type",option);
  655.                 }
  656.               break;
  657.             }
  658.           MagickError(OptionError,"Unrecognized option",option);
  659.           break;
  660.         }
  661.         case 'm':
  662.         {
  663.           if (strncmp("map",option+1,3) == 0)
  664.             {
  665.               argv[i]="+sans";
  666.               resource_info.map_type=(char *) NULL;
  667.               if (*option == '-')
  668.                 {
  669.                   argv[i]="-sans";
  670.                   i++;
  671.                   if (i == argc)
  672.                     MagickError(OptionError,"Missing map type",option);
  673.                   resource_info.map_type=argv[i];
  674.                 }
  675.               break;
  676.             }
  677.           if (strcmp("matte",option+1) == 0)
  678.             break;
  679.           if (strncmp("mattecolor",option+1,6) == 0)
  680.             {
  681.               resource_info.matte_color=(char *) NULL;
  682.               if (*option == '-')
  683.                 {
  684.                   i++;
  685.                   if (i == argc)
  686.                     MagickError(OptionError,"Missing color",option);
  687.                   resource_info.matte_color=argv[i];
  688.                 }
  689.               break;
  690.             }
  691.           if (strncmp("monochrome",option+1,2) == 0)
  692.             {
  693.               image_info->monochrome=(*option == '-');
  694.               if (image_info->monochrome)
  695.                 {
  696.                   quantize_info->number_colors=2;
  697.                   quantize_info->tree_depth=8;
  698.                   quantize_info->colorspace=GRAYColorspace;
  699.                 }
  700.               break;
  701.             }
  702.           MagickError(OptionError,"Unrecognized option",option);
  703.           break;
  704.         }
  705.         case 'n':
  706.         {
  707.           resource_info.name=(char *) NULL;
  708.           if (*option == '-')
  709.             {
  710.               i++;
  711.               if (i == argc)
  712.                 MagickError(OptionError,"Missing name",option);
  713.               resource_info.name=argv[i];
  714.             }
  715.           break;
  716.         }
  717.         case 'r':
  718.         {
  719.           if (strncmp("remote",option+1,3) == 0)
  720.             {
  721.               Atom
  722.                 remote_atom;
  723.  
  724.               Window
  725.                 remote_window,
  726.                 root_window;
  727.  
  728.               root_window=XRootWindow(display,XDefaultScreen(display));
  729.               remote_atom=XInternAtom(display,"IM_PROTOCOLS",False);
  730.               remote_window=XWindowByProperty(display,root_window,remote_atom);
  731.               if (remote_window == (Window) NULL)
  732.                 break;
  733.               i++;
  734.               if (i == argc)
  735.                 MagickError(OptionError,"Missing command",option);
  736.               /*
  737.                 Send remote command.
  738.               */
  739.               remote_atom=XInternAtom(display,"IM_REMOTE_COMMAND",False);
  740.               XChangeProperty(display,remote_window,remote_atom,XA_STRING,8,
  741.                 PropModeReplace,(unsigned char *) argv[i],Extent(argv[i]));
  742.               XSync(display,False);
  743.               Exit(0);
  744.             }
  745.           if (strncmp("rotate",option+1,3) == 0)
  746.             {
  747.               if (*option == '-')
  748.                 {
  749.                   i++;
  750.                   if ((i == argc) || !IsGeometry(argv[i]))
  751.                     MagickError(OptionError,"Missing degrees",option);
  752.                 }
  753.               break;
  754.             }
  755.           MagickError(OptionError,"Unrecognized option",option);
  756.           break;
  757.         }
  758.         case 's':
  759.         {
  760.           if (strncmp("scene",option+1,3) == 0)
  761.             {
  762.               first_scene=0;
  763.               last_scene=0;
  764.               if (*option == '-')
  765.                 {
  766.                   i++;
  767.                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
  768.                     MagickError(OptionError,"Missing scene number",option);
  769.                   first_scene=atoi(argv[i]);
  770.                   last_scene=first_scene;
  771.                   (void) sscanf(argv[i],"%u-%u",&first_scene,&last_scene);
  772.                 }
  773.               break;
  774.             }
  775.           if (strncmp("shared_memory",option+1,4) == 0)
  776.             {
  777.               resource_info.use_shared_memory=(*option == '-');
  778.               break;
  779.             }
  780.           if (strncmp("size",option+1,2) == 0)
  781.             {
  782.               image_info->size=(char *) NULL;
  783.               if (*option == '-')
  784.                 {
  785.                   i++;
  786.                   if ((i == argc) || !IsGeometry(argv[i]))
  787.                     MagickError(OptionError,"Missing geometry",option);
  788.                   image_info->size=argv[i];
  789.                 }
  790.               break;
  791.             }
  792.           MagickError(OptionError,"Unrecognized option",option);
  793.           break;
  794.         }
  795.         case 't':
  796.         {
  797.           if (strncmp("text_font",option+1,3) == 0)
  798.             {
  799.               resource_info.text_font=(char *) NULL;
  800.               if (*option == '-')
  801.                 {
  802.                   i++;
  803.                   if (i == argc)
  804.                     MagickError(OptionError,"Missing font name",option);
  805.                   resource_info.text_font=argv[i];
  806.                 }
  807.               break;
  808.             }
  809.           if (strncmp("title",option+1,2) == 0)
  810.             {
  811.               resource_info.title=(char *) NULL;
  812.               if (*option == '-')
  813.                 {
  814.                   i++;
  815.                   if (i == argc)
  816.                     MagickError(OptionError,"Missing title",option);
  817.                   resource_info.title=argv[i];
  818.                 }
  819.               break;
  820.             }
  821.           if (strncmp("treedepth",option+1,3) == 0)
  822.             {
  823.               quantize_info->tree_depth=0;
  824.               if (*option == '-')
  825.                 {
  826.                   i++;
  827.                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
  828.                     MagickError(OptionError,"Missing depth",option);
  829.                   quantize_info->tree_depth=atoi(argv[i]);
  830.                 }
  831.               break;
  832.             }
  833.           MagickError(OptionError,"Unrecognized option",option);
  834.           break;
  835.         }
  836.         case 'v':
  837.         {
  838.           if (strncmp("verbose",option+1,2) == 0)
  839.             {
  840.               image_info->verbose=(*option == '-');
  841.               break;
  842.             }
  843.           if (strncmp("visual",option+1,3) == 0)
  844.             {
  845.               resource_info.visual_type=(char *) NULL;
  846.               if (*option == '-')
  847.                 {
  848.                   i++;
  849.                   if (i == argc)
  850.                     MagickError(OptionError,"Missing visual class",option);
  851.                   resource_info.visual_type=argv[i];
  852.                 }
  853.               break;
  854.             }
  855.           MagickError(OptionError,"Unrecognized option",option);
  856.           break;
  857.         }
  858.         case 'w':
  859.         {
  860.           if (strncmp("window",option+1,2) == 0)
  861.             {
  862.               resource_info.window_id=(char *) NULL;
  863.               if (*option == '-')
  864.                 {
  865.                   i++;
  866.                   if (i == argc)
  867.                     MagickError(OptionError,"Missing id, name, or 'root'",
  868.                       option);
  869.                   resource_info.window_id=argv[i];
  870.                 }
  871.               break;
  872.             }
  873.           MagickError(OptionError,"Unrecognized option",option);
  874.           break;
  875.         }
  876.         case '?':
  877.         {
  878.           Usage(client_name);
  879.           break;
  880.         }
  881.         default:
  882.         {
  883.           MagickError(OptionError,"Unrecognized option",option);
  884.           break;
  885.         }
  886.       }
  887.     else
  888.       {
  889.         /*
  890.           Option is a file name.
  891.         */
  892.         for (scene=first_scene; scene <= last_scene ; scene++)
  893.         {
  894.           /*
  895.             Read image.
  896.           */
  897.           (void) strcpy(image_info->filename,option);
  898.           if (first_scene != last_scene)
  899.             {
  900.               char
  901.                 filename[MaxTextExtent];
  902.  
  903.               /*
  904.                 Form filename for multi-part images.
  905.               */
  906.               (void) sprintf(filename,image_info->filename,scene);
  907.               if (strcmp(filename,image_info->filename) == 0)
  908.                 (void) sprintf(filename,"%s[%u]",image_info->filename,scene);
  909.               (void) strcpy(image_info->filename,filename);
  910.             }
  911.           (void) strcpy(image_info->magick,"MIFF");
  912.           image_info->colorspace=quantize_info->colorspace;
  913.           image_info->dither=quantize_info->dither;
  914.           next_image=ReadImage(image_info);
  915.           if (next_image == (Image *) NULL)
  916.             if (*option == '-')
  917.               break;
  918.             else
  919.               continue;
  920.           MogrifyImages(image_info,i,argv,&next_image);
  921.           if (image == (Image *) NULL)
  922.             image=next_image;
  923.           else
  924.             {
  925.               /*
  926.                 Link image into image list.
  927.               */
  928.               for (p=image; p->next != (Image *) NULL; p=p->next);
  929.               next_image->previous=p;
  930.               p->next=next_image;
  931.             }
  932.         }
  933.       }
  934.   }
  935.   if (image == (Image *) NULL)
  936.     MagickError(OptionError,"Missing an image file name",(char *) NULL);
  937.   while (image->previous != (Image *) NULL)
  938.     image=image->previous;
  939.   if (resource_info.window_id != (char *) NULL)
  940.     XAnimateBackgroundImage(display,&resource_info,image);
  941.   else
  942.     {
  943.       /*
  944.         Animate image to X server.
  945.       */
  946.       loaded_image=XAnimateImages(display,&resource_info,argv,argc,image);
  947.       DestroyImages(image);
  948.       while (loaded_image != (Image *) NULL)
  949.       {
  950.         image=loaded_image;
  951.         MogrifyImage(image_info,argc-1,argv,&image);
  952.         loaded_image=XAnimateImages(display,&resource_info,argv,argc,image);
  953.         DestroyImages(image);
  954.       }
  955.     }
  956.   Exit(0);
  957.   return(False);
  958. }
  959.