]> granicus.if.org Git - imagemagick/blobdiff - MagickWand/display.c
(no commit message)
[imagemagick] / MagickWand / display.c
index 7c45a47a67d1bd71d9326e99512f7c6e475d0308..554c1f32c5b6f9ec69291723a2d54f1e1420171e 100644 (file)
 %              Methods to Interactively Display and Edit an Image             %
 %                                                                             %
 %                             Software Design                                 %
-%                               John Cristy                                   %
+%                                  Cristy                                     %
 %                                July 1992                                    %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -45,7 +45,9 @@
 #include "MagickWand/MagickWand.h"
 #include "MagickWand/mogrify-private.h"
 #include "MagickCore/display-private.h"
+#include "MagickCore/nt-base-private.h"
 #include "MagickCore/string-private.h"
+#include "MagickCore/xwindow-private.h"
 \f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -185,6 +187,7 @@ static MagickBooleanType DisplayUsage(void)
       "-limit type value    pixel cache resource limit",
       "-loop iterations     loop images then exit",
       "-map type            display image using this Standard Colormap",
+      "-matte               store matte channel if the image has one",
       "-monitor             monitor progress",
       "-page geometry       size and location of an image canvas",
       "-profile filename    add, delete, or apply an image profile",
@@ -197,9 +200,11 @@ static MagickBooleanType DisplayUsage(void)
       "-respect-parentheses settings remain in effect until parenthesis boundary",
       "-sampling-factor geometry",
       "                     horizontal and vertical sampling factor",
+      "-scenes range        image scene range",
       "-seed value          seed a new sequence of pseudo-random numbers",
       "-set property value  set an image property",
       "-size geometry       width and height of image",
+      "-support factor      resize support: > 1.0 is blurry, < 1.0 is sharp",
       "-texture filename    name of texture to tile onto the image background",
       "-transparent-color color",
       "                     transparent color",
@@ -221,9 +226,7 @@ static MagickBooleanType DisplayUsage(void)
       (char *) NULL
     };
 
-  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
-  (void) printf("Copyright: %s\n",GetMagickCopyright());
-  (void) printf("Features: %s\n\n",GetMagickFeatures());
+  ListMagickVersion(stdout);
   (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
     GetClientName());
   (void) printf("\nImage Settings:\n");
@@ -246,7 +249,7 @@ static MagickBooleanType DisplayUsage(void)
     "-borderwidth, -font, -foreground, -iconGeometry, -iconic, -mattecolor,\n");
   (void) printf("-name, -shared-memory, -usePixmap, or -title.\n");
   (void) printf(
-    "\nBy default, the image format of `file' is determined by its magic\n");
+    "\nBy default, the image format of 'file' is determined by its magic\n");
   (void) printf(
     "number.  To specify a particular image format, precede the filename\n");
   (void) printf(
@@ -291,7 +294,7 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
 #define ThrowDisplayInvalidArgumentException(option,argument) \
 { \
   (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
-    "InvalidArgument","`%s': %s",option,argument); \
+    "InvalidArgument","'%s': %s",option,argument); \
   DestroyDisplay(); \
   return(MagickFalse); \
 }
@@ -359,12 +362,7 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
       if ((LocaleCompare("version",option+1) == 0) ||
           (LocaleCompare("-version",option+1) == 0))
         {
-          (void) FormatLocaleFile(stdout,"Version: %s\n",
-            GetMagickVersion((size_t *) NULL));
-          (void) FormatLocaleFile(stdout,"Copyright: %s\n",
-            GetMagickCopyright());
-          (void) FormatLocaleFile(stdout,"Features: %s\n\n",
-            GetMagickFeatures());
+          ListMagickVersion(stdout);
           return(MagickFalse);
         }
     }
@@ -446,10 +444,11 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
   image_info->quality=StringToUnsignedLong(resource_value);
   resource_value=XGetResourceInstance(resource_database,GetClientName(),
     "verbose","False");
-  image_info->verbose=IsMagickTrue(resource_value);
+  image_info->verbose=IsStringTrue(resource_value);
   resource_value=XGetResourceInstance(resource_database,GetClientName(),
     "dither","True");
-  quantize_info->dither=IsMagickTrue(resource_value);
+  quantize_info->dither_method=IsStringTrue(resource_value) != MagickFalse ?
+    RiemersmaDitherMethod : NoDitherMethod;
   /*
     Parse command line.
   */
@@ -471,7 +470,7 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
 
             c=getc(stdin);
             if (c == EOF)
-              break;
+              option="logo:";
             else
               {
                 c=ungetc(c,stdin);
@@ -502,6 +501,7 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
 
         Image
           *display_image,
+          *image_list,
           *images;
 
         /*
@@ -526,10 +526,11 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
         iterations=0;
         if (i == (ssize_t) (argc-1))
           iterations=image->iterations;
-        display_image=CloneImageList(image,exception);
-        if (display_image == (Image *) NULL)
+        image_list=CloneImageList(image,exception);
+        if (image_list == (Image *) NULL)
           ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed",
             GetExceptionMessage(errno));
+        display_image=image_list;
         do
         {
           /*
@@ -542,12 +543,14 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
                 Display image to a specified X window.
               */
               status=XDisplayBackgroundImage(display,&resource_info,
-                display_image);
+                display_image,exception);
               if (status != MagickFalse)
                 {
                   state|=RetainColorsState;
                   status=MagickFalse;
                 }
+              if (GetNextImageInList(display_image) == (Image *) NULL)
+                state|=ExitState;
             }
           else
             do
@@ -561,7 +564,7 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
               if (resource_info.delay != 1)
                 display_image->delay=resource_info.delay;
               nexus=XDisplayImage(display,&resource_info,argv,argc,
-                &display_image,&state);
+                &display_image,&state,exception);
               status&=nexus != (Image *) NULL;
               if (nexus == (Image *) NULL)
                 break;
@@ -579,7 +582,7 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
                     break;
                   }
                 next=XDisplayImage(display,&resource_info,argv,argc,&nexus,
-                  &state);
+                  &state,exception);
                 if ((next == (Image *) NULL) &&
                     (GetNextImageInList(nexus) != (Image *) NULL))
                   {
@@ -601,10 +604,8 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
               */
               (void) CopyMagickString(display_image->filename,
                 resource_info.write_filename,MaxTextExtent);
-              (void) SetImageInfo(image_info,1,&display_image->exception);
-              status&=WriteImage(image_info,display_image,
-                &display_image->exception);
-              GetImageException(display_image,exception);
+              (void) SetImageInfo(image_info,1,exception);
+              status&=WriteImage(image_info,display_image,exception);
             }
           /*
             Proceed to next/previous image.
@@ -612,17 +613,19 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
           if ((state & FormerImageState) != 0)
             for (l=0; l < (ssize_t) resource_info.quantum; l++)
             {
-              display_image=GetPreviousImageInList(display_image);
-              if (display_image == (Image *) NULL)
+              if (GetPreviousImageInList(display_image) == (Image *) NULL)
                 break;
+              display_image=GetPreviousImageInList(display_image);
             }
           else
             for (l=0; l < (ssize_t) resource_info.quantum; l++)
             {
-              display_image=GetNextImageInList(display_image);
-              if (display_image == (Image *) NULL)
+              if (GetNextImageInList(display_image) == (Image *) NULL)
                 break;
+              display_image=GetNextImageInList(display_image);
             }
+          if (l < (ssize_t) resource_info.quantum)
+            break;
         } while ((display_image != (Image *) NULL) && ((state & ExitState) == 0));
         /*
           Free image resources.
@@ -668,6 +671,7 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
           state|=ExitState;
         if (LocaleCompare(filename,"-") == 0)
           state|=ExitState;
+        RemoveAllImageStack();
         continue;
       }
     pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
@@ -685,9 +689,9 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
             i++;
             if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
-            type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
+            type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]);
             if (type < 0)
-              ThrowDisplayException(OptionError,"UnrecognizedAlphaChannelType",
+              ThrowDisplayException(OptionError,"UnrecognizedAlphaChannelOption",
                 argv[i]);
             break;
           }
@@ -1012,7 +1016,7 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
             ssize_t
               method;
 
-            quantize_info->dither=MagickFalse;
+            quantize_info->dither_method=NoDitherMethod;
             if (*option == '+')
               break;
             i++;
@@ -1022,7 +1026,6 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
             if (method < 0)
               ThrowDisplayException(OptionError,"UnrecognizedDitherMethod",
                 argv[i]);
-            quantize_info->dither=MagickTrue;
             quantize_info->dither_method=(DitherMethod) method;
             break;
           }
@@ -1313,7 +1316,7 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
             i++;
             if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
-            value=InterpretLocaleValue(argv[i],&p);
+            value=StringToDouble(argv[i],&p);
             (void) value;
             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
               ThrowDisplayInvalidArgumentException(option,argv[i]);
@@ -1790,12 +1793,7 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
         if ((LocaleCompare("version",option+1) == 0) ||
             (LocaleCompare("-version",option+1) == 0))
           {
-            (void) FormatLocaleFile(stdout,"Version: %s\n",
-              GetMagickVersion((size_t *) NULL));
-            (void) FormatLocaleFile(stdout,"Copyright: %s\n",
-              GetMagickCopyright());
-            (void) FormatLocaleFile(stdout,"Features: %s\n\n",
-              GetMagickFeatures());
+            ListMagickVersion(stdout);
             break;
           }
         if (LocaleCompare("visual",option+1) == 0)
@@ -1849,7 +1847,7 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
             i++;
             if (i == (ssize_t) argc)
               ThrowDisplayException(OptionError,"MissingArgument",option);
-            if (InterpretLocaleValue(argv[i],(char **) NULL) != 0)
+            if (StringToDouble(argv[i],(char **) NULL) != 0)
               resource_info.window_group=argv[i];
             break;
           }
@@ -1902,7 +1900,7 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
   (void) argc;
   (void) argv;
   (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
-    "DelegateLibrarySupportNotBuiltIn","`%s' (X11)",image_info->filename);
+    "DelegateLibrarySupportNotBuiltIn","'%s' (X11)",image_info->filename);
   return(DisplayUsage());
 #endif
 }