                    ImageMagick 3.0 Patch #1

To apply this patch:

cd to the top of the source tree (to the directory containing the
"ImageMagick" subdirectories) and do:

  patch -p < ThisFile

Prereq: ImageMagick 3.0 (part of the X11R6 contrib distribution).

Alternatively get the entire distribution as
contrib/applications/ImageMagick/ImageMagick-3.1.tar.gz on ftp.x.org.

diff -c -r ImageMagick-3.1/ChangeLog ImageMagick/ChangeLog
*** ImageMagick-3.1/ChangeLog	Wed Jul 13 10:52:10 1994
--- ImageMagick/ChangeLog	Thu Jun  2 14:19:25 1994
***************
*** 1,76 ****
! ImageMagick 3.1
  
    Thanks to pederl@hpubgon.norway.hp.com, rjohnson@shell.com, and
!   muquit@warm.semcor.com for Beta testing 3.1 and offering numerous
    suggestions and bug fixes.
  
-   o You can now toggle the colormap type (Shared or Private) within
-     display(1) (suggested by muquit@warm.semcor.com).
- 
-   o Matte editing now used a flood-fill algorithm (suggested by
-     pederl@hpubgon.norway.hp.com).
- 
-   o Display(1) now supports the X Shape Extension and Shared Memory
-     Extension.
- 
-   o IM can now brighten, darken, sharpen, dull, or saturate an image
-     (suggested by pederl@hpubgon.norway.hp.com).
- 
-   o The aspect ratio was incorrectly honored when writing an image
-     within display(1) (thanks to fergusja@dupont.com).
- 
-   o You can now withdraw the magnify and panning windows by typing
-     'q' within the respective window (suggested by
-     henrik@PICARD.TAMU.EDU).
- 
-   o IM now correctly recognizes '\n' in the -comment option (thanks to
-     pritchet@usceast.cs.scarolina.edu).
- 
-   o IM produces correct JPEG grayscale images now (thanks to
-     Steve Singles).
- 
-   o Misplaced '=' for NAXIS keyword when writing FITS images
-     (discovered by allen@prufrock.gsfc.nasa.gov).
- 
-   o Magnify menu now works properly within display(1) (thanks to
-     muquit@warm.semcor.com).
- 
-   o ImageMagick now accepts TIFF images on stdin, stdout, and pipes
-     (suggested by pederl@hpubgon.norway.hp.com)
- 
-   o Can't use ftell on a pipe (thanks to haalboom@prl.philips.nl).
- 
-   o Added Quicken command to display(1) to display the next image after
-     pausing (suggested by pederl@hpubgon.norway.hp.com).
- 
-   o When writing Postscript, the image is scaled only when it exceeds the
-     page geometry (suggested by to muquit@warm.semcor.com).
- 
-   o Image formats that force color reduction now respect the value of the
-     *dither* option (suggested by rjohnson@shell.com).
- 
-   o Two color grayscale images are no longer forced to black and white
-     unless the the *monochrome* option is specified (suggested by
-     rjohnson@shell.com).
- 
-   o ImageMagick now uses V5 Alpha of the Independent JPEG Group's library.
- 
-   o The speed of writing several image formats has been improved
-     (suggested by pederl@hpubgon.norway.hp.com).
- 
-   o Added Emboss to the display(1) menu (thanks to muquit@warm.semcor.com).
- 
-   o Display(1) now puts image read/write errors in a Notice widget.
- 
-   o Add image filename to JPEG error messages (suggested by
-     cheung@remulak.ds.dupont.com).
- 
-   o Double click in the Text widget to copy and paste text (suggested by
-     pederl@hpubgon.norway.hp.com).
- 
- 
- ImageMagick 3.0
- 
    o Postscript written by ImageMagick no longer leaves an operator on the
      stack (thanks to doug@cc.gatech.edu).
  
--- 1,9 ----
! ImageMagick 3.0
  
    Thanks to pederl@hpubgon.norway.hp.com, rjohnson@shell.com, and
!   muquit@warm.semcor.com for Beta testing 3.0 and offering numerous
    suggestions and bug fixes.
  
    o Postscript written by ImageMagick no longer leaves an operator on the
      stack (thanks to doug@cc.gatech.edu).
  
***************
*** 88,94 ****
    o Dithering caused segmentation fault on the DEC ALPHA (discovered by
      blake@davros.portable.com).
  
!   o display(1) now recognizes the fontList resource (thanks to
      Steve Singles).
  
    o ImageMagick supports the mask image for XPM images (suggested by
--- 21,27 ----
    o Dithering caused segmentation fault on the DEC ALPHA (discovered by
      blake@davros.portable.com).
  
!   o display(1) now recognized the fontList resource (thanks to
      Steve Singles).
  
    o ImageMagick supports the mask image for XPM images (suggested by
***************
*** 128,135 ****
    o Press F1 to get help within display(1) (suggested by
      pederl@hpubgon.norway.hp.com).
  
!   o display(1) now has a crop image command.  You can define a region
!     to crop with button 1 and use the arrow keys to adjust (suggested by
      pederl@hpubgon.norway.hp.com).
  
    o Use -label to display a header above the Postscript image
--- 61,68 ----
    o Press F1 to get help within display(1) (suggested by
      pederl@hpubgon.norway.hp.com).
  
!   o display(1) now has a clip image command.  You can define a region
!     to clip with button 1 and use the arrow keys to adjust (suggested by
      pederl@hpubgon.norway.hp.com).
  
    o Use -label to display a header above the Postscript image
***************
*** 164,175 ****
    o When converting an image with an matte channel to GIF, the
      transparency index is set (suggested by scott@shrug.org).
  
!   o display(1) now rotates cropped images properly (thanks to
      rjohnson@shell.com).
  
    o Improved the scaling algorithm (suggested by rjohnson@shell.com).
  
!   o Use -crop 0x0 to remove edges that are the background color
      (suggested by ruggier@ptsun00.cern.ch).
  
  
--- 97,108 ----
    o When converting an image with an matte channel to GIF, the
      transparency index is set (suggested by scott@shrug.org).
  
!   o display(1) now rotates clipped images properly (thanks to
      rjohnson@shell.com).
  
    o Improved the scaling algorithm (suggested by rjohnson@shell.com).
  
!   o Use -clip 0x0 to remove edges that are the background color
      (suggested by ruggier@ptsun00.cern.ch).
  
  
***************
*** 303,309 ****
  
    o Added preview bitmap to Encapsulated Postscript images.
  
!   o Added -crop to import(1) (suggested by jb7716@csc.albany.edu).
  
    o Converting from full color to monochrome images now works
      properly.
--- 236,242 ----
  
    o Added preview bitmap to Encapsulated Postscript images.
  
!   o Added -clip to import(1) (suggested by jb7716@csc.albany.edu).
  
    o Converting from full color to monochrome images now works
      properly.
***************
*** 316,322 ****
  
    o ImageMagick can now read and write FITS images.
  
!   o ImageMagick no longer crops large Postscript images (images larger
      than the default page).
  
    o ImageMagick can now read and write 24 bit PICT images.
--- 249,255 ----
  
    o ImageMagick can now read and write FITS images.
  
!   o ImageMagick no longer clips large Postscript images (images larger
      than the default page).
  
    o ImageMagick can now read and write 24 bit PICT images.
***************
*** 561,567 ****
    o Red, green, and blue values of a X constant image were set to the
      red intensity of the background color.
  
!   o Cropped images did not show up correctly in the panning icon.
  
    o `animate' no longer shows images out-of-order if the image scene
      number is absent (thanks to kent@oddjob.uchicago.edu).
--- 494,500 ----
    o Red, green, and blue values of a X constant image were set to the
      red intensity of the background color.
  
!   o Clipped images did not show up correctly in the panning icon.
  
    o `animate' no longer shows images out-of-order if the image scene
      number is absent (thanks to kent@oddjob.uchicago.edu).
diff -c -r ImageMagick-3.1/ImageMagick.man ImageMagick/ImageMagick.man
*** ImageMagick-3.1/ImageMagick.man	Wed Jul 13 10:52:15 1994
--- ImageMagick/ImageMagick.man	Wed Jun  1 22:12:55 1994
***************
*** 44,59 ****
      o invert the colors of the image
      o perform histogram equalization on the image
      o perform histogram normalization on the image
-     o brighten the image
-     o darken the image
-     o sharpen the image contrast
-     o dull the image contrast
-     o increase or decrease the color saturation
      o gamma correct the image
      o reduce the speckles within an image
      o eliminate peak noise from an image
      o detect edges within the image
-     o emboss an image
      o convert the image to grayscale
      o set the maximum number of unique colors in the image
      o annotate the image with text
--- 44,53 ----
diff -c -r ImageMagick-3.1/Imakefile ImageMagick/Imakefile
*** ImageMagick-3.1/Imakefile	Wed Jul 13 10:52:16 1994
--- ImageMagick/Imakefile	Mon Jun 13 14:33:18 1994
***************
*** 79,85 ****
  NormalProgramTarget(segment,segment.o,NullParameter,$(LOCAL_LIBRARIES),$(XLIB) -lm)
  InstallProgram(segment,$(LOCALDIR))
  InstallManPage(segment,$(MANDIR))
- InstallManPage(ImageMagick,$(MANDIR))
  
  DependTarget()
  
--- 79,84 ----
***************
*** 87,91 ****
  install.man:: file.man                                                  @@\
  	$(INSTALL) -c $(INSTMANFLAGS) file.man $(DESTDIR)destdir/file.suffix
  
! InstallMyManPage(quantize,$(MANPATH)/man5,5)
! InstallMyManPage(miff,$(MANPATH)/man5,5)
--- 86,91 ----
  install.man:: file.man                                                  @@\
  	$(INSTALL) -c $(INSTMANFLAGS) file.man $(DESTDIR)destdir/file.suffix
  
! InstallMyManPage(ImageMagick,$(MANDIR),n)
! InstallMyManPage(quantize,$(MANDIR),5)
! InstallMyManPage(miff,$(MANDIR),5)
diff -c -r ImageMagick-3.1/Magick.tmpl ImageMagick/Magick.tmpl
*** ImageMagick-3.1/Magick.tmpl	Wed Jul 13 10:52:16 1994
--- ImageMagick/Magick.tmpl	Mon Jun  6 13:37:06 1994
***************
*** 29,43 ****
  XCOMM
  XCOMM DIRENT_DEFINES= -DDIRENT=0
  
- DIRENT_DEFINES=
- 
- XCOMM Define HasShape if your X server supports the Shape Extension. Define
- XCOMM HasSharedMemory if your X server supports the Shared Memory Extension.
- XCOMM
- XCOMM EXTENSIONS_DEFINES= -DHasShape -DHasSHaredMemory
- 
- EXTENSIONS_DEFINES=
- 
  XCOMM Set DoSharedLib to HasSharedLibraries to build ImageMagick with shared
  XCOMM libraries.
  XCOMM
--- 29,34 ----
***************
*** 76,82 ****
  XCOMM  EXTRA_LOAD_FLAGS= -lnsl
  
  #ifdef HPArchitecture
! CCOPTIONS= -Aa -D_HPUX_SOURCE -Dhpux
  #endif
  
  LOCALDIR= /usr/local/bin
--- 67,73 ----
  XCOMM  EXTRA_LOAD_FLAGS= -lnsl
  
  #ifdef HPArchitecture
! CCOPTIONS= -Aa
  #endif
  
  LOCALDIR= /usr/local/bin
***************
*** 86,94 ****
  MAGICK_INCLUDES= -I$(TOP)/magick
  MAGICK_LIBRARIES= -L$(TOP)/magick -lMagick
  
! DEFINES= $(MAGICK_INCLUDES) $(DIRENT_DEFINES) $(EXTENSIONS_DEFINES) \
!   $(JPEG_DEFINES) $(JPEG_INCLUDES) $(TIFF_DEFINES) $(TIFF_INCLUDES) \
!   $(XPM_DEFINES) $(XPM_INCLUDES)
  LOCAL_LIBRARIES= $(MAGICK_LIBRARIES) $(JPEG_LIBRARIES) $(TIFF_LIBRARIES) \
    $(XPM_LIBRARIES)
  REQUIRED_LIBRARIES= $(JPEG_LIBRARIES) $(TIFF_LIBRARIES) $(XPM_LIBRARIES)
--- 77,84 ----
  MAGICK_INCLUDES= -I$(TOP)/magick
  MAGICK_LIBRARIES= -L$(TOP)/magick -lMagick
  
! DEFINES= $(MAGICK_INCLUDES) $(DIRENT_DEFINES) $(JPEG_DEFINES) $(JPEG_INCLUDES)\
!   $(TIFF_DEFINES) $(TIFF_INCLUDES) $(XPM_DEFINES) $(XPM_INCLUDES)
  LOCAL_LIBRARIES= $(MAGICK_LIBRARIES) $(JPEG_LIBRARIES) $(TIFF_LIBRARIES) \
    $(XPM_LIBRARIES)
  REQUIRED_LIBRARIES= $(JPEG_LIBRARIES) $(TIFF_LIBRARIES) $(XPM_LIBRARIES)
diff -c -r ImageMagick-3.1/README ImageMagick/README
*** ImageMagick-3.1/README	Wed Jul 13 10:52:11 1994
--- ImageMagick/README	Wed Jun  8 16:00:08 1994
***************
*** 20,26 ****
  AVAILABILITY
  
    Anonymous FTP at ftp.x.org, file
!   contrib/applications/ImageMagick/ImageMagick-3.1.tar.gz.  I want
    ImageMagick to be of high quality, so if you encounter a problem I
    will investigate.  However, be sure you are using the most recent
    version from ftp.x.org before submitting any bug reports or
--- 20,26 ----
  AVAILABILITY
  
    Anonymous FTP at ftp.x.org, file
!   contrib/applications/ImageMagick/ImageMagick-3.0.tar.gz.  I want
    ImageMagick to be of high quality, so if you encounter a problem I
    will investigate.  However, be sure you are using the most recent
    version from ftp.x.org before submitting any bug reports or
***************
*** 31,38 ****
  
    Type:
  
!     gunzip ImageMagick-3.1.tar.gz
!     tar xvf ImageMagick-3.1.tar
      cd ImageMagick
      xmkmf
      make Makefiles
--- 31,38 ----
  
    Type:
  
!     gunzip ImageMagick-3.0.tar.gz
!     tar xvf ImageMagick-3.0.tar
      cd ImageMagick
      xmkmf
      make Makefiles
***************
*** 41,48 ****
  
    If you do not have gunzip(1), it is available as
    prep.ai.mit.edu:pub/gnu/gzip-1.2.4.shar.  If you do not have xmkmf(1),
!   or if xmkmf(1) fails to produce usable Makefiles, type
  
      configure
      make
  
--- 41,52 ----
  
    If you do not have gunzip(1), it is available as
    prep.ai.mit.edu:pub/gnu/gzip-1.2.4.shar.  If you do not have xmkmf(1),
!   or if xmkmf(1) fails to produce usable Makefiles, get 
!   ftp.x.org:contrib/applications/ImageMagick/ImageMagick.configure and
!   type
  
+     cd ImageMagick
+     sh ImageMagick.configure -c
      configure
      make
  
***************
*** 89,95 ****
         PNM       Portable bitmap
         PS        Adobe PostScript file
         PS2       Adobe PostScript Level II file
-        RAD       Radiance image file
         RGB       Raw red, green, and blue bytes
         RLE       Utah Raster Toolkit
         SUN       SUN raster
--- 93,98 ----
***************
*** 138,145 ****
    Radiance image format.
  
    ImageMagick requires the Independent JPEG Group's software available via
!   FTP as ftp.x.org:contrib/applications/ImageMagick/ImageMagick.jpeg.tar.gz
!   to read the JPEG image format.
  
    ImageMagick requires Sam Leffler's TIFF software available via FTP as
    sgi.com:graphics/tiff/v3.2beta.tar.Z to read the TIFF image format. If
--- 141,148 ----
    Radiance image format.
  
    ImageMagick requires the Independent JPEG Group's software available via
!   FTP as ftp.uu.net:graphics/jpeg/jpegsrc.v4.tar.Z to read the JPEG image
!   format.
  
    ImageMagick requires Sam Leffler's TIFF software available via FTP as
    sgi.com:graphics/tiff/v3.2beta.tar.Z to read the TIFF image format. If
***************
*** 154,162 ****
      cd ImageMagick
      mkdir jpeg
      cd jpeg
!     gunzip -c ImageMagick.jpeg.tar.gz | tar xvof -
!     configure CC=cc
!     make
      cd ..
      mkdir tiff
      cd tiff
--- 157,166 ----
      cd ImageMagick
      mkdir jpeg
      cd jpeg
!     zcat jpegsrc.v4.tar.Z | tar xvof -
!     cp jmemnobs.c jmemsys.c
!     cp makefile.unix Makefile
!     make libjpeg.a
      cd ..
      mkdir tiff
      cd tiff
***************
*** 166,173 ****
      make
      cd ../..
      mkdir xpm
-     cd xpm
      mv xpm-3.4b/lib/* .
      xmkmf
      make
      cd ..
--- 170,177 ----
      make
      cd ../..
      mkdir xpm
      mv xpm-3.4b/lib/* .
+     cd xpm
      xmkmf
      make
      cd ..
***************
*** 200,208 ****
  
      display [.images]aquarium.miff
      display -monochrome -dither [.images]aquarium.miff
- 
-   Alternatively, get a BACKUP save set from decwindows/imagemagick??.zip
-   from ada.cenaath.cena.dgac.fr.
  
  
  ANIMATION
--- 204,209 ----
Only in ImageMagick-3.1: README.jpeg
diff -c -r ImageMagick-3.1/animate.c ImageMagick/animate.c
*** ImageMagick-3.1/animate.c	Wed Jul 13 10:52:08 1994
--- ImageMagick/animate.c	Mon May 23 16:46:12 1994
***************
*** 62,71 ****
  %
  %  Where options include:
  %    -backdrop            display image centered on a backdrop
  %    -colormap type       Shared or Private
  %    -colors value        preferred number of colors in the image
  %    -colorspace type     GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV
- %    -crop geometry       preferred size and location of the cropped image
  %    -delay milliseconds  display the next image after pausing
  %    -density geometry    vertical and horizontal density of the image
  %    -display server      display image to this X server
--- 62,71 ----
  %
  %  Where options include:
  %    -backdrop            display image centered on a backdrop
+ %    -clip geometry       preferred size and location of the clipped image
  %    -colormap type       Shared or Private
  %    -colors value        preferred number of colors in the image
  %    -colorspace type     GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV
  %    -delay milliseconds  display the next image after pausing
  %    -density geometry    vertical and horizontal density of the image
  %    -display server      display image to this X server
***************
*** 195,204 ****
      *options[]=
      {
        "-backdrop            display image centered on a backdrop",
        "-colormap type       Shared or Private",
        "-colors value        preferred number of colors in the image",
        "-colorspace type     GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV",
-       "-crop geometry       preferred size and location of the cropped image",
        "-delay milliseconds  display the next image after pausing",
        "-density geometry    vertical and horizontal density of the image",
        "-display server      display image to this X server",
--- 195,204 ----
      *options[]=
      {
        "-backdrop            display image centered on a backdrop",
+       "-clip geometry       preferred size and location of the clipped image",
        "-colormap type       Shared or Private",
        "-colors value        preferred number of colors in the image",
        "-colorspace type     GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV",
        "-delay milliseconds  display the next image after pausing",
        "-density geometry    vertical and horizontal density of the image",
        "-display server      display image to this X server",
***************
*** 829,842 ****
    windows->wm_protocols=XInternAtom(display,"WM_PROTOCOLS",False);
    windows->wm_delete_window=XInternAtom(display,"WM_DELETE_WINDOW",False);
    windows->wm_take_focus=XInternAtom(display,"WM_TAKE_FOCUS",False);
-   if (resource_info->debug)
-     {
-       (void) fprintf(stderr,"Protocols:\n");
-       (void) fprintf(stderr,"  Window Manager: 0x%lx\n",windows->wm_protocols);
-       (void) fprintf(stderr,"    delete window: 0x%lx\n",
-         windows->wm_delete_window);
-       (void) fprintf(stderr,"    take focus: 0x%lx\n",windows->wm_take_focus);
-     }
    /*
      Allocate class and manager hints.
    */
--- 829,834 ----
***************
*** 1114,1120 ****
    windows->info.y=2;
    windows->info.flags|=PPosition;
    windows->info.attributes.win_gravity=UnmapGravity;
!   windows->info.attributes.event_mask=ButtonPressMask | StructureNotifyMask;
    class_hint->res_name="info";
    manager_hints->flags=InputHint | StateHint | WindowGroupHint;
    manager_hints->input=False;
--- 1106,1113 ----
    windows->info.y=2;
    windows->info.flags|=PPosition;
    windows->info.attributes.win_gravity=UnmapGravity;
!   windows->info.attributes.event_mask=ButtonPressMask | OwnerGrabButtonMask |
!     StructureNotifyMask;
    class_hint->res_name="info";
    manager_hints->flags=InputHint | StateHint | WindowGroupHint;
    manager_hints->input=False;
***************
*** 1743,1766 ****
        (void) sprintf(text,"%s  depth: %d\n",text,windows->image.depth);
        (void) sprintf(text,"%s  geometry: %dx%d\n",text,
          windows->image.ximage->width,windows->image.ximage->height);
!       if (windows->image.crop_geometry != (char *) NULL)
!         (void) sprintf(text,"%s  crop geometry: %s\n",text,
!           windows->image.crop_geometry);
!       if (resource_info->colormap== SharedColormap)
!         (void) strcat(text,"  colormap type: Shared\n");
!       else
!         (void) strcat(text,"  colormap type: Private\n");
!       (void) strcat(text,"\n");
!       (void) sprintf(text,"%sImage\n  file: %s\n",text,(*image)->filename);
!       (void) sprintf(text,"%s  format: %s\n",text,(*image)->magick);
!       if ((*image)->filesize != 0)
!         (void) sprintf(text,"%s  bytes: %ld\n",text,(*image)->filesize);
        if ((*image)->class == DirectClass)
          (void) strcat(text,"  class: DirectClass\n");
        else
          (void) strcat(text,"  class: PseudoClass\n");
!       (void) sprintf(text,"%s  geometry: %dx%d\n",text,(*image)->columns,
!         (*image)->rows);
        if ((*image)->colors != 0)
          (void) sprintf(text,"%s  colors: %u\n",text,(*image)->colors);
        if ((*image)->signature != (char *) NULL)
--- 1736,1751 ----
        (void) sprintf(text,"%s  depth: %d\n",text,windows->image.depth);
        (void) sprintf(text,"%s  geometry: %dx%d\n",text,
          windows->image.ximage->width,windows->image.ximage->height);
!       if (windows->image.clip_geometry != (char *) NULL)
!         (void) sprintf(text,"%s  clip geometry: %s\n",text,
!           windows->image.clip_geometry);
!       (void) sprintf(text,"%sImage\n  format: %s\n",text,(*image)->magick);
        if ((*image)->class == DirectClass)
          (void) strcat(text,"  class: DirectClass\n");
        else
          (void) strcat(text,"  class: PseudoClass\n");
!       (void) sprintf(text,"%sImage geometry: %dx%d\n",text,
!         (*image)->columns,(*image)->rows);
        if ((*image)->colors != 0)
          (void) sprintf(text,"%s  colors: %u\n",text,(*image)->colors);
        if ((*image)->signature != (char *) NULL)
***************
*** 1848,1854 ****
    **argv;
  {
    char
!     *crop_geometry,
      *gamma,
      *option,
      *resource_value,
--- 1833,1840 ----
    **argv;
  {
    char
!     *clip_geometry,
!     *density,
      *gamma,
      *option,
      *resource_value,
***************
*** 1860,1868 ****
    Image
      **images;
  
-   ImageInfo
-     image_info;
- 
    int
      i,
      x;
--- 1846,1851 ----
***************
*** 1870,1878 ****
    unsigned int
      first_scene,
      image_number,
      last_scene,
      maximum_images,
!     scene;
  
    XResourceInfo
      resource_info;
--- 1853,1863 ----
    unsigned int
      first_scene,
      image_number,
+     interlace,
      last_scene,
      maximum_images,
!     scene,
!     verbose;
  
    XResourceInfo
      resource_info;
***************
*** 1892,1898 ****
    */
    display=(Display *) NULL;
    first_scene=0;
-   GetImageInfo(&image_info);
    last_scene=0;
    server_name=(char *) NULL;
    maximum_images=MaxTextLength;
--- 1877,1882 ----
***************
*** 1949,1975 ****
      Get user defaults from X resource database.
    */
    XGetResourceInfo(resource_database,client_name,&resource_info);
!   crop_geometry=XGetResourceClass(resource_database,client_name,
!     "cropGeometry",(char *) NULL);
    resource_value=XGetResourceClass(resource_database,client_name,"delay","30");
    resource_info.delay=atoi(resource_value);
!   image_info.density=XGetResourceClass(resource_database,client_name,"density",
      (char *) NULL);
    gamma=XGetResourceClass(resource_database,client_name,"gamma",(char *) NULL);
    resource_value=
      XGetResourceClass(resource_database,client_name,"interlace","none");
!   image_info.interlace=UndefinedInterlace;
    if (Latin1Compare("none",resource_value) == 0)
!     image_info.interlace=NoneInterlace;
    if (Latin1Compare("line",resource_value) == 0)
!     image_info.interlace=LineInterlace;
    if (Latin1Compare("plane",resource_value) == 0)
!     image_info.interlace=PlaneInterlace;
!   if (image_info.interlace == UndefinedInterlace)
      Warning("Unrecognized interlace type",resource_value);
    resource_value=
      XGetResourceClass(resource_database,client_name,"verbose","False");
!   image_info.verbose=IsTrue(resource_value);
    /*
      Parse command line.
    */
--- 1933,1959 ----
      Get user defaults from X resource database.
    */
    XGetResourceInfo(resource_database,client_name,&resource_info);
!   clip_geometry=XGetResourceClass(resource_database,client_name,
!     "clipGeometry",(char *) NULL);
    resource_value=XGetResourceClass(resource_database,client_name,"delay","30");
    resource_info.delay=atoi(resource_value);
!   density=XGetResourceClass(resource_database,client_name,"density",
      (char *) NULL);
    gamma=XGetResourceClass(resource_database,client_name,"gamma",(char *) NULL);
    resource_value=
      XGetResourceClass(resource_database,client_name,"interlace","none");
!   interlace=UndefinedInterlace;
    if (Latin1Compare("none",resource_value) == 0)
!     interlace=NoneInterlace;
    if (Latin1Compare("line",resource_value) == 0)
!     interlace=LineInterlace;
    if (Latin1Compare("plane",resource_value) == 0)
!     interlace=PlaneInterlace;
!   if (interlace == UndefinedInterlace)
      Warning("Unrecognized interlace type",resource_value);
    resource_value=
      XGetResourceClass(resource_database,client_name,"verbose","False");
!   verbose=IsTrue(resource_value);
    /*
      Parse command line.
    */
***************
*** 2028,2033 ****
--- 2012,2029 ----
          }
          case 'c':
          {
+           if (strncmp("clip",option+1,2) == 0)
+             {
+               clip_geometry=(char *) NULL;
+               if (*option == '-')
+                 {
+                   i++;
+                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
+                     Error("Missing geometry on -clip",(char *) NULL);
+                   clip_geometry=argv[i];
+                 }
+               break;
+             }
            if (strncmp("colormap",option+1,6) == 0)
              {
                resource_info.colormap=PrivateColormap;
***************
*** 2092,2109 ****
                  }
                break;
              }
-           if (strncmp("crop",option+1,2) == 0)
-             {
-               crop_geometry=(char *) NULL;
-               if (*option == '-')
-                 {
-                   i++;
-                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
-                     Error("Missing geometry on -crop",(char *) NULL);
-                   crop_geometry=argv[i];
-                 }
-               break;
-             }
            Error("Unrecognized option",option);
            break;
          }
--- 2088,2093 ----
***************
*** 2128,2140 ****
              }
            if (strncmp("density",option+1,3) == 0)
              {
!               image_info.density=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -density",(char *) NULL);
!                   image_info.density=argv[i];
                  }
                break;
              }
--- 2112,2124 ----
              }
            if (strncmp("density",option+1,3) == 0)
              {
!               density=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -density",(char *) NULL);
!                   density=argv[i];
                  }
                break;
              }
***************
*** 2248,2261 ****
                    if (i == argc)
                      Error("Missing type on -interlace",(char *) NULL);
                    option=argv[i];
!                   image_info.interlace=UndefinedInterlace;
                    if (Latin1Compare("none",option) == 0)
!                     image_info.interlace=NoneInterlace;
                    if (Latin1Compare("line",option) == 0)
!                     image_info.interlace=LineInterlace;
                    if (Latin1Compare("plane",option) == 0)
!                     image_info.interlace=PlaneInterlace;
!                   if (image_info.interlace == UndefinedInterlace)
                      Error("Invalid interlace type on -interlace",option);
                  }
                break;
--- 2232,2245 ----
                    if (i == argc)
                      Error("Missing type on -interlace",(char *) NULL);
                    option=argv[i];
!                   interlace=UndefinedInterlace;
                    if (Latin1Compare("none",option) == 0)
!                     interlace=NoneInterlace;
                    if (Latin1Compare("line",option) == 0)
!                     interlace=LineInterlace;
                    if (Latin1Compare("plane",option) == 0)
!                     interlace=PlaneInterlace;
!                   if (interlace == UndefinedInterlace)
                      Error("Invalid interlace type on -interlace",option);
                  }
                break;
***************
*** 2368,2374 ****
          {
            if (strncmp("verbose",option+1,2) == 0)
              {
!               image_info.verbose=(*option == '-');
                break;
              }
            if (strncmp("visual",option+1,2) == 0)
--- 2352,2358 ----
          {
            if (strncmp("verbose",option+1,2) == 0)
              {
!               verbose=(*option == '-');
                break;
              }
            if (strncmp("visual",option+1,2) == 0)
***************
*** 2422,2427 ****
--- 2406,2414 ----
            info_image,
            *next_image;
  
+         ImageInfo
+           image_info;
+ 
          time_t
            start_time;
  
***************
*** 2435,2441 ****
            Option is a file name: begin by reading image from specified file.
          */
          start_time=time((time_t *) NULL);
!         (void) strcpy(image_info.filename,argv[i]);
          if (first_scene != last_scene)
            {
              char
--- 2422,2428 ----
            Option is a file name: begin by reading image from specified file.
          */
          start_time=time((time_t *) NULL);
!         GetImageInfo(argv[i],&image_info);
          if (first_scene != last_scene)
            {
              char
***************
*** 2452,2459 ****
          image_info.server_name=resource_info.server_name;
          image_info.font=resource_info.font;
          image_info.geometry=resource_info.image_geometry;
!         image_info.dither=resource_info.dither;
          image_info.monochrome=resource_info.monochrome;
          image=ReadImage(&image_info);
          if (image == (Image *) NULL)
            if (*option == '-')
--- 2439,2448 ----
          image_info.server_name=resource_info.server_name;
          image_info.font=resource_info.font;
          image_info.geometry=resource_info.image_geometry;
!         image_info.density=density;
!         image_info.interlace=interlace;
          image_info.monochrome=resource_info.monochrome;
+         image_info.verbose=verbose;
          image=ReadImage(&image_info);
          if (image == (Image *) NULL)
            if (*option == '-')
***************
*** 2467,2475 ****
              image->scene=image_number;
            total_colors=0;
            /*
!             Transform image as defined by the crop, image and scale geometries.
            */
!           TransformImage(&image,crop_geometry,resource_info.image_geometry);
            if (gamma != (char *) NULL)
              GammaImage(image,gamma);
            if (resource_info.number_colors != 0)
--- 2456,2464 ----
              image->scene=image_number;
            total_colors=0;
            /*
!             Transform image as defined by the clip, image and scale geometries.
            */
!           TransformImage(&image,clip_geometry,resource_info.image_geometry);
            if (gamma != (char *) NULL)
              GammaImage(image,gamma);
            if (resource_info.number_colors != 0)
***************
*** 2483,2489 ****
                  QuantizeImage(image,resource_info.number_colors,
                    resource_info.tree_depth,resource_info.dither,
                    resource_info.colorspace,True);
!               if (image_info.verbose)
                  {
                    /*
                      Measure quantization error.
--- 2472,2478 ----
                  QuantizeImage(image,resource_info.number_colors,
                    resource_info.tree_depth,resource_info.dither,
                    resource_info.colorspace,True);
!               if (verbose)
                  {
                    /*
                      Measure quantization error.
***************
*** 2494,2500 ****
                  }
                SyncImage(image);
              }
!           if (image_info.verbose)
              {
                /*
                  Display detailed info about the image.
--- 2483,2489 ----
                  }
                SyncImage(image);
              }
!           if (verbose)
              {
                /*
                  Display detailed info about the image.
diff -c -r ImageMagick-3.1/animate.man ImageMagick/animate.man
*** ImageMagick-3.1/animate.man	Wed Jul 13 10:52:16 1994
--- ImageMagick/animate.man	Wed Jun  1 22:12:55 1994
***************
*** 58,63 ****
--- 58,74 ----
  of the backdrop is specified as the background color.  Refer to \fBX
  RESOURCES\fP for details.
  .TP 5
+ .B "-clip \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
+ preferred size and location of the clipped image.  See \fBX(1)\fP for details
+ about the geometry specification.
+ 
+ Use clipping to apply image processing options, or display, only a
+ particular area of an image.  Use \fB-clip 0x0\fP to remove edges that are
+ the background color.
+ 
+ The equivalent X resource for this option is \fBclipGeometry\fP
+ (class \fBClipGeometry\fP).  See \fBX RESOURCES\fP for details.
+ .TP 5
  .B "-colormap \fItype\fP"
  the type of colormap: \fBShared\fP or \fBPrivate\fP.
  
***************
*** 102,118 ****
  images.  \fImilliseconds\fP milliseconds must expire before the display of
  the next image.  The default is 30 milliseconds between each frame
  of the image sequence.
- .TP 5
- .B "-crop \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
- preferred size and location of the cropped image.  See \fBX(1)\fP for details
- about the geometry specification.
- 
- Use cropping to apply image processing options, or display, only a
- particular area of an image.  Use \fB-crop 0x0\fP to remove edges that are
- the background color.
- 
- The equivalent X resource for this option is \fBcropGeometry\fP
- (class \fBCropGeometry\fP).  See \fBX RESOURCES\fP for details.
  .TP 5
  .B "-density \fI<width>x<height>
  vertical and horizontal density of the image.
--- 113,118 ----
diff -c -r ImageMagick-3.1/combine.c ImageMagick/combine.c
*** ImageMagick-3.1/combine.c	Wed Jul 13 10:52:10 1994
--- ImageMagick/combine.c	Mon May 23 16:46:22 1994
***************
*** 164,172 ****
  
    char
      *comment,
      *filename,
      *label,
!     *option;
  
    double
      normalized_maximum_error,
--- 164,177 ----
  
    char
      *comment,
+     *density,
      *filename,
+     *font,
+     *image_geometry,
      *label,
!     *option,
!     *page_geometry,
!     *server_name;
  
    double
      normalized_maximum_error,
***************
*** 192,204 ****
      colorspace,
      compose,
      compression,
      matte,
      mean_error_per_pixel,
      monochrome,
      number_colors,
      scene,
      stereo,
!     tree_depth;
  
    unsigned long
      total_colors;
--- 197,213 ----
      colorspace,
      compose,
      compression,
+     dither,
+     interlace,
      matte,
      mean_error_per_pixel,
      monochrome,
      number_colors,
+     quality,
      scene,
      stereo,
!     tree_depth,
!     verbose;
  
    unsigned long
      total_colors;
***************
*** 218,232 ****
    comment=(char *) NULL;
    compose=OverCompositeOp;
    compression=UndefinedCompression;
!   GetImageInfo(&image_info);
    label=(char *) NULL;
    matte=NotInitialized;
    monochrome=False;
    number_colors=0;
    scene=0;
    start_time=time((time_t *) NULL);
    stereo=False;
    tree_depth=0;
    /*
      Check command syntax.
    */
--- 227,249 ----
    comment=(char *) NULL;
    compose=OverCompositeOp;
    compression=UndefinedCompression;
!   density=(char *) NULL;
!   dither=False;
!   font=(char *) NULL;
!   image_geometry=(char *) NULL;
!   interlace=NoneInterlace;
    label=(char *) NULL;
    matte=NotInitialized;
    monochrome=False;
    number_colors=0;
+   page_geometry=(char *) NULL;
+   quality=85;
    scene=0;
+   server_name=(char *) NULL;
    start_time=time((time_t *) NULL);
    stereo=False;
    tree_depth=0;
+   verbose=False;
    /*
      Check command syntax.
    */
***************
*** 240,246 ****
            Read input images.
          */
          filename=argv[i];
!         (void) strcpy(image_info.filename,filename);
          if (alpha_image == (Image *) NULL)
            {
              alpha_image=ReadImage(&image_info);
--- 257,271 ----
            Read input images.
          */
          filename=argv[i];
!         GetImageInfo(filename,&image_info);
!         image_info.server_name=server_name;
!         image_info.font=font;
!         image_info.geometry=image_geometry;
!         image_info.page=page_geometry;
!         image_info.density=density;
!         image_info.interlace=interlace;
!         image_info.quality=quality;
!         image_info.verbose=verbose;
          if (alpha_image == (Image *) NULL)
            {
              alpha_image=ReadImage(&image_info);
***************
*** 379,409 ****
          {
            if (strncmp("density",option+1,3) == 0)
              {
!               image_info.density=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -density",(char *) NULL);
!                   image_info.density=argv[i];
                  }
                break;
              }
            if (strncmp("display",option+1,3) == 0)
              {
!               image_info.server_name=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if (i == argc)
                      Error("Missing server name on -display",(char *) NULL);
!                   image_info.server_name=argv[i];
                  }
                break;
              }
            if (strncmp("dither",option+1,3) == 0)
              {
!               image_info.dither=(*option == '-');
                break;
              }
            Error("Unrecognized option",option);
--- 404,434 ----
          {
            if (strncmp("density",option+1,3) == 0)
              {
!               density=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -density",(char *) NULL);
!                   density=argv[i];
                  }
                break;
              }
            if (strncmp("display",option+1,3) == 0)
              {
!               server_name=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if (i == argc)
                      Error("Missing server name on -display",(char *) NULL);
!                   server_name=argv[i];
                  }
                break;
              }
            if (strncmp("dither",option+1,3) == 0)
              {
!               dither=(*option == '-');
                break;
              }
            Error("Unrecognized option",option);
***************
*** 411,435 ****
          }
          case 'f':
          {
!           image_info.font=(char *) NULL;
            if (*option == '-')
              {
                i++;
                if (i == argc)
                  Error("Missing font name on -font",(char *) NULL);
!               image_info.font=argv[i];
              }
            break;
          }
          case 'g':
          {
!           image_info.geometry=(char *) NULL;
            if (*option == '-')
              {
                i++;
                if ((i == argc) || !sscanf(argv[i],"%d",&x))
                  Error("Missing geometry on -geometry",(char *) NULL);
!               image_info.geometry=argv[i];
              }
            break;
          }
--- 436,460 ----
          }
          case 'f':
          {
!           font=(char *) NULL;
            if (*option == '-')
              {
                i++;
                if (i == argc)
                  Error("Missing font name on -font",(char *) NULL);
!               font=argv[i];
              }
            break;
          }
          case 'g':
          {
!           image_geometry=(char *) NULL;
            if (*option == '-')
              {
                i++;
                if ((i == argc) || !sscanf(argv[i],"%d",&x))
                  Error("Missing geometry on -geometry",(char *) NULL);
!               image_geometry=argv[i];
              }
            break;
          }
***************
*** 442,448 ****
          {
            if (strncmp("interlace",option+1,3) == 0)
              {
!               image_info.interlace=NoneInterlace;
                if (*option == '-')
                  {
                    i++;
--- 467,473 ----
          {
            if (strncmp("interlace",option+1,3) == 0)
              {
!               interlace=NoneInterlace;
                if (*option == '-')
                  {
                    i++;
***************
*** 449,462 ****
                    if (i == argc)
                      Error("Missing type on -interlace",(char *) NULL);
                    option=argv[i];
!                   image_info.interlace=UndefinedInterlace;
                    if (Latin1Compare("none",option) == 0)
!                     image_info.interlace=NoneInterlace;
                    if (Latin1Compare("line",option) == 0)
!                     image_info.interlace=LineInterlace;
                    if (Latin1Compare("plane",option) == 0)
!                     image_info.interlace=PlaneInterlace;
!                   if (image_info.interlace == UndefinedInterlace)
                      Error("Invalid interlace type on -interlace",option);
                  }
                break;
--- 474,487 ----
                    if (i == argc)
                      Error("Missing type on -interlace",(char *) NULL);
                    option=argv[i];
!                   interlace=UndefinedInterlace;
                    if (Latin1Compare("none",option) == 0)
!                     interlace=NoneInterlace;
                    if (Latin1Compare("line",option) == 0)
!                     interlace=LineInterlace;
                    if (Latin1Compare("plane",option) == 0)
!                     interlace=PlaneInterlace;
!                   if (interlace == UndefinedInterlace)
                      Error("Invalid interlace type on -interlace",option);
                  }
                break;
***************
*** 506,518 ****
          {
            if (strncmp("page",option+1,2) == 0)
              {
!               image_info.page=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing page geometry on -page",(char *) NULL);
!                   image_info.page=argv[i];
                  }
                break;
              }
--- 531,543 ----
          {
            if (strncmp("page",option+1,2) == 0)
              {
!               page_geometry=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing page geometry on -page",(char *) NULL);
!                   page_geometry=argv[i];
                  }
                break;
              }
***************
*** 524,530 ****
            i++;
            if ((i == argc) || !sscanf(argv[i],"%d",&x))
              Error("Missing quality on -quality",(char *) NULL);
!           image_info.quality=atoi(argv[i]);
            break;
          }
          case 's':
--- 549,555 ----
            i++;
            if ((i == argc) || !sscanf(argv[i],"%d",&x))
              Error("Missing quality on -quality",(char *) NULL);
!           quality=atoi(argv[i]);
            break;
          }
          case 's':
***************
*** 563,569 ****
          }
          case 'v':
          {
!           image_info.verbose=(*option == '-');
            break;
          }
          default:
--- 588,594 ----
          }
          case 'v':
          {
!           verbose=(*option == '-');
            break;
          }
          default:
***************
*** 624,632 ****
        if ((combined_image->class == DirectClass) ||
            (combined_image->colors > number_colors) ||
            (colorspace == GRAYColorspace))
!         QuantizeImage(combined_image,number_colors,tree_depth,image_info.dither,
!           colorspace,True);
!       if (image_info.verbose)
          {
            /*
              Measure quantization error.
--- 649,657 ----
        if ((combined_image->class == DirectClass) ||
            (combined_image->colors > number_colors) ||
            (colorspace == GRAYColorspace))
!         QuantizeImage(combined_image,number_colors,tree_depth,dither,colorspace,
!           True);
!       if (verbose)
          {
            /*
              Measure quantization error.
***************
*** 638,644 ****
        SyncImage(combined_image);
      }
    status=WriteImage(&image_info,combined_image);
!   if (image_info.verbose)
      {
        /*
          Display detailed info about the image.
--- 663,669 ----
        SyncImage(combined_image);
      }
    status=WriteImage(&image_info,combined_image);
!   if (verbose)
      {
        /*
          Display detailed info about the image.
diff -c -r ImageMagick-3.1/combine.man ImageMagick/combine.man
*** ImageMagick-3.1/combine.man	Wed Jul 13 10:52:16 1994
--- ImageMagick/combine.man	Wed Jun  1 22:12:55 1994
***************
*** 117,127 ****
  .TP 9
  .B plus
  The result is just the sum of the image data.  Output values are
! cropped to 255 (no overflow).  This operation is independent of the
  matte channels.
  .TP 9
  .B minus
! The result of \fIP\fP \- \fIQ\fP, with underflow cropped to zero.  The
  matte channel is ignored (set to 255, full coverage).
  .TP 9
  .B add
--- 117,127 ----
  .TP 9
  .B plus
  The result is just the sum of the image data.  Output values are
! clipped to 255 (no overflow).  This operation is independent of the
  matte channels.
  .TP 9
  .B minus
! The result of \fIP\fP \- \fIQ\fP, with underflow clipped to zero.  The
  matte channel is ignored (set to 255, full coverage).
  .TP 9
  .B add
***************
*** 248,254 ****
  picas or a TEXT page in pixels.  The default for a Postscript page is
  to center the image on a letter page 612 by 792 dots per inch.  The
  left and right margins are 18 picas and the top and bottom 94 picas
! (i.e.  612x792+36+36).  Other common sizes are:
  
      540x720   Note
      612x1008  Legal
--- 248,254 ----
  picas or a TEXT page in pixels.  The default for a Postscript page is
  to center the image on a letter page 612 by 792 dots per inch.  The
  left and right margins are 18 picas and the top and bottom 94 picas
! (i.e.  612x792+18+94).  Other common sizes are:
  
      540x720   Note
      612x1008  Legal
diff -c -r ImageMagick-3.1/convert.c ImageMagick/convert.c
*** ImageMagick-3.1/convert.c	Wed Jul 13 10:52:10 1994
--- ImageMagick/convert.c	Fri Jun  3 15:16:58 1994
***************
*** 50,64 ****
  %  Usage: convert [options ...] input_file output_file
  %
  %  Where options include:
- %    -brighten            brighten or darken an image
  %    -blur                apply a filter to blur the image
  %    -border geometry     surround image with a border of color
  %    -colors value        preferred number of colors in the image
  %    -colorspace type     GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV
  %    -comment string      annotate image with comment
  %    -compress type       RunlengthEncoded or QEncoded
- %    -contrast            enhance or reduce the image contrast
- %    -crop geometry       preferred size and location of the cropped image
  %    -density geometry    vertical and horizontal density of the image
  %    -despeckle           reduce the speckles within an image"
  %    -display server      obtain image or font from this X server
--- 50,62 ----
  %  Usage: convert [options ...] input_file output_file
  %
  %  Where options include:
  %    -blur                apply a filter to blur the image
  %    -border geometry     surround image with a border of color
  %    -colors value        preferred number of colors in the image
+ %    -clip geometry       preferred size and location of the clipped image
  %    -colorspace type     GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV
  %    -comment string      annotate image with comment
  %    -compress type       RunlengthEncoded or QEncoded
  %    -density geometry    vertical and horizontal density of the image
  %    -despeckle           reduce the speckles within an image"
  %    -display server      obtain image or font from this X server
***************
*** 83,89 ****
  %    -roll geometry       roll an image vertically or horizontally
  %    -rotate degrees      apply Paeth rotation to the image
  %    -sample geometry     scale image with pixel sampling
- %    -saturate value      percent increase or decrease in color saturation
  %    -scene value         image scene number
  %    -sharpen             apply a filter to sharpen the image
  %    -shear geometry      slide one edge of the image along the X or Y axis
--- 81,86 ----
***************
*** 128,134 ****
  %    PNM   Portable bitmap.
  %    PS    Adobe PostScript file.
  %    PS2   Adobe Level II PostScript file.
- %    RAD   Radiance image file.
  %    RGB   Raw red, green, and blue bytes.
  %    RLE   Utah Run length encoded image file; read only.
  %    SUN   SUN Rasterfile.
--- 125,130 ----
***************
*** 205,211 ****
        "PNM   Portable bitmap.",
        "PS    Adobe PostScript file.",
        "PS2   Adobe Level II PostScript file.",
-       "RAD   Radiance image file.",
        "RGB   Raw red, green, and blue bytes.",
        "RLE   Utah Run length encoded image file; read only.",
        "SUN   SUN Rasterfile.",
--- 201,206 ----
***************
*** 225,239 ****
      },
      *options[]=
      {
-       "-brighten            brighten or darken an image",
        "-blur                apply a filter to blur the image",
        "-border geometry     surround image with a border of color",
        "-colors value        preferred number of colors in the image",
        "-colorspace type     GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV",
        "-comment string      annotate image with comment",
        "-compress type       RunlengthEncoded or QEncoded",
-       "-contrast            enhance or reduce the image contrast",
-       "-crop geometry       preferred size and location of the cropped image",
        "-density geometry    vertical and horizontal density of the image",
        "-despeckle           reduce the speckles within an image",
        "-display server      obtain image or font from this X server",
--- 220,232 ----
      },
      *options[]=
      {
        "-blur                apply a filter to blur the image",
        "-border geometry     surround image with a border of color",
+       "-clip geometry       preferred size and location of the clipped image",
        "-colors value        preferred number of colors in the image",
        "-colorspace type     GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV",
        "-comment string      annotate image with comment",
        "-compress type       RunlengthEncoded or QEncoded",
        "-density geometry    vertical and horizontal density of the image",
        "-despeckle           reduce the speckles within an image",
        "-display server      obtain image or font from this X server",
***************
*** 258,264 ****
        "-roll geometry       roll an image vertically or horizontally",
        "-rotate degrees      apply Paeth rotation to the image",
        "-sample geometry     scale image with pixel sampling",
-       "-saturate value      percent increase or decrease in color saturation",
        "-scene value         image scene number",
        "-sharpen             apply a filter to sharpen the image",
        "-shear geometry      slide one edge of the image along the X or Y axis",
--- 251,256 ----
***************
*** 316,324 ****
    char
      *border_color,
      *comment,
      *filename,
      *label,
!     *option;
  
    ColorPacket
      border_packet;
--- 308,322 ----
    char
      *border_color,
      *comment,
+     *density,
      *filename,
+     *font,
      *label,
!     *image_geometry,
!     *option,
!     *page_geometry,
!     *server_name,
!     *undercolor_geometry;
  
    ColorPacket
      border_packet;
***************
*** 349,360 ****
--- 347,363 ----
    unsigned int
      colorspace,
      compression,
+     dither,
      height,
+     interlace,
      matte,
+     monochrome,
      mean_error_per_pixel,
      number_colors,
+     quality,
      scene,
      tree_depth,
+     verbose,
      width;
  
    unsigned long
***************
*** 376,389 ****
    colorspace=RGBColorspace;
    compression=UndefinedCompression;
    comment=(char *) NULL;
    image=(Image *) NULL;
!   GetImageInfo(&image_info);
    label=(char *) NULL;
    matte=NotInitialized;
    number_colors=0;
    scene=0;
    start_time=time((time_t *) NULL);
    tree_depth=0;
    /*
      Check command syntax.
    */
--- 379,402 ----
    colorspace=RGBColorspace;
    compression=UndefinedCompression;
    comment=(char *) NULL;
+   density=(char *) NULL;
+   dither=False;
+   font=(char *) NULL;
    image=(Image *) NULL;
!   image_geometry=(char *) NULL;
!   interlace=NoneInterlace;
    label=(char *) NULL;
    matte=NotInitialized;
+   monochrome=False;
    number_colors=0;
+   page_geometry=(char *) NULL;
+   quality=85;
    scene=0;
+   server_name=(char *) NULL;
    start_time=time((time_t *) NULL);
    tree_depth=0;
+   undercolor_geometry=(char *) NULL;
+   verbose=False;
    /*
      Check command syntax.
    */
***************
*** 397,403 ****
            Read input image.
          */
          filename=argv[i];
!         (void) strcpy(image_info.filename,filename);
          if (image != (Image *) NULL)
            Error("input image already specified",filename);
          image=ReadImage(&image_info);
--- 410,426 ----
            Read input image.
          */
          filename=argv[i];
!         GetImageInfo(filename,&image_info);
!         image_info.server_name=server_name;
!         image_info.font=font;
!         image_info.geometry=image_geometry;
!         image_info.page=page_geometry;
!         image_info.density=density;
!         image_info.interlace=interlace;
!         image_info.monochrome=monochrome;
!         image_info.quality=quality;
!         image_info.verbose=verbose;
!         image_info.undercolor=undercolor_geometry;
          if (image != (Image *) NULL)
            Error("input image already specified",filename);
          image=ReadImage(&image_info);
***************
*** 433,445 ****
                  }
                break;
              }
-           if (strncmp("brighten",option+1,2) == 0)
-             break;
            Error("Unrecognized option",option);
            break;
          }
          case 'c':
          {
            if (strncmp("colors",option+1,7) == 0)
              {
                number_colors=0;
--- 456,476 ----
                  }
                break;
              }
            Error("Unrecognized option",option);
            break;
          }
          case 'c':
          {
+           if (strncmp("clip",option+1,2) == 0)
+             {
+               if (*option == '-')
+                 {
+                   i++;
+                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
+                     Error("Missing geometry on -clip",(char *) NULL);
+                 }
+               break;
+             }
            if (strncmp("colors",option+1,7) == 0)
              {
                number_colors=0;
***************
*** 516,533 ****
                  }
                break;
              }
-           if (strncmp("contrast",option+1,3) == 0)
-             break;
-           if (strncmp("crop",option+1,2) == 0)
-             {
-               if (*option == '-')
-                 {
-                   i++;
-                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
-                     Error("Missing geometry on -crop",(char *) NULL);
-                 }
-               break;
-             }
            Error("Unrecognized option",option);
            break;
          }
--- 547,552 ----
***************
*** 535,547 ****
          {
            if (strncmp("density",option+1,3) == 0)
              {
!               image_info.density=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -density",(char *) NULL);
!                   image_info.density=argv[i];
                  }
                break;
              }
--- 554,566 ----
          {
            if (strncmp("density",option+1,3) == 0)
              {
!               density=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -density",(char *) NULL);
!                   density=argv[i];
                  }
                break;
              }
***************
*** 549,567 ****
              break;
            if (strncmp("display",option+1,3) == 0)
              {
!               image_info.server_name=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if (i == argc)
                      Error("Missing server name on -display",(char *) NULL);
!                   image_info.server_name=argv[i];
                  }
                break;
              }
            if (strncmp("dither",option+1,3) == 0)
              {
!               image_info.dither=(*option == '-');
                break;
              }
            Error("Unrecognized option",option);
--- 568,586 ----
              break;
            if (strncmp("display",option+1,3) == 0)
              {
!               server_name=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if (i == argc)
                      Error("Missing server name on -display",(char *) NULL);
!                   server_name=argv[i];
                  }
                break;
              }
            if (strncmp("dither",option+1,3) == 0)
              {
!               dither=(*option == '-');
                break;
              }
            Error("Unrecognized option",option);
***************
*** 586,598 ****
              break;
            if (strncmp("font",option+1,2) == 0)
              {
!               image_info.font=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if (i == argc)
                      Error("Missing font name on -font",(char *) NULL);
!                   image_info.font=argv[i];
                  }
              }
            Error("Unrecognized option",option);
--- 605,617 ----
              break;
            if (strncmp("font",option+1,2) == 0)
              {
!               font=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if (i == argc)
                      Error("Missing font name on -font",(char *) NULL);
!                   font=argv[i];
                  }
              }
            Error("Unrecognized option",option);
***************
*** 612,624 ****
              }
            if (strncmp("geometry",option+1,2) == 0)
              {
!               image_info.geometry=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -geometry",(char *) NULL);
!                   image_info.geometry=argv[i];
                  }
                break;
              }
--- 631,643 ----
              }
            if (strncmp("geometry",option+1,2) == 0)
              {
!               image_geometry=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -geometry",(char *) NULL);
!                   image_geometry=argv[i];
                  }
                break;
              }
***************
*** 634,640 ****
          {
            if (strncmp("interlace",option+1,3) == 0)
              {
!               image_info.interlace=NoneInterlace;
                if (*option == '-')
                  {
                    i++;
--- 653,659 ----
          {
            if (strncmp("interlace",option+1,3) == 0)
              {
!               interlace=NoneInterlace;
                if (*option == '-')
                  {
                    i++;
***************
*** 641,654 ****
                    if (i == argc)
                      Error("Missing type on -interlace",(char *) NULL);
                    option=argv[i];
!                   image_info.interlace=UndefinedInterlace;
                    if (Latin1Compare("none",option) == 0)
!                     image_info.interlace=NoneInterlace;
                    if (Latin1Compare("line",option) == 0)
!                     image_info.interlace=LineInterlace;
                    if (Latin1Compare("plane",option) == 0)
!                     image_info.interlace=PlaneInterlace;
!                   if (image_info.interlace == UndefinedInterlace)
                      Error("Invalid interlace type on -interlace",option);
                  }
                break;
--- 660,673 ----
                    if (i == argc)
                      Error("Missing type on -interlace",(char *) NULL);
                    option=argv[i];
!                   interlace=UndefinedInterlace;
                    if (Latin1Compare("none",option) == 0)
!                     interlace=NoneInterlace;
                    if (Latin1Compare("line",option) == 0)
!                     interlace=LineInterlace;
                    if (Latin1Compare("plane",option) == 0)
!                     interlace=PlaneInterlace;
!                   if (interlace == UndefinedInterlace)
                      Error("Invalid interlace type on -interlace",option);
                  }
                break;
***************
*** 681,688 ****
              }
            if (strncmp("monochrome",option+1,2) == 0)
              {
!               image_info.monochrome=(*option == '-');
!               if (image_info.monochrome)
                  {
                    number_colors=2;
                    tree_depth=8;
--- 700,707 ----
              }
            if (strncmp("monochrome",option+1,2) == 0)
              {
!               monochrome=(*option == '-');
!               if (monochrome)
                  {
                    number_colors=2;
                    tree_depth=8;
***************
*** 707,719 ****
          {
            if (strncmp("page",option+1,2) == 0)
              {
!               image_info.page=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing page geometry on -page",(char *) NULL);
!                   image_info.page=argv[i];
                  }
                break;
              }
--- 726,738 ----
          {
            if (strncmp("page",option+1,2) == 0)
              {
!               page_geometry=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing page geometry on -page",(char *) NULL);
!                   page_geometry=argv[i];
                  }
                break;
              }
***************
*** 725,731 ****
            i++;
            if ((i == argc) || !sscanf(argv[i],"%d",&x))
              Error("Missing quality on -quality",(char *) NULL);
!           image_info.quality=atoi(argv[i]);
            break;
          }
          case 'r':
--- 744,750 ----
            i++;
            if ((i == argc) || !sscanf(argv[i],"%d",&x))
              Error("Missing quality on -quality",(char *) NULL);
!           quality=atoi(argv[i]);
            break;
          }
          case 'r':
***************
*** 765,780 ****
                  }
                break;
              }
-           if (strncmp("saturate",option+1,2) == 0)
-             {
-               if (*option == '-')
-                 {
-                   i++;
-                   if ((i == argc) || !sscanf(argv[i],"%d",(int *) &x))
-                     Error("Missing value on -saturate",(char *) NULL);
-                 }
-               break;
-             }
            if (strncmp("scene",option+1,3) == 0)
              {
                scene=0;
--- 784,789 ----
***************
*** 818,824 ****
          {
            if (strncmp("undercolor",option+1,2) == 0)
              {
!               image_info.undercolor=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
--- 827,833 ----
          {
            if (strncmp("undercolor",option+1,2) == 0)
              {
!               undercolor_geometry=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
***************
*** 825,831 ****
                    if ((i == argc) || !sscanf(argv[i],"%f",(float *) &x))
                      Error("Missing undercolor geometry on -undercolor",
                        (char *) NULL);
!                   image_info.undercolor=argv[i];
                  }
                break;
              }
--- 834,840 ----
                    if ((i == argc) || !sscanf(argv[i],"%f",(float *) &x))
                      Error("Missing undercolor geometry on -undercolor",
                        (char *) NULL);
!                   undercolor_geometry=argv[i];
                  }
                break;
              }
***************
*** 836,842 ****
          {
            if (strncmp("verbose",option+1,1) == 0)
              {
!               image_info.verbose=(*option == '-');
                break;
              }
            Error("Unrecognized option",option);
--- 845,851 ----
          {
            if (strncmp("verbose",option+1,1) == 0)
              {
!               verbose=(*option == '-');
                break;
              }
            Error("Unrecognized option",option);
***************
*** 924,933 ****
              {
                Colormap
                  colormap;
! 
                XColor
                  color;
! 
                /*
                  Obtain border color from the X server.
                */
--- 933,942 ----
              {
                Colormap
                  colormap;
!         
                XColor
                  color;
!         
                /*
                  Obtain border color from the X server.
                */
***************
*** 939,953 ****
                XCloseDisplay(display);
              }
          }
!       if (strncmp("-brighten",option,3) == 0)
!         GammaImage(image,"1.25");
!       if (strncmp("+brighten",option,3) == 0)
!         GammaImage(image,"0.75");
!       if (strncmp("-contrast",option,4) == 0)
!         ContrastImage(image,True);
!       if (strncmp("+contrast",option,4) == 0)
!         ContrastImage(image,False);
!       if (strncmp("-crop",option,3) == 0)
          TransformImage(&image,argv[++i],(char *) NULL);
        if (strncmp("-despeckle",option,4) == 0)
          {
--- 948,954 ----
                XCloseDisplay(display);
              }
          }
!       if (strncmp("-clip",option,3) == 0)
          TransformImage(&image,argv[++i],(char *) NULL);
        if (strncmp("-despeckle",option,4) == 0)
          {
***************
*** 1105,1112 ****
                image=sampled_image;
              }
          }
-       if (strncmp("-saturate",option,4) == 0)
-         SaturateImage(image,atoi(argv[++i]));
        if (strncmp("-sharpen",option,4) == 0)
          {
            Image
--- 1106,1111 ----
***************
*** 1153,1161 ****
          */
          if ((image->class == DirectClass) || (image->colors > number_colors) ||
              (colorspace == GRAYColorspace))
!           QuantizeImage(image,number_colors,tree_depth,image_info.dither,
!             colorspace,True);
!         if (image_info.verbose)
            {
              /*
                Measure quantization error.
--- 1152,1159 ----
          */
          if ((image->class == DirectClass) || (image->colors > number_colors) ||
              (colorspace == GRAYColorspace))
!           QuantizeImage(image,number_colors,tree_depth,dither,colorspace,True);
!         if (verbose)
            {
              /*
                Measure quantization error.
***************
*** 1167,1173 ****
          SyncImage(image);
        }
      status=WriteImage(&image_info,image);
!     if (image_info.verbose)
        {
          /*
            Display detailed info about the image.
--- 1165,1171 ----
          SyncImage(image);
        }
      status=WriteImage(&image_info,image);
!     if (verbose)
        {
          /*
            Display detailed info about the image.
diff -c -r ImageMagick-3.1/convert.man ImageMagick/convert.man
*** ImageMagick-3.1/convert.man	Wed Jul 13 10:52:17 1994
--- ImageMagick/convert.man	Wed Jun  1 22:12:56 1994
***************
*** 88,96 ****
  .B PS2
  Adobe Level II PostScript file.
  .TP 6
- .B RAD
- Radiance image format.
- .TP 6
  .B RGB
  Raw red, green, and blue bytes.
  .TP 6
--- 88,93 ----
***************
*** 170,181 ****
  The color of the border is obtained from the X server and is defined as
  \fBbordercolor\fP (class \fBborderColor\fP).  See \fBX(1)\fP for details.
  .TP 5
! .B "-brighten"
! brighten or darken an image.
  
! This option increases or decreases the intensity of an image.  Use
! \fB-brighten\fP to brighten the image or \fB+brighten\fP to darken the
! image intensity.
  .TP 5
  .B "-colors \fIvalue\fP"
  preferred number of colors in the image.
--- 167,178 ----
  The color of the border is obtained from the X server and is defined as
  \fBbordercolor\fP (class \fBborderColor\fP).  See \fBX(1)\fP for details.
  .TP 5
! .B "-clip \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
! preferred size and location of the clipped image.  See \fBX(1)\fP for details
! about the geometry specification.
  
! Use clipping to crop a particular area of an image.   Use \fB-clip
! 0x0\fP to remove edges that are the background color.
  .TP 5
  .B "-colors \fIvalue\fP"
  preferred number of colors in the image.
***************
*** 228,247 ****
  Specify \fB\+compress\fP to store the binary image in an uncompressed format.
  The default is the compression type of the specified image file.
  .TP 5
- .B "-contrast"
- enhance or reduce the image contrast.
- 
- This option enhances the intensity differences between the
- lighter and darker elements of the image.  Use \fB-contrast\fP to
- enhance the image or \fB+contrast\fP to reduce the image contrast.
- .TP 5
- .B "-crop \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
- preferred size and location of the cropped image.  See \fBX(1)\fP for details
- about the geometry specification.
- 
- Use cropping to crop a particular area of an image.   Use \fB-crop
- 0x0\fP to remove edges that are the background color.
- .TP 5
  .B "-density \fI<width>x<height>
  vertical and horizontal density of the image.
  
--- 225,230 ----
***************
*** 359,364 ****
--- 342,348 ----
  
  The red, green, and blue intensities of an image are negated.
  .TP 5
+ .TP 5
  .B "-noise"
  reduce the noise in an image with a noise peak elimination filter.
  
***************
*** 381,387 ****
  picas or a TEXT page in pixels.  The default for a Postscript page is
  to center the image on a letter page 612 by 792 dots per inch.  The
  left and right margins are 18 picas and the top and bottom 94 picas
! (i.e.  612x792+36+36).  Other common sizes are:
  
      540x720   Note
      612x1008  Legal
--- 365,371 ----
  picas or a TEXT page in pixels.  The default for a Postscript page is
  to center the image on a letter page 612 by 792 dots per inch.  The
  left and right margins are 18 picas and the top and bottom 94 picas
! (i.e.  612x792+18+94).  Other common sizes are:
  
      540x720   Note
      612x1008  Legal
***************
*** 419,430 ****
  Empty triangles left over from rotating the image are filled with
  the color defined as \fBbordercolor\fP (class \fBborderColor\fP).
  See \fBX(1)\fP for details.
- .TP 5
- .B "-sample \fIgeometry\fP"
- scale image with pixel sampling.
- .TP 5
- .B "-saturate \fIvalue\fP"
- precent increase or decrease in color saturation.
  .TP 5
  .B "-scene \fIvalue\fP"
  image scene number.
--- 403,408 ----
diff -c -r ImageMagick-3.1/display.c ImageMagick/display.c
*** ImageMagick-3.1/display.c	Wed Jul 13 10:52:10 1994
--- ImageMagick/display.c	Sat Jun  4 22:50:13 1994
***************
*** 63,78 ****
  %
  %  Where options include:
  %    -backdrop           display image centered on a backdrop
- %    -brighten           brighten or darken an image
  %    -blur               apply a filter to blur the image
  %    -border geometry    surround image with a border of color
  %    -colormap type      Shared or Private
  %    -colors value       preferred number of colors in the image
  %    -colorspace type    GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV
  %    -comment string     annotate image with comment",
  %    -compress type      RunlengthEncoded or QEncoded
- %    -contrast           enhance or reduce the image contrast
- %    -crop geometry      preferred size and location of the cropped image
  %    -delay seconds      display the next image after pausing
  %    -density geometry   vertical and horizontal density of the image
  %    -despeckle          reduce the speckles within an image
--- 63,76 ----
  %
  %  Where options include:
  %    -backdrop           display image centered on a backdrop
  %    -blur               apply a filter to blur the image
  %    -border geometry    surround image with a border of color
+ %    -clip geometry      preferred size and location of the clipped image
  %    -colormap type      Shared or Private
  %    -colors value       preferred number of colors in the image
  %    -colorspace type    GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV
  %    -comment string     annotate image with comment",
  %    -compress type      RunlengthEncoded or QEncoded
  %    -delay seconds      display the next image after pausing
  %    -density geometry   vertical and horizontal density of the image
  %    -despeckle          reduce the speckles within an image
***************
*** 97,104 ****
  %    -quality value      JPEG quality setting
  %    -roll geometry      roll an image vertically or horizontally
  %    -rotate degrees     apply Paeth rotation to the image
- %    -sample geometry    scale image with pixel sampling
- %    -saturate value     percent increase or decrease in color saturation
  %    -scene value        image scene number
  %    -sharpen            apply a filter to sharpen the image
  %    -shear geometry     slide one edge of the image along the X or Y axis
--- 95,100 ----
***************
*** 136,152 ****
  %    l    load an image from a file
  %    n    display the next image
  %    f    display the former image
- %    Q    display the next image after pausing
  %    u    undo last image transformation
  %    r    restore the image to its original size
  %    @    refresh the image window
- %    F7   toggle the colormap type: : Shared or Private
  %    <    half the image size
  %    o    original image size
  %    >    double the image size
  %    %    resize the image
  %    t    trim the image edges
! %    [    crop the image
  %    ]    cut the image
  %    |    flop image in the horizontal direction
  %    -    flip image in the vertical direction
--- 132,146 ----
  %    l    load an image from a file
  %    n    display the next image
  %    f    display the former image
  %    u    undo last image transformation
  %    r    restore the image to its original size
  %    @    refresh the image window
  %    <    half the image size
  %    o    original image size
  %    >    double the image size
  %    %    resize the image
  %    t    trim the image edges
! %    [    clip the image
  %    ]    cut the image
  %    |    flop image in the horizontal direction
  %    -    flip image in the vertical direction
***************
*** 154,182 ****
  %    \    rotate the image 90 degrees counter-clockwise
  %    *    rotate the image
  %    s    shear the image
! %    F8   brighten the image
! %    F9   darken the image
! %    g    gamma correct the image
! %    F10  sharpen the image contrast
! %    F11  dull the image contrast
! %    F12  increase or decrease the color saturation
  %    =    perform histogram equalization on the image
  %    N    perform histogram normalization on the image
! %    ~    invert the colors of the image
  %    D    reduce the speckles within an image
  %    P    eliminate peak noise from an image
  %    S    sharpen the image
  %    B    blur the image
  %    E    detect edges within an image
- %    M    emboss an image
  %    G    convert the image to grayscale
! %    #    set the maximum number of unique colors in the image
  %    a    annotate the image with text
  %    b    add a border to the image
  %    x    composite image with another
  %    c    edit an image pixel color
  %    m    edit the image matte information
! %    !    add an image comment
  %    h    display information about this program
  %    v    display version number of this program
  %    q    discard all images and exit program
--- 148,170 ----
  %    \    rotate the image 90 degrees counter-clockwise
  %    *    rotate the image
  %    s    shear the image
! %    ~    invert the colors of the image
  %    =    perform histogram equalization on the image
  %    N    perform histogram normalization on the image
! %    g    gamma correct the image
  %    D    reduce the speckles within an image
  %    P    eliminate peak noise from an image
  %    S    sharpen the image
  %    B    blur the image
  %    E    detect edges within an image
  %    G    convert the image to grayscale
! %    Q    set the maximum number of unique colors in the image
  %    a    annotate the image with text
  %    b    add a border to the image
  %    x    composite image with another
  %    c    edit an image pixel color
  %    m    edit the image matte information
! %    #    edit an image comment
  %    h    display information about this program
  %    v    display version number of this program
  %    q    discard all images and exit program
***************
*** 208,222 ****
  #define UpdateConfigurationState  0x0040
  
  /*
-   Global declarations.
- */
- static Display
-   *display;
- 
- static XWindows
-   *windows;
- 
- /*
    Forward declarations.
  */
  static Image
--- 196,201 ----
***************
*** 250,258 ****
    XMakePanImage _Declare((Display *,XResourceInfo *,XWindows *,Image *)),
    XPanImageWindow _Declare((Display *,XWindows *,XEvent *)),
    XMagnifyWindowCommand _Declare((Display *,XWindows *,KeySym)),
!   XSetCropGeometry _Declare((Display *,XWindows *,RectangleInfo *,Image *)),
!   XTranslateImageWindow _Declare((Display *,XWindows *,Image *,KeySym)),
!   XWarning _Declare((char *,char *));
  
  /*
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--- 229,236 ----
    XMakePanImage _Declare((Display *,XResourceInfo *,XWindows *,Image *)),
    XPanImageWindow _Declare((Display *,XWindows *,XEvent *)),
    XMagnifyWindowCommand _Declare((Display *,XWindows *,KeySym)),
!   XSetClipGeometry _Declare((Display *,XWindows *,RectangleInfo *,Image *)),
!   XTranslateImageWindow _Declare((Display *,XWindows *,Image *,KeySym));
  
  /*
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
***************
*** 301,317 ****
        "l    load an image from a file",
        "n    display the next image",
        "f    display the former image",
-       "Q    display the next image after pausing",
        "u    undo last image transformation",
        "r    restore the image to its original size",
        "@    refresh the image window",
-       "F7   toggle the colormap type: Shared or Private",
        "<    half the image size",
        "o    original image size",
        ">    double the image size",
        "%    resize the image",
        "t    trim the image edges",
!       "[    crop the image",
        "]    cut the image",
        "|    flop image in the horizontal direction",
        "-    flip image in the vertical direction",
--- 279,293 ----
        "l    load an image from a file",
        "n    display the next image",
        "f    display the former image",
        "u    undo last image transformation",
        "r    restore the image to its original size",
        "@    refresh the image window",
        "<    half the image size",
        "o    original image size",
        ">    double the image size",
        "%    resize the image",
        "t    trim the image edges",
!       "[    clip the image",
        "]    cut the image",
        "|    flop image in the horizontal direction",
        "-    flip image in the vertical direction",
***************
*** 319,347 ****
        "\\    rotate the image 90 degrees counter-clockwise",
        "*    rotate the image",
        "s    shear the image",
!       "F8   brighten the image",
!       "F9   darken the image",
!       "g    gamma correct the image",
!       "F10  sharpen the image contrast",
!       "F11  dull the image contrast",
!       "F12  increase or decrease the color saturation",
        "=    perform histogram equalization on the image",
        "N    perform histogram normalization on the image",
!       "~    invert the colors of the image",
        "D    reduce the speckles within an image",
        "P    eliminate peak noise from an image",
        "S    sharpen the image",
        "B    blur the image",
        "E    detect edges within an image",
-       "M    emboss an image",
        "G    convert the image to grayscale",
!       "#    set the maximum number of unique colors in the image",
        "a    annotate the image with text",
        "b    add a border to the image",
        "x    composite image with another",
        "c    edit an image pixel color",
        "m    edit the image matte information",
!       "!    add an image comment",
        "h    display information about this program",
        "v    display version number of this program",
        "q    discard all images and exit program",
--- 295,317 ----
        "\\    rotate the image 90 degrees counter-clockwise",
        "*    rotate the image",
        "s    shear the image",
!       "~    invert the colors of the image",
        "=    perform histogram equalization on the image",
        "N    perform histogram normalization on the image",
!       "g    gamma correct the image",
        "D    reduce the speckles within an image",
        "P    eliminate peak noise from an image",
        "S    sharpen the image",
        "B    blur the image",
        "E    detect edges within an image",
        "G    convert the image to grayscale",
!       "Q    set the maximum number of unique colors in the image",
        "a    annotate the image with text",
        "b    add a border to the image",
        "x    composite image with another",
        "c    edit an image pixel color",
        "m    edit the image matte information",
!       "#    add an image comment",
        "h    display information about this program",
        "v    display version number of this program",
        "q    discard all images and exit program",
***************
*** 351,366 ****
      *options[]=
      {
        "-backdrop           display image centered on a backdrop",
-       "-brighten           brighten or darken an image",
        "-blur               apply a filter to blur the image",
        "-border geometry    surround image with a border of color",
        "-colormap type      Shared or Private",
        "-colors value       preferred number of colors in the image",
        "-colorspace type    GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV",
        "-comment string     annotate image with comment",
        "-compress type      RunlengthEncoded or QEncoded",
-       "-contrast           enhance or reduce the image contrast",
-       "-crop geometry      preferred size and location of the cropped image",
        "-delay seconds      display the next image after pausing",
        "-density geometry   vertical and horizontal density of the image",
        "-despeckle          reduce the speckles within an image",
--- 321,334 ----
      *options[]=
      {
        "-backdrop           display image centered on a backdrop",
        "-blur               apply a filter to blur the image",
        "-border geometry    surround image with a border of color",
+       "-clip geometry      preferred size and location of the clipped image",
        "-colormap type      Shared or Private",
        "-colors value       preferred number of colors in the image",
        "-colorspace type    GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV",
        "-comment string     annotate image with comment",
        "-compress type      RunlengthEncoded or QEncoded",
        "-delay seconds      display the next image after pausing",
        "-density geometry   vertical and horizontal density of the image",
        "-despeckle          reduce the speckles within an image",
***************
*** 386,393 ****
        "-roll geometry      roll an image vertically or horizontally",
        "-rotate degrees     apply Paeth rotation to the image",
        "-scene value        image scene number",
-       "-sample geometry    scale image with pixel sampling",
-       "-saturate value     percent increase or decrease in color saturation",
        "-sharpen            apply a filter to sharpen the image",
        "-shear geometry     slide one edge of the image along the X or Y axis",
        "-treedepth value    depth of the color classification tree",
--- 354,359 ----
***************
*** 627,634 ****
              XSetWindowExtents(display,&windows->info,text);
              break;
            }
-         if (event.xbutton.window != windows->image.id)
-           break;
          switch (event.xbutton.button)
          {
            case Button1:
--- 593,598 ----
***************
*** 1189,1196 ****
    y=0;
    width=image->columns;
    height=image->rows;
!   if (windows->image.crop_geometry != (char *) NULL)
!     (void) XParseGeometry(windows->image.crop_geometry,&x,&y,&width,&height);
    /*
      Initialize annotated image.
    */
--- 1153,1160 ----
    y=0;
    width=image->columns;
    height=image->rows;
!   if (windows->image.clip_geometry != (char *) NULL)
!     (void) XParseGeometry(windows->image.clip_geometry,&x,&y,&width,&height);
    /*
      Initialize annotated image.
    */
***************
*** 1345,1350 ****
--- 1309,1798 ----
  %                                                                             %
  %                                                                             %
  %                                                                             %
+ %   X C l i p I m a g e W i n d o w                                           %
+ %                                                                             %
+ %                                                                             %
+ %                                                                             %
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %
+ %  Function XClipImageWindow clips the image window.
+ %
+ %  The format of the XClipImageWindow routine is:
+ %
+ %    status=XClipImageWindow(display,resource_info,windows,image)
+ %
+ %  A description of each parameter follows:
+ %
+ %    o status: Function XClipImageWindow returns True if the image is
+ %      clipped.  False is returned is there is a memory shortage or if the
+ %      image fails to be cropped.
+ %
+ %    o display: Specifies a connection to an X server; returned from
+ %      XOpenDisplay.
+ %
+ %    o resource_info: Specifies a pointer to a X11 XResourceInfo structure.
+ %
+ %    o windows: Specifies a pointer to a XWindows structure.
+ %
+ %    o image: Specifies a pointer to a Image structure; returned from
+ %      ReadImage.
+ %
+ %
+ */
+ static unsigned int XClipImageWindow(display,resource_info,windows,image)
+ Display
+   *display;
+ 
+ XResourceInfo
+   *resource_info;
+ 
+ XWindows
+   *windows;
+ 
+ Image
+   *image;
+ {
+   static char
+     *ImageClipHelp[]=
+     {
+       "To define a clipping region, press button 1 and drag.  The",
+       "clipping region is defined by a highlighted rectangle that",
+       "expands or contracts as it follows the pointer.  Once you",
+       "are satisfied with the clipping region, release the button.",
+       "You can make adjustments to the clipping rectangle with the",
+       "arrow keys.  Press an arrow key to expand the region by",
+       "one pixel.  Press ALT and an arrow key to contract the",
+       "clipping region.",
+       "",
+       "Finally, press RETURN to commit your clipping region.  To",
+       "exit without cropping the image, press ESC.",
+       (char *) NULL,
+     };
+ 
+   char
+     text[MaxTextLength];
+ 
+   Cursor
+     cursor;
+ 
+   int
+     i,
+     x,
+     y;
+ 
+   RectangleInfo
+     clip_info;
+ 
+   unsigned int
+     mask;
+ 
+   unsigned long
+     state;
+ 
+   Window
+     xwindow;
+ 
+   XEvent
+     event;
+ 
+   /*
+     Map info window.
+   */
+   state=DefaultState;
+   (void) sprintf(text," +%u+%u  ",windows->image.width,windows->image.height);
+   XSetWindowExtents(display,&windows->info,text);
+   XMapWindow(display,windows->info.id);
+   /*
+     Track pointer until button 1 is pressed.
+   */
+   XQueryPointer(display,windows->image.id,&xwindow,&xwindow,&i,&i,&x,&y,&mask);
+   clip_info.x=x;
+   clip_info.y=y;
+   clip_info.width=0;
+   clip_info.height=0;
+   cursor=XCreateFontCursor(display,XC_fleur);
+   XSelectInput(display,windows->image.id,windows->image.attributes.event_mask |
+     PointerMotionMask);
+   do
+   {
+     if (windows->info.mapped)
+       {
+         /*
+           Display pointer position.
+         */
+         (void) sprintf(text," %+d%+d ",x-windows->image.x,y-windows->image.y);
+         XDisplayInfoString(display,&windows->info,text);
+       }
+     /*
+       Wait for next event.
+     */
+     XIfEvent(display,&event,XScreenEvent,(char *) windows);
+     switch (event.type)
+     {
+       case ButtonPress:
+       {
+         if (event.xbutton.window == windows->pan.id)
+           {
+             XPanImageWindow(display,windows,&event);
+             XSetWindowExtents(display,&windows->info,text);
+             break;
+           }
+         if (event.xbutton.button == Button1)
+           {
+             /*
+               Note first corner of clipping rectangle-- exit loop.
+             */
+             XDefineCursor(display,windows->image.id,cursor);
+             clip_info.x=event.xbutton.x;
+             clip_info.y=event.xbutton.y;
+             state|=ExitState;
+             break;
+           }
+         break;
+       }
+       case Expose:
+         break;
+       case KeyPress:
+       {
+         static char
+           command[MaxTextLength];
+ 
+         static KeySym
+           key_symbol;
+ 
+         /*
+           Respond to a user key press.
+         */
+         (void) XLookupString((XKeyEvent *) &event.xkey,command,sizeof(command),
+           &key_symbol,(XComposeStatus *) NULL);
+         switch (key_symbol)
+         {
+           case XK_Escape:
+           {
+             /*
+               Prematurely exit.
+             */
+             state|=EscapeState;
+             state|=ExitState;
+             break;
+           }
+           case XK_F1:
+           case XK_Help:
+           {
+             XTextViewWidget(display,windows,"Help Viewer - Image Clipping",
+               ImageClipHelp);
+             break;
+           }
+           default:
+           {
+             XBell(display,0);
+             break;
+           }
+         }
+         break;
+       }
+       case MotionNotify:
+       {
+         /*
+           Discard pending pointer motion events.
+         */
+         while (XCheckMaskEvent(display,PointerMotionMask,&event));
+         x=event.xmotion.x;
+         y=event.xmotion.y;
+         /*
+           Map and unmap info window as text cursor crosses its boundaries.
+         */
+         if (windows->info.mapped)
+           {
+             if ((x < (windows->info.x+windows->info.width)) &&
+                 (y < (windows->info.y+windows->info.height)))
+               XWithdrawWindow(display,windows->info.id,windows->info.screen);
+           }
+         else
+           if ((x > (windows->info.x+windows->info.width)) ||
+               (y > (windows->info.y+windows->info.height)))
+             XMapWindow(display,windows->info.id);
+         clip_info.x=x;
+         clip_info.y=y;
+         break;
+       }
+       default:
+         break;
+     }
+   } while (!(state & ExitState));
+   XSelectInput(display,windows->image.id,windows->image.attributes.event_mask);
+   if (state & EscapeState)
+     {
+       /*
+         User want to exit without cropping.
+       */
+       XWithdrawWindow(display,windows->info.id,windows->info.screen);
+       XFreeCursor(display,cursor);
+       return(True);
+     }
+   /*
+     Size rectangle as pointer moves until the mouse button is released.
+   */
+   state=DefaultState;
+   (void) sprintf(text," %ux%u+%u+%u ",windows->image.width,
+     windows->image.height,windows->image.width,windows->image.height);
+   XSetWindowExtents(display,&windows->info,text);
+   x=clip_info.x;
+   y=clip_info.y;
+   clip_info.width=0;
+   clip_info.height=0;
+   XSetFunction(display,windows->image.highlight_context,GXinvert);
+   XSelectInput(display,windows->image.id,windows->image.attributes.event_mask |
+     PointerMotionMask);
+   do
+   {
+     if ((clip_info.width > 3) && (clip_info.height > 3))
+       {
+         /*
+           Display info and draw clipping rectangle.
+         */
+         if (!windows->info.mapped)
+           XMapWindow(display,windows->info.id);
+         (void) sprintf(text," %ux%u%+d%+d",clip_info.width,clip_info.height,
+           clip_info.x,clip_info.y);
+         XDisplayInfoString(display,&windows->info,text);
+         XHighlightRegion(display,windows->image.id,
+           windows->image.highlight_context,&clip_info);
+       }
+     else
+       if (windows->info.mapped)
+         XWithdrawWindow(display,windows->info.id,windows->info.screen);
+     /*
+       Wait for next event.
+     */
+     XIfEvent(display,&event,XScreenEvent,(char *) windows);
+     if ((clip_info.width > 3) && (clip_info.height > 3))
+       XHighlightRegion(display,windows->image.id,
+         windows->image.highlight_context,&clip_info);
+     switch (event.type)
+     {
+       case ButtonPress:
+         break;
+       case ButtonRelease:
+       {
+         /*
+           User has committed to clipping rectangle.
+         */
+         clip_info.x=event.xbutton.x;
+         clip_info.y=event.xbutton.y;
+         state|=ExitState;
+         break;
+       }
+       case Expose:
+         break;
+       case MotionNotify:
+       {
+         /*
+           Discard pending button motion events.
+         */
+         while (XCheckMaskEvent(display,ButtonMotionMask,&event));
+         clip_info.x=event.xmotion.x;
+         clip_info.y=event.xmotion.y;
+       }
+       default:
+         break;
+     }
+     if ((clip_info.x != x) || (clip_info.y != y))
+       {
+         /*
+           Check boundary conditions.
+         */
+         if (clip_info.x < 0)
+           clip_info.x=0;
+         else
+           if (clip_info.x > windows->image.width)
+             clip_info.x=windows->image.width;
+         if (clip_info.x < x)
+           clip_info.width=(unsigned int) (x-clip_info.x+1);
+         else
+           {
+             clip_info.width=(unsigned int) (clip_info.x-x+1);
+             clip_info.x=x;
+           }
+         if (clip_info.y < 0)
+           clip_info.y=0;
+         else
+           if (clip_info.y > windows->image.height)
+             clip_info.y=windows->image.height;
+         if (clip_info.y < y)
+           clip_info.height=(unsigned int) (y-clip_info.y+1);
+         else
+           {
+             clip_info.height=(unsigned int) (clip_info.y-y+1);
+             clip_info.y=y;
+           }
+       }
+   } while (!(state & ExitState));
+   XSelectInput(display,windows->image.id,windows->image.attributes.event_mask);
+   XDefineCursor(display,windows->image.id,windows->image.cursor);
+   XFreeCursor(display,cursor);
+   state=DefaultState;
+   do
+   {
+     if ((clip_info.width > 3) && (clip_info.height > 3))
+       {
+         /*
+           Display info and draw clipping rectangle.
+         */
+         if (!windows->info.mapped)
+           XMapWindow(display,windows->info.id);
+         (void) sprintf(text," %ux%u%+d%+d",clip_info.width,clip_info.height,
+           clip_info.x,clip_info.y);
+         XDisplayInfoString(display,&windows->info,text);
+         XHighlightRegion(display,windows->image.id,
+           windows->image.highlight_context,&clip_info);
+       }
+     else
+       if (windows->info.mapped)
+         XWithdrawWindow(display,windows->info.id,windows->info.screen);
+     /*
+       Wait for next event.
+     */
+     XIfEvent(display,&event,XScreenEvent,(char *) windows);
+     if ((clip_info.width > 3) && (clip_info.height > 3))
+       XHighlightRegion(display,windows->image.id,
+         windows->image.highlight_context,&clip_info);
+     switch (event.type)
+     {
+       case Expose:
+         break;
+       case KeyPress:
+       {
+         static char
+           command[MaxTextLength];
+ 
+         static KeySym
+           key_symbol;
+ 
+         /*
+           Respond to a user key press.
+         */
+         (void) XLookupString((XKeyEvent *) &event.xkey,command,sizeof(command),
+           &key_symbol,(XComposeStatus *) NULL);
+         switch (key_symbol)
+         {
+           case XK_Escape:
+           {
+             /*
+               Exit without cropping.
+             */
+             state|=EscapeState;
+             state|=ExitState;
+             break;
+           }
+           case XK_Return:
+           {
+             /*
+               Exit.
+             */
+             state|=ExitState;
+             break;
+           }
+           case XK_Up:
+           case XK_KP_Up:
+           {
+             if (event.xkey.state & Mod1Mask)
+               {
+                 clip_info.height--;
+                 break;
+               }
+             clip_info.y--;
+             clip_info.height++;
+             break;
+           }
+           case XK_Down:
+           case XK_KP_Down:
+           {
+             if (event.xkey.state & Mod1Mask)
+               {
+                 clip_info.y++;
+                 clip_info.height--;
+                 break;
+               }
+             clip_info.height++;
+             break;
+           }
+           case XK_Left:
+           case XK_KP_Left:
+           {
+             if (event.xkey.state & Mod1Mask)
+               {
+                 clip_info.width--;
+                 break;
+               }
+             clip_info.x--;
+             clip_info.width++;
+             break;
+           }
+           case XK_Right:
+           case XK_KP_Right:
+           {
+             if (event.xkey.state & Mod1Mask)
+               {
+                 clip_info.x++;
+                 clip_info.width--;
+                 break;
+               }
+             clip_info.width++;
+             break;
+           }
+           default:
+             break;
+         }
+         break;
+       }
+       case KeyRelease:
+         break;
+       default:
+         break;
+     }
+     /*
+       Check boundary conditions.
+     */
+     if (clip_info.x < 0)
+       clip_info.x=0;
+     else
+       if (clip_info.x > windows->image.width)
+         clip_info.x=windows->image.width;
+     if ((clip_info.x+clip_info.width) > windows->image.width)
+       clip_info.width=windows->image.width-clip_info.x;
+     if (clip_info.y < 0)
+       clip_info.y=0;
+     else
+       if (clip_info.y > windows->image.height)
+         clip_info.y=windows->image.height;
+     if ((clip_info.y+clip_info.height) > windows->image.height)
+       clip_info.height=windows->image.height-clip_info.y;
+   } while (!(state & ExitState));
+   XSetFunction(display,windows->image.highlight_context,GXcopy);
+   XWithdrawWindow(display,windows->info.id,windows->info.screen);
+   if (state & EscapeState)
+     return(True);
+   if ((clip_info.width > 3) && (clip_info.height > 3))
+     if ((clip_info.width != windows->image.width) ||
+         (clip_info.height != windows->image.height))
+       {
+         /*
+           Reconfigure image window as defined by clipping rectangle.
+         */
+         XSetClipGeometry(display,windows,&clip_info,image);
+         windows->image.window_changes.width=clip_info.width;
+         windows->image.window_changes.height=clip_info.height;
+         (void) XConfigureImageWindow(display,resource_info,windows,image);
+       }
+   return(True);
+ }
+ 
+ /*
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %                                                                             %
+ %                                                                             %
+ %                                                                             %
  %   X C o l o r E d i t I m a g e W i n d o w                                 %
  %                                                                             %
  %                                                                             %
***************
*** 1392,1399 ****
        "",
        "1    Press to select a pixel within an image window to",
        "     change its color.  Any pixel within an image that",
!       "     matches the color within the region you selected is",
!       "     recolored.",
        "",
        "2    Press and drag to select a pixel color from a pop-up",
        "     menu.  Choose from these pixel colors:",
--- 1840,1846 ----
        "",
        "1    Press to select a pixel within an image window to",
        "     change its color.  Any pixel within an image that",
!       "     matches the color of the selected pixel is recolored.",
        "",
        "2    Press and drag to select a pixel color from a pop-up",
        "     menu.  Choose from these pixel colors:",
***************
*** 1429,1436 ****
        "     that are considered candidates for recoloring.  The",
        "     factor is added then subtracted from each color",
        "     component of the pixel you choose with button 1.  Any",
!       "     pixel within the selected region that falls in this",
!       "     range is recolored.",
        "",
        "The actual color you request for the pixel is saved in the",
        "image.  However, the color that appears in your image window",
--- 1876,1883 ----
        "     that are considered candidates for recoloring.  The",
        "     factor is added then subtracted from each color",
        "     component of the pixel you choose with button 1.  Any",
!       "     pixel within an image that falls in this range is",
!       "     recolored.",
        "",
        "The actual color you request for the pixel is saved in the",
        "image.  However, the color that appears in your image window",
***************
*** 1456,1461 ****
--- 1903,1914 ----
      y,
      y_offset;
  
+   register RunlengthPacket
+     *p;
+ 
+   RunlengthPacket
+     pixel;
+ 
    static int
      delta = 0;
  
***************
*** 1709,1721 ****
            x,
            y;
  
-         register RunlengthPacket
-           *p,
-           *q;
- 
-         RunlengthPacket
-           target;
- 
          /*
            Pixel edit is relative to image configuration.
          */
--- 2162,2167 ----
***************
*** 1723,1777 ****
          y=0;
          width=image->columns;
          height=image->rows;
!         if (windows->image.crop_geometry != (char *) NULL)
!           (void) XParseGeometry(windows->image.crop_geometry,&x,&y,&width,
              &height);
          x_factor=UpShift(width)/windows->image.ximage->width;
!         x_offset=DownShift((windows->image.x+x_offset)*x_factor)+x;
          y_factor=UpShift(height)/windows->image.ximage->height;
!         y_offset=DownShift((windows->image.y+y_offset)*y_factor)+y;
          /*
!           Image must be DirectClass and uncompressed.
          */
!         image->class=DirectClass;
!         if (!UncompressImage(image))
!           break;
!         /*
!           Update matte information using flood fill algorithm.
!         */
!         p=image->pixels+(y_offset*image->columns+x_offset);
!         target=(*p);
!         color=windows->image.pixel_info->pen_color[pen_id];
!         for (y=y_offset ; y > 0; y--)
          {
!           p-=image->columns;
!           if (!FuzzyColorMatch(p,target,delta))
              break;
          }
!         p=image->pixels+(y*image->columns+x_offset);
!         for ( ; y < image->rows; y++)
!         {
!           if (!FuzzyColorMatch(p,target,delta))
!             break;
!           q=p;
!           for (x=x_offset ; x > 0; x--)
            {
!             q--;
!             if (!FuzzyColorMatch(q,target,delta))
!               break;
            }
!           q=image->pixels+(y*image->columns+x);
!           for ( ; x < image->columns; x++)
            {
!             if (!FuzzyColorMatch(q,target,delta))
!               break;
!             q->red=color.red >> 8;
!             q->green=color.green >> 8;
!             q->blue=color.blue >> 8;
!             q++;
            }
-           p+=image->columns;
-         }
          /*
            Update image colormap and return to color editing.
          */
--- 2169,2225 ----
          y=0;
          width=image->columns;
          height=image->rows;
!         if (windows->image.clip_geometry != (char *) NULL)
!           (void) XParseGeometry(windows->image.clip_geometry,&x,&y,&width,
              &height);
          x_factor=UpShift(width)/windows->image.ximage->width;
!         x_offset=DownShift((windows->image.x+x_offset+1)*x_factor)+x;
          y_factor=UpShift(height)/windows->image.ximage->height;
!         y_offset=DownShift((windows->image.y+y_offset+1)*y_factor)+y;
          /*
!           Update color of pixel.
          */
!         x=0;
!         p=image->pixels;
!         for (i=0; i < image->packets; i++)
          {
!           x+=(p->length+1);
!           if (x >= (y_offset*image->columns+x_offset))
              break;
+           p++;
          }
!         pixel=image->pixels[i];
!         color=windows->image.pixel_info->pen_color[pen_id];
!         if (image->class == DirectClass)
            {
!             p=image->pixels;
!             for (i=0; i < image->packets; i++)
!             {
!               if (((int) p->red > ((int) pixel.red-delta)) &&
!                   ((int) p->red < ((int) pixel.red+delta)) &&
!                   ((int) p->green > ((int) pixel.green-delta)) &&
!                   ((int) p->green < ((int) pixel.green+delta)) &&
!                   ((int) p->blue > ((int) pixel.blue-delta)) &&
!                   ((int) p->blue < ((int) pixel.blue+delta)))
!                 {
!                   p->red=color.red >> 8;
!                   p->green=color.green >> 8;
!                   p->blue=color.blue >> 8;
!                 }
!               p++;
!             }
            }
!         else
            {
!             register unsigned short
!               index;
! 
!             index=pixel.index;
!             image->colormap[index].red=color.red >> 8;
!             image->colormap[index].green=color.green >> 8;
!             image->colormap[index].blue=color.blue >> 8;
!             SyncImage(image);
            }
          /*
            Update image colormap and return to color editing.
          */
***************
*** 1898,1909 ****
        "         The overlap region is blank.",
        "",
        "plus     The result is just the sum of the image data.",
!       "         Output values are cropped to 255 (no overflow).",
        "         This operation is independent of the matte",
        "         channels.",
        "",
        "minus    The result of image - image window, with underflow",
!       "         cropped to zero.  The matte channel is ignored (set",
        "         to 255, full coverage).",
        "",
        "add      The result of image + image window, with overflow",
--- 2346,2357 ----
        "         The overlap region is blank.",
        "",
        "plus     The result is just the sum of the image data.",
!       "         Output values are clipped to 255 (no overflow).",
        "         This operation is independent of the matte",
        "         channels.",
        "",
        "minus    The result of image - image window, with underflow",
!       "         clipped to zero.  The matte channel is ignored (set",
        "         to 255, full coverage).",
        "",
        "add      The result of image + image window, with overflow",
***************
*** 1998,2003 ****
--- 2446,2452 ----
    if (*filename == '\0')
      return(True);
    XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
+   XCheckRefreshWindow(display,&windows->image);
    /*
      Read image.
    */
***************
*** 2221,2228 ****
    y=0;
    width=(*image)->columns;
    height=(*image)->rows;
!   if (windows->image.crop_geometry != (char *) NULL)
!     (void) XParseGeometry(windows->image.crop_geometry,&x,&y,&width,&height);
    scale_factor=UpShift(width)/windows->image.ximage->width;
    composite_info.x+=windows->image.x;
    composite_info.x=DownShift(composite_info.x*scale_factor);
--- 2670,2677 ----
    y=0;
    width=(*image)->columns;
    height=(*image)->rows;
!   if (windows->image.clip_geometry != (char *) NULL)
!     (void) XParseGeometry(windows->image.clip_geometry,&x,&y,&width,&height);
    scale_factor=UpShift(width)/windows->image.ximage->width;
    composite_info.x+=windows->image.x;
    composite_info.x=DownShift(composite_info.x*scale_factor);
***************
*** 2311,2319 ****
  {
  #define ConfigureColormapText  "  Configuring colormap...  "
  
-   Colormap
-     colormap;
- 
    /*
      Map info window.
    */
--- 2760,2765 ----
***************
*** 2327,2343 ****
    */
    XMakeStandardColormap(display,windows->image.visual_info,resource_info,
      image,windows->image.map_info,windows->image.pixel_info);
-   colormap=windows->image.map_info->colormap;
-   XSetWindowColormap(display,windows->image.id,colormap);
-   if (windows->magnify.mapped)
-     XSetWindowColormap(display,windows->magnify.id,colormap);
-   if (windows->pan.mapped)
-     XSetWindowColormap(display,windows->pan.id,colormap);
    XWithdrawWindow(display,windows->info.id,windows->info.screen);
    XDefineCursor(display,windows->image.id,windows->image.cursor);
    XCheckRefreshWindow(display,&windows->image);
    XClientMessage(display,windows->image.id,windows->im_protocols,
!     windows->im_update_colormap,CurrentTime);
  }
  
  /*
--- 2773,2783 ----
    */
    XMakeStandardColormap(display,windows->image.visual_info,resource_info,
      image,windows->image.map_info,windows->image.pixel_info);
    XWithdrawWindow(display,windows->info.id,windows->info.screen);
    XDefineCursor(display,windows->image.id,windows->image.cursor);
    XCheckRefreshWindow(display,&windows->image);
    XClientMessage(display,windows->image.id,windows->im_protocols,
!     windows->im_window_colormap,CurrentTime);
  }
  
  /*
***************
*** 2483,2492 ****
      XMakeMagnifyImage(display,windows);
    windows->image.x=DownShift(x_factor*windows->image.x);
    windows->image.y=DownShift(y_factor*windows->image.y);
!   windows->pan.crop_geometry=windows->image.crop_geometry;
    if (windows->pan.mapped)
      XMakePanImage(display,resource_info,windows,image);
!   windows->icon.crop_geometry=windows->image.crop_geometry;
    XWithdrawWindow(display,windows->info.id,windows->info.screen);
    XDefineCursor(display,windows->image.id,windows->image.cursor);
    return(status);
--- 2923,2932 ----
      XMakeMagnifyImage(display,windows);
    windows->image.x=DownShift(x_factor*windows->image.x);
    windows->image.y=DownShift(y_factor*windows->image.y);
!   windows->pan.clip_geometry=windows->image.clip_geometry;
    if (windows->pan.mapped)
      XMakePanImage(display,resource_info,windows,image);
!   windows->icon.clip_geometry=windows->image.clip_geometry;
    XWithdrawWindow(display,windows->info.id,windows->info.screen);
    XDefineCursor(display,windows->image.id,windows->image.cursor);
    return(status);
***************
*** 2497,2986 ****
  %                                                                             %
  %                                                                             %
  %                                                                             %
- %   X C r o p I m a g e W i n d o w                                           %
- %                                                                             %
- %                                                                             %
- %                                                                             %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- %  Function XCropImageWindow crops the image window.
- %
- %  The format of the XCropImageWindow routine is:
- %
- %    status=XCropImageWindow(display,resource_info,windows,image)
- %
- %  A description of each parameter follows:
- %
- %    o status: Function XCropImageWindow returns True if the image is
- %      cropped.  False is returned is there is a memory shortage or if the
- %      image fails to be cropped.
- %
- %    o display: Specifies a connection to an X server; returned from
- %      XOpenDisplay.
- %
- %    o resource_info: Specifies a pointer to a X11 XResourceInfo structure.
- %
- %    o windows: Specifies a pointer to a XWindows structure.
- %
- %    o image: Specifies a pointer to a Image structure; returned from
- %      ReadImage.
- %
- %
- */
- static unsigned int XCropImageWindow(display,resource_info,windows,image)
- Display
-   *display;
- 
- XResourceInfo
-   *resource_info;
- 
- XWindows
-   *windows;
- 
- Image
-   *image;
- {
-   static char
-     *ImageCropHelp[]=
-     {
-       "To define a cropping region, press button 1 and drag.  The",
-       "cropping region is defined by a highlighted rectangle that",
-       "expands or contracts as it follows the pointer.  Once you",
-       "are satisfied with the cropping region, release the button.",
-       "You can make adjustments to the cropping rectangle with the",
-       "arrow keys.  Press an arrow key to expand the region by",
-       "one pixel.  Press ALT and an arrow key to contract the",
-       "cropping region.",
-       "",
-       "Finally, press RETURN to commit your cropping region.  To",
-       "exit without cropping the image, press ESC.",
-       (char *) NULL,
-     };
- 
-   char
-     text[MaxTextLength];
- 
-   Cursor
-     cursor;
- 
-   int
-     i,
-     x,
-     y;
- 
-   RectangleInfo
-     crop_info;
- 
-   unsigned int
-     mask;
- 
-   unsigned long
-     state;
- 
-   Window
-     xwindow;
- 
-   XEvent
-     event;
- 
-   /*
-     Map info window.
-   */
-   state=DefaultState;
-   (void) sprintf(text," +%u+%u  ",windows->image.width,windows->image.height);
-   XSetWindowExtents(display,&windows->info,text);
-   XMapWindow(display,windows->info.id);
-   /*
-     Track pointer until button 1 is pressed.
-   */
-   XQueryPointer(display,windows->image.id,&xwindow,&xwindow,&i,&i,&x,&y,&mask);
-   crop_info.x=x;
-   crop_info.y=y;
-   crop_info.width=0;
-   crop_info.height=0;
-   cursor=XCreateFontCursor(display,XC_fleur);
-   XSelectInput(display,windows->image.id,windows->image.attributes.event_mask |
-     PointerMotionMask);
-   do
-   {
-     if (windows->info.mapped)
-       {
-         /*
-           Display pointer position.
-         */
-         (void) sprintf(text," %+d%+d ",x-windows->image.x,y-windows->image.y);
-         XDisplayInfoString(display,&windows->info,text);
-       }
-     /*
-       Wait for next event.
-     */
-     XIfEvent(display,&event,XScreenEvent,(char *) windows);
-     switch (event.type)
-     {
-       case ButtonPress:
-       {
-         if (event.xbutton.window == windows->pan.id)
-           {
-             XPanImageWindow(display,windows,&event);
-             XSetWindowExtents(display,&windows->info,text);
-             break;
-           }
-         if (event.xbutton.button == Button1)
-           {
-             /*
-               Note first corner of cropping rectangle-- exit loop.
-             */
-             XDefineCursor(display,windows->image.id,cursor);
-             crop_info.x=event.xbutton.x;
-             crop_info.y=event.xbutton.y;
-             state|=ExitState;
-             break;
-           }
-         break;
-       }
-       case Expose:
-         break;
-       case KeyPress:
-       {
-         static char
-           command[MaxTextLength];
- 
-         static KeySym
-           key_symbol;
- 
-         /*
-           Respond to a user key press.
-         */
-         (void) XLookupString((XKeyEvent *) &event.xkey,command,sizeof(command),
-           &key_symbol,(XComposeStatus *) NULL);
-         switch (key_symbol)
-         {
-           case XK_Escape:
-           {
-             /*
-               Prematurely exit.
-             */
-             state|=EscapeState;
-             state|=ExitState;
-             break;
-           }
-           case XK_F1:
-           case XK_Help:
-           {
-             XTextViewWidget(display,windows,"Help Viewer - Image Cropping",
-               ImageCropHelp);
-             break;
-           }
-           default:
-           {
-             XBell(display,0);
-             break;
-           }
-         }
-         break;
-       }
-       case MotionNotify:
-       {
-         /*
-           Discard pending pointer motion events.
-         */
-         while (XCheckMaskEvent(display,PointerMotionMask,&event));
-         x=event.xmotion.x;
-         y=event.xmotion.y;
-         /*
-           Map and unmap info window as text cursor crosses its boundaries.
-         */
-         if (windows->info.mapped)
-           {
-             if ((x < (windows->info.x+windows->info.width)) &&
-                 (y < (windows->info.y+windows->info.height)))
-               XWithdrawWindow(display,windows->info.id,windows->info.screen);
-           }
-         else
-           if ((x > (windows->info.x+windows->info.width)) ||
-               (y > (windows->info.y+windows->info.height)))
-             XMapWindow(display,windows->info.id);
-         crop_info.x=x;
-         crop_info.y=y;
-         break;
-       }
-       default:
-         break;
-     }
-   } while (!(state & ExitState));
-   XSelectInput(display,windows->image.id,windows->image.attributes.event_mask);
-   if (state & EscapeState)
-     {
-       /*
-         User want to exit without cropping.
-       */
-       XWithdrawWindow(display,windows->info.id,windows->info.screen);
-       XFreeCursor(display,cursor);
-       return(True);
-     }
-   /*
-     Size rectangle as pointer moves until the mouse button is released.
-   */
-   state=DefaultState;
-   (void) sprintf(text," %ux%u+%u+%u ",windows->image.width,
-     windows->image.height,windows->image.width,windows->image.height);
-   XSetWindowExtents(display,&windows->info,text);
-   x=crop_info.x;
-   y=crop_info.y;
-   crop_info.width=0;
-   crop_info.height=0;
-   XSetFunction(display,windows->image.highlight_context,GXinvert);
-   XSelectInput(display,windows->image.id,windows->image.attributes.event_mask |
-     PointerMotionMask);
-   do
-   {
-     if ((crop_info.width > 3) && (crop_info.height > 3))
-       {
-         /*
-           Display info and draw cropping rectangle.
-         */
-         if (!windows->info.mapped)
-           XMapWindow(display,windows->info.id);
-         (void) sprintf(text," %ux%u%+d%+d",crop_info.width,crop_info.height,
-           crop_info.x,crop_info.y);
-         XDisplayInfoString(display,&windows->info,text);
-         XHighlightRegion(display,windows->image.id,
-           windows->image.highlight_context,&crop_info);
-       }
-     else
-       if (windows->info.mapped)
-         XWithdrawWindow(display,windows->info.id,windows->info.screen);
-     /*
-       Wait for next event.
-     */
-     XIfEvent(display,&event,XScreenEvent,(char *) windows);
-     if ((crop_info.width > 3) && (crop_info.height > 3))
-       XHighlightRegion(display,windows->image.id,
-         windows->image.highlight_context,&crop_info);
-     switch (event.type)
-     {
-       case ButtonPress:
-         break;
-       case ButtonRelease:
-       {
-         /*
-           User has committed to cropping rectangle.
-         */
-         crop_info.x=event.xbutton.x;
-         crop_info.y=event.xbutton.y;
-         state|=ExitState;
-         break;
-       }
-       case Expose:
-         break;
-       case MotionNotify:
-       {
-         /*
-           Discard pending button motion events.
-         */
-         while (XCheckMaskEvent(display,ButtonMotionMask,&event));
-         crop_info.x=event.xmotion.x;
-         crop_info.y=event.xmotion.y;
-       }
-       default:
-         break;
-     }
-     if ((crop_info.x != x) || (crop_info.y != y))
-       {
-         /*
-           Check boundary conditions.
-         */
-         if (crop_info.x < 0)
-           crop_info.x=0;
-         else
-           if (crop_info.x > windows->image.width)
-             crop_info.x=windows->image.width;
-         if (crop_info.x < x)
-           crop_info.width=(unsigned int) (x-crop_info.x+1);
-         else
-           {
-             crop_info.width=(unsigned int) (crop_info.x-x+1);
-             crop_info.x=x;
-           }
-         if (crop_info.y < 0)
-           crop_info.y=0;
-         else
-           if (crop_info.y > windows->image.height)
-             crop_info.y=windows->image.height;
-         if (crop_info.y < y)
-           crop_info.height=(unsigned int) (y-crop_info.y+1);
-         else
-           {
-             crop_info.height=(unsigned int) (crop_info.y-y+1);
-             crop_info.y=y;
-           }
-       }
-   } while (!(state & ExitState));
-   XSelectInput(display,windows->image.id,windows->image.attributes.event_mask);
-   XDefineCursor(display,windows->image.id,windows->image.cursor);
-   XFreeCursor(display,cursor);
-   state=DefaultState;
-   do
-   {
-     if ((crop_info.width > 3) && (crop_info.height > 3))
-       {
-         /*
-           Display info and draw cropping rectangle.
-         */
-         if (!windows->info.mapped)
-           XMapWindow(display,windows->info.id);
-         (void) sprintf(text," %ux%u%+d%+d",crop_info.width,crop_info.height,
-           crop_info.x,crop_info.y);
-         XDisplayInfoString(display,&windows->info,text);
-         XHighlightRegion(display,windows->image.id,
-           windows->image.highlight_context,&crop_info);
-       }
-     else
-       if (windows->info.mapped)
-         XWithdrawWindow(display,windows->info.id,windows->info.screen);
-     /*
-       Wait for next event.
-     */
-     XIfEvent(display,&event,XScreenEvent,(char *) windows);
-     if ((crop_info.width > 3) && (crop_info.height > 3))
-       XHighlightRegion(display,windows->image.id,
-         windows->image.highlight_context,&crop_info);
-     switch (event.type)
-     {
-       case Expose:
-         break;
-       case KeyPress:
-       {
-         static char
-           command[MaxTextLength];
- 
-         static KeySym
-           key_symbol;
- 
-         /*
-           Respond to a user key press.
-         */
-         (void) XLookupString((XKeyEvent *) &event.xkey,command,sizeof(command),
-           &key_symbol,(XComposeStatus *) NULL);
-         switch (key_symbol)
-         {
-           case XK_Escape:
-           {
-             /*
-               Exit without cropping.
-             */
-             state|=EscapeState;
-             state|=ExitState;
-             break;
-           }
-           case XK_Return:
-           {
-             /*
-               Exit.
-             */
-             state|=ExitState;
-             break;
-           }
-           case XK_Up:
-           case XK_KP_Up:
-           {
-             if (event.xkey.state & Mod1Mask)
-               {
-                 crop_info.height--;
-                 break;
-               }
-             crop_info.y--;
-             crop_info.height++;
-             break;
-           }
-           case XK_Down:
-           case XK_KP_Down:
-           {
-             if (event.xkey.state & Mod1Mask)
-               {
-                 crop_info.y++;
-                 crop_info.height--;
-                 break;
-               }
-             crop_info.height++;
-             break;
-           }
-           case XK_Left:
-           case XK_KP_Left:
-           {
-             if (event.xkey.state & Mod1Mask)
-               {
-                 crop_info.width--;
-                 break;
-               }
-             crop_info.x--;
-             crop_info.width++;
-             break;
-           }
-           case XK_Right:
-           case XK_KP_Right:
-           {
-             if (event.xkey.state & Mod1Mask)
-               {
-                 crop_info.x++;
-                 crop_info.width--;
-                 break;
-               }
-             crop_info.width++;
-             break;
-           }
-           default:
-             break;
-         }
-         break;
-       }
-       case KeyRelease:
-         break;
-       default:
-         break;
-     }
-     /*
-       Check boundary conditions.
-     */
-     if (crop_info.x < 0)
-       crop_info.x=0;
-     else
-       if (crop_info.x > windows->image.width)
-         crop_info.x=windows->image.width;
-     if ((crop_info.x+crop_info.width) > windows->image.width)
-       crop_info.width=windows->image.width-crop_info.x;
-     if (crop_info.y < 0)
-       crop_info.y=0;
-     else
-       if (crop_info.y > windows->image.height)
-         crop_info.y=windows->image.height;
-     if ((crop_info.y+crop_info.height) > windows->image.height)
-       crop_info.height=windows->image.height-crop_info.y;
-   } while (!(state & ExitState));
-   XSetFunction(display,windows->image.highlight_context,GXcopy);
-   XWithdrawWindow(display,windows->info.id,windows->info.screen);
-   if (state & EscapeState)
-     return(True);
-   if ((crop_info.width > 3) && (crop_info.height > 3))
-     if ((crop_info.width != windows->image.width) ||
-         (crop_info.height != windows->image.height))
-       {
-         /*
-           Reconfigure image window as defined by cropping rectangle.
-         */
-         XSetCropGeometry(display,windows,&crop_info,image);
-         windows->image.window_changes.width=crop_info.width;
-         windows->image.window_changes.height=crop_info.height;
-         (void) XConfigureImageWindow(display,resource_info,windows,image);
-       }
-   return(True);
- }
- 
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %                                                                             %
- %                                                                             %
- %                                                                             %
  %   X C u t I m a g e W i n d o w                                             %
  %                                                                             %
  %                                                                             %
--- 2937,2942 ----
***************
*** 3361,3367 ****
    /*
      Image cutting is relative to image configuration.
    */
!   if ((windows->image.crop_geometry != (char *) NULL) ||
        ((*image)->columns != windows->image.ximage->width) ||
        ((*image)->rows != windows->image.ximage->height))
      {
--- 3317,3323 ----
    /*
      Image cutting is relative to image configuration.
    */
!   if ((windows->image.clip_geometry != (char *) NULL) ||
        ((*image)->columns != windows->image.ximage->width) ||
        ((*image)->rows != windows->image.ximage->height))
      {
***************
*** 3371,3383 ****
        /*
          Update image with user transforms.
        */
!       (void) sprintf(image_geometry,"%dx%d!",windows->image.ximage->width,
          windows->image.ximage->height);
!       TransformImage(image,windows->image.crop_geometry,image_geometry);
!       if (windows->image.crop_geometry != (char *) NULL)
          {
!           (void) free((char *) windows->image.crop_geometry);
!           windows->image.crop_geometry=(char *) NULL;
          }
        windows->image.x=0;
        windows->image.y=0;
--- 3327,3339 ----
        /*
          Update image with user transforms.
        */
!       (void) sprintf(image_geometry,"%dx%d",windows->image.ximage->width,
          windows->image.ximage->height);
!       TransformImage(image,windows->image.clip_geometry,image_geometry);
!       if (windows->image.clip_geometry != (char *) NULL)
          {
!           (void) free((char *) windows->image.clip_geometry);
!           windows->image.clip_geometry=(char *) NULL;
          }
        windows->image.x=0;
        windows->image.y=0;
***************
*** 3390,3397 ****
    y=0;
    width=(*image)->columns;
    height=(*image)->rows;
!   if (windows->image.crop_geometry != (char *) NULL)
!     (void) XParseGeometry(windows->image.crop_geometry,&x,&y,&width,&height);
    scale_factor=UpShift(width)/windows->image.ximage->width;
    cut_info.x+=windows->image.x;
    cut_info.x=DownShift(cut_info.x*scale_factor);
--- 3346,3353 ----
    y=0;
    width=(*image)->columns;
    height=(*image)->rows;
!   if (windows->image.clip_geometry != (char *) NULL)
!     (void) XParseGeometry(windows->image.clip_geometry,&x,&y,&width,&height);
    scale_factor=UpShift(width)/windows->image.ximage->width;
    cut_info.x+=windows->image.x;
    cut_info.x=DownShift(cut_info.x*scale_factor);
***************
*** 3849,3857 ****
    static XClassHint
      *class_hint;
  
-   static XFontStruct
-     *font_info;
- 
    static XImage
      former_ximage;
  
--- 3805,3810 ----
***************
*** 3876,3881 ****
--- 3829,3837 ----
    static XWindowInfo
      *magick_windows[MaxWindows];
  
+   static XWindows
+     *windows;
+ 
    static XWMHints
      *manager_hints;
  
***************
*** 3891,3902 ****
      update_time;
  
    unsigned int
!     scale_factor,
!     context_mask;
  
    XEvent
      event;
  
    XGCValues
      context_values;
  
--- 3847,3860 ----
      update_time;
  
    unsigned int
!     scale_factor;
  
    XEvent
      event;
  
+   XFontStruct
+     *font_info;
+ 
    XGCValues
      context_values;
  
***************
*** 3918,3927 ****
        map_info->colormap=(Colormap) NULL;
        icon_map->colormap=(Colormap) NULL;
        pixel_info.pixels=(unsigned long *) NULL;
-       pixel_info.annotate_context=(GC) NULL;
-       pixel_info.highlight_context=(GC) NULL;
-       pixel_info.widget_context=(GC) NULL;
-       font_info=(XFontStruct *) NULL;
        icon_pixel.pixels=(unsigned long *) NULL;
        /*
          Allocate visual.
--- 3876,3881 ----
***************
*** 3960,3989 ****
        windows->wm_delete_window=XInternAtom(display,"WM_DELETE_WINDOW",False);
        windows->wm_take_focus=XInternAtom(display,"WM_TAKE_FOCUS",False);
        windows->im_protocols=XInternAtom(display,"IM_PROTOCOLS",False);
!       windows->im_update_colormap=
          XInternAtom(display,"IM_UPDATE_COLORMAP",False);
        windows->im_former_image=XInternAtom(display,"IM_FORMER_IMAGE",False);
        windows->im_next_image=XInternAtom(display,"IM_NEXT_IMAGE",False);
        windows->im_exit=XInternAtom(display,"IM_EXIT",False);
-       if (resource_info->debug)
-         {
-           (void) fprintf(stderr,"Protocols:\n");
-           (void) fprintf(stderr,"  Window Manager: 0x%lx\n",
-             windows->wm_protocols);
-           (void) fprintf(stderr,"    delete window: 0x%lx\n",
-             windows->wm_delete_window);
-           (void) fprintf(stderr,"    take focus: 0x%lx\n",
-             windows->wm_take_focus);
-           (void) fprintf(stderr,"  ImageMagick: 0x%lx\n",
-             windows->im_protocols);
-           (void) fprintf(stderr,"    update colormap: 0x%lx\n",
-             windows->im_update_colormap);
-           (void) fprintf(stderr,"    former image: 0x%lx\n",
-             windows->im_former_image);
-           (void) fprintf(stderr,"    next image: 0x%lx\n",
-             windows->im_next_image);
-           (void) fprintf(stderr,"    exit: 0x%lx\n",windows->im_exit);
-         }
        /*
          Allocate class and manager hints.
        */
--- 3914,3924 ----
        windows->wm_delete_window=XInternAtom(display,"WM_DELETE_WINDOW",False);
        windows->wm_take_focus=XInternAtom(display,"WM_TAKE_FOCUS",False);
        windows->im_protocols=XInternAtom(display,"IM_PROTOCOLS",False);
!       windows->im_window_colormap=
          XInternAtom(display,"IM_UPDATE_COLORMAP",False);
        windows->im_former_image=XInternAtom(display,"IM_FORMER_IMAGE",False);
        windows->im_next_image=XInternAtom(display,"IM_NEXT_IMAGE",False);
        windows->im_exit=XInternAtom(display,"IM_EXIT",False);
        /*
          Allocate class and manager hints.
        */
***************
*** 4029,4036 ****
    /*
      Initialize font info.
    */
-   if (font_info != (XFontStruct *) NULL)
-     XFreeFont(display,font_info);
    font_info=XBestFont(display,resource_info);
    if (font_info == (XFontStruct *) NULL)
      Error("Unable to load font",resource_info->font);
--- 3964,3969 ----
***************
*** 4053,4070 ****
    context_values.font=font_info->fid;
    context_values.foreground=pixel_info.foreground_color.pixel;
    context_values.graphics_exposures=False;
!   if (pixel_info.annotate_context != (GC) NULL)
!     XFreeGC(display,pixel_info.annotate_context);
!   context_mask=GCBackground | GCFont | GCForeground | GCGraphicsExposures;
!   pixel_info.annotate_context=
!     XCreateGC(display,windows->context.id,context_mask,&context_values);
    if (pixel_info.annotate_context == (GC) NULL)
      Error("Unable to create graphic context",(char *) NULL);
    context_values.background=pixel_info.depth_color.pixel;
!   if (pixel_info.widget_context != (GC) NULL)
!     XFreeGC(display,pixel_info.widget_context);
!   pixel_info.widget_context=
!     XCreateGC(display,windows->context.id,context_mask,&context_values);
    if (pixel_info.widget_context == (GC) NULL)
      Error("Unable to create graphic context",(char *) NULL);
    context_values.background=pixel_info.foreground_color.pixel;
--- 3986,3998 ----
    context_values.font=font_info->fid;
    context_values.foreground=pixel_info.foreground_color.pixel;
    context_values.graphics_exposures=False;
!   pixel_info.annotate_context=XCreateGC(display,windows->context.id,
!     GCBackground | GCFont | GCForeground | GCGraphicsExposures,&context_values);
    if (pixel_info.annotate_context == (GC) NULL)
      Error("Unable to create graphic context",(char *) NULL);
    context_values.background=pixel_info.depth_color.pixel;
!   pixel_info.widget_context=XCreateGC(display,windows->context.id,
!     GCBackground | GCFont | GCForeground | GCGraphicsExposures,&context_values);
    if (pixel_info.widget_context == (GC) NULL)
      Error("Unable to create graphic context",(char *) NULL);
    context_values.background=pixel_info.foreground_color.pixel;
***************
*** 4071,4080 ****
    context_values.foreground=pixel_info.background_color.pixel;
    context_values.plane_mask=
      context_values.background ^ context_values.foreground;
-   if (pixel_info.highlight_context != (GC) NULL)
-     XFreeGC(display,pixel_info.highlight_context);
    pixel_info.highlight_context=XCreateGC(display,windows->context.id,
!     context_mask | GCPlaneMask,&context_values);
    if (pixel_info.highlight_context == (GC) NULL)
      Error("Unable to create graphic context",(char *) NULL);
    XDestroyWindow(display,windows->context.id);
--- 3999,4007 ----
    context_values.foreground=pixel_info.background_color.pixel;
    context_values.plane_mask=
      context_values.background ^ context_values.foreground;
    pixel_info.highlight_context=XCreateGC(display,windows->context.id,
!     GCBackground | GCFont | GCForeground | GCGraphicsExposures | GCPlaneMask,
!     &context_values);
    if (pixel_info.highlight_context == (GC) NULL)
      Error("Unable to create graphic context",(char *) NULL);
    XDestroyWindow(display,windows->context.id);
***************
*** 4108,4118 ****
    /*
      Initialize image window.
    */
-   if (windows->image.id != (Window) NULL)
-     {
-       (void) free((char *) windows->image.name);
-       (void) free((char *) windows->image.icon_name);
-     }
    XGetWindowInfo(display,visual_info,map_info,&pixel_info,font_info,
      resource_info,&windows->image);
    windows->image.name=(char *) malloc(MaxTextLength*sizeof(char));
--- 4035,4040 ----
***************
*** 4173,4179 ****
        windows->backdrop.attributes.do_not_propagate_mask=ButtonPressMask |
          ButtonReleaseMask;
        windows->backdrop.attributes.event_mask=ButtonPressMask | KeyPressMask |
!         StructureNotifyMask;
        windows->backdrop.attributes.override_redirect=True;
        class_hint->res_name="backdrop";
        manager_hints->flags=IconWindowHint | InputHint | StateHint;
--- 4095,4101 ----
        windows->backdrop.attributes.do_not_propagate_mask=ButtonPressMask |
          ButtonReleaseMask;
        windows->backdrop.attributes.event_mask=ButtonPressMask | KeyPressMask |
!         OwnerGrabButtonMask;
        windows->backdrop.attributes.override_redirect=True;
        class_hint->res_name="backdrop";
        manager_hints->flags=IconWindowHint | InputHint | StateHint;
***************
*** 4243,4249 ****
    windows->info.flags|=PPosition;
    windows->info.attributes.save_under=True;
    windows->info.attributes.win_gravity=UnmapGravity;
!   windows->info.attributes.event_mask=ButtonPressMask | StructureNotifyMask;
    class_hint->res_name="info";
    manager_hints->flags=InputHint | StateHint | WindowGroupHint;
    manager_hints->input=False;
--- 4165,4172 ----
    windows->info.flags|=PPosition;
    windows->info.attributes.save_under=True;
    windows->info.attributes.win_gravity=UnmapGravity;
!   windows->info.attributes.event_mask=ButtonPressMask | OwnerGrabButtonMask |
!     StructureNotifyMask;
    class_hint->res_name="info";
    manager_hints->flags=InputHint | StateHint | WindowGroupHint;
    manager_hints->input=False;
***************
*** 4256,4263 ****
    /*
      Initialize magnify window and cursor.
    */
-   if (windows->magnify.id != (Window) NULL)
-     (void) free((char *) windows->magnify.name);
    XGetWindowInfo(display,visual_info,map_info,&pixel_info,font_info,
      resource_info,&windows->magnify);
    windows->magnify.name=(char *) malloc(MaxTextLength*sizeof(char));
--- 4179,4184 ----
***************
*** 4309,4316 ****
    windows->pan.immutable=True;
    windows->pan.attributes.save_under=True;
    windows->pan.attributes.event_mask=ButtonMotionMask | ButtonPressMask |
!     ButtonReleaseMask | ExposureMask | KeyPressMask | KeyReleaseMask |
!     StructureNotifyMask;
    class_hint->res_name="pan";
    manager_hints->flags=InputHint | StateHint | WindowGroupHint;
    manager_hints->input=True;
--- 4230,4237 ----
    windows->pan.immutable=True;
    windows->pan.attributes.save_under=True;
    windows->pan.attributes.event_mask=ButtonMotionMask | ButtonPressMask |
!     ButtonReleaseMask | ExposureMask | OwnerGrabButtonMask | KeyPressMask |
!     KeyReleaseMask | StructureNotifyMask;
    class_hint->res_name="pan";
    manager_hints->flags=InputHint | StateHint | WindowGroupHint;
    manager_hints->input=True;
***************
*** 4355,4362 ****
    /*
      Initialize popup window.
    */
-   if (windows->popup.id != (Window) NULL)
-     (void) free((char *) windows->popup.name);
    XGetWindowInfo(display,visual_info,map_info,&pixel_info,font_info,
      resource_info,&windows->popup);
    windows->popup.name=(char *) malloc(MaxTextLength*sizeof(char));
--- 4276,4281 ----
***************
*** 4383,4389 ****
    windows->popup.shadow_stipple=XCreateBitmapFromData(display,
      windows->popup.id,(char *) ShadowBitmap,8,8);
    XSetTransientForHint(display,windows->popup.id,windows->image.id);
-   SetWarningHandler(XWarning);
    /*
      Respond to events.
    */
--- 4302,4307 ----
***************
*** 4575,4581 ****
              XPanImageWindow(display,windows,&event);
              break;
            }
-         timer=time((time_t *) NULL)+resource_info->delay;
          break;
        }
        case ClientMessage:
--- 4493,4498 ----
***************
*** 4586,4619 ****
              event.xclient.format,event.xclient.data.l[0]);
          if (event.xclient.message_type == windows->im_protocols)
            {
!             if (*event.xclient.data.l == windows->im_update_colormap)
                {
                  /*
!                   Update graphic context and window colormap.
                  */
                  for (i=0; i < number_windows; i++)
                  {
                    if (magick_windows[i]->id == windows->icon.id)
                      continue;
!                   context_values.background=pixel_info.background_color.pixel;
!                   context_values.foreground=pixel_info.foreground_color.pixel;
!                   XChangeGC(display,magick_windows[i]->annotate_context,
!                     context_mask,&context_values);
!                   XChangeGC(display,magick_windows[i]->widget_context,
!                     context_mask,&context_values);
!                   context_values.background=pixel_info.foreground_color.pixel;
!                   context_values.foreground=pixel_info.background_color.pixel;
!                   context_values.plane_mask=
!                     context_values.background ^ context_values.foreground;
!                   XChangeGC(display,magick_windows[i]->highlight_context,
!                     context_mask | GCPlaneMask,&context_values);
!                   magick_windows[i]->attributes.background_pixel=
!                     pixel_info.background_color.pixel;
!                   magick_windows[i]->attributes.border_pixel=
!                     pixel_info.border_color.pixel;
!                   magick_windows[i]->attributes.colormap=map_info->colormap;
!                   XChangeWindowAttributes(display,magick_windows[i]->id,
!                      magick_windows[i]->mask,&magick_windows[i]->attributes);
                  }
                  if (windows->backdrop.id != (Window) NULL)
                    XInstallColormap(display,map_info->colormap);
--- 4503,4531 ----
              event.xclient.format,event.xclient.data.l[0]);
          if (event.xclient.message_type == windows->im_protocols)
            {
!             if (*event.xclient.data.l == windows->im_window_colormap)
                {
                  /*
!                   Update window colormap and graphic context.
                  */
                  for (i=0; i < number_windows; i++)
                  {
                    if (magick_windows[i]->id == windows->icon.id)
                      continue;
!                   XSetWindowColormap(display,magick_windows[i]->id,
!                     map_info->colormap);
!                   XSetBackground(display,magick_windows[i]->annotate_context,
!                     pixel_info.background_color.pixel);
!                   XSetForeground(display,magick_windows[i]->annotate_context,
!                     pixel_info.foreground_color.pixel);
!                   XSetBackground(display,magick_windows[i]->widget_context,
!                     pixel_info.background_color.pixel);
!                   XSetForeground(display,magick_windows[i]->widget_context,
!                     pixel_info.foreground_color.pixel);
!                   XSetBackground(display,magick_windows[i]->highlight_context,
!                     pixel_info.foreground_color.pixel);
!                   XSetForeground(display,magick_windows[i]->highlight_context,
!                     pixel_info.background_color.pixel);
                  }
                  if (windows->backdrop.id != (Window) NULL)
                    XInstallColormap(display,map_info->colormap);
***************
*** 4833,4846 ****
          if (event.xkey.window == windows->magnify.id)
            XMagnifyWindowCommand(display,windows,key_symbol);
          if (event.xkey.window == windows->pan.id)
!           {
!             if (key_symbol == XK_q)
!               XWithdrawWindow(display,windows->pan.id,windows->pan.screen);
!             if ((key_symbol == XK_F1) || (key_symbol == XK_Help))
!               XTextViewWidget(display,windows,"Help Viewer - Image Panning",
!                 ImagePanHelp);
!           }
!         timer=time((time_t *) NULL)+resource_info->delay;
          break;
        }
        case KeyRelease:
--- 4745,4753 ----
          if (event.xkey.window == windows->magnify.id)
            XMagnifyWindowCommand(display,windows,key_symbol);
          if (event.xkey.window == windows->pan.id)
!           if ((key_symbol == XK_F1) || (key_symbol == XK_Help))
!             XTextViewWidget(display,windows,"Help Viewer - Image Panning",
!               ImagePanHelp);
          break;
        }
        case KeyRelease:
***************
*** 4869,4880 ****
        {
          if (resource_info->debug)
            (void) fprintf(stderr,"Map Notify: 0x%lx\n",event.xmap.window);
-         if (event.xbutton.window == windows->backdrop.id)
-           {
-             XSetInputFocus(display,event.xmap.window,RevertToParent,
-               CurrentTime);
-             break;
-           }
          if (event.xmap.window == windows->image.id)
            {
              if (windows->backdrop.id != (Window) NULL)
--- 4776,4781 ----
***************
*** 4995,5001 ****
        /*
          Update image with user transforms.
        */
!       if ((windows->image.crop_geometry != (char *) NULL) ||
            (displayed_image->columns != windows->image.ximage->width) ||
            (displayed_image->rows != windows->image.ximage->height))
          {
--- 4896,4902 ----
        /*
          Update image with user transforms.
        */
!       if ((windows->image.clip_geometry != (char *) NULL) ||
            (displayed_image->columns != windows->image.ximage->width) ||
            (displayed_image->rows != windows->image.ximage->height))
          {
***************
*** 5003,5013 ****
              image_geometry[MaxTextLength];
  
            /*
!             Crop and/or scale displayed image.
            */
!           (void) sprintf(image_geometry,"%dx%d!",windows->image.ximage->width,
              windows->image.ximage->height);
!           TransformImage(&displayed_image,windows->image.crop_geometry,
              image_geometry);
          }
        if (resource_info->number_colors != 0)
--- 4904,4914 ----
              image_geometry[MaxTextLength];
  
            /*
!             Clip and/or scale displayed image.
            */
!           (void) sprintf(image_geometry,"%dx%d",windows->image.ximage->width,
              windows->image.ximage->height);
!           TransformImage(&displayed_image,windows->image.clip_geometry,
              image_geometry);
          }
        if (resource_info->number_colors != 0)
***************
*** 5032,5037 ****
--- 4933,4958 ----
    if (windows->magnify.mapped)
      XWithdrawWindow(display,windows->magnify.id,windows->magnify.screen);
    XCheckRefreshWindow(display,&windows->image);
+   /*
+     Free X resources.
+   */
+   (void) free((char *) windows->popup.name);
+   (void) free((char *) windows->magnify.name);
+   (void) free((char *) windows->image.name);
+   (void) free((char *) windows->image.icon_name);
+   for (i=0; i < number_windows; i++)
+   {
+     XFreeCursor(display,magick_windows[i]->cursor);
+     XFreeCursor(display,magick_windows[i]->busy_cursor);
+   }
+   if (windows->popup.highlight_stipple != (Pixmap) NULL)
+     XFreePixmap(display,windows->popup.highlight_stipple);
+   if (windows->popup.highlight_stipple != (Pixmap) NULL)
+     XFreePixmap(display,windows->popup.shadow_stipple);
+   XFreeGC(display,pixel_info.highlight_context);
+   XFreeGC(display,pixel_info.widget_context);
+   XFreeGC(display,pixel_info.annotate_context);
+   XFreeFont(display,font_info);
    if (*state & ExitState)
      {
        /*
***************
*** 5130,5214 ****
  %                                                                             %
  %                                                                             %
  %                                                                             %
- %   X E m b o s s I m a g e W i n d o w                                       %
- %                                                                             %
- %                                                                             %
- %                                                                             %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- %  Function XEmbossImageWindow embosses an image.
- %
- %  The format of the XEmbossImageWindow routine is:
- %
- %    status=XEmbossImageWindow(display,resource_info,windows,image)
- %
- %  A description of each parameter follows:
- %
- %    o status: Function XEmbossImageWindow return True if the edges within
- %      the image are detected.  False is returned is there is a memory
- %      shortage or if the edges cannot be detected.
- %
- %    o display: Specifies a connection to an X server; returned from
- %      XOpenDisplay.
- %
- %    o resource_info: Specifies a pointer to a X11 XResourceInfo structure.
- %
- %    o windows: Specifies a pointer to a XWindows structure.
- %
- %    o image: Specifies a pointer to a Image structure;  returned from
- %      ReadImage.
- %
- %
- */
- static unsigned int XEmbossImageWindow(display,resource_info,windows,image)
- Display
-   *display;
- 
- XResourceInfo
-   *resource_info;
- 
- XWindows
-   *windows;
- 
- Image
-   **image;
- {
- #define EmbossImageText  "  Emboss image...  "
- 
-   Image
-     *embossed_image;
- 
-   /*
-     Map info window.
-   */
-   XSetWindowExtents(display,&windows->info,EmbossImageText);
-   XMapWindow(display,windows->info.id);
-   XDisplayInfoString(display,&windows->info,EmbossImageText);
-   /*
-     Emboss image scanlines.
-   */
-   XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
-   XFlush(display);
-   embossed_image=EmbossImage(*image);
-   XDefineCursor(display,windows->image.id,windows->image.cursor);
-   XWithdrawWindow(display,windows->info.id,windows->info.screen);
-   if (embossed_image == (Image *) NULL)
-     return(False);
-   DestroyImage(*image);
-   *image=embossed_image;
-   /*
-     Update image configuration.
-   */
-   XConfigureImageColormap(display,resource_info,windows,*image);
-   (void) XConfigureImageWindow(display,resource_info,windows,*image);
-   return(True);
- }
- 
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %                                                                             %
- %                                                                             %
- %                                                                             %
  %   X E d g e I m a g e W i n d o w                                           %
  %                                                                             %
  %                                                                             %
--- 5051,5056 ----
***************
*** 5355,5361 ****
      return(False);
    DestroyImage(*image);
    *image=flipped_image;
!   if (windows->image.crop_geometry != (char *) NULL)
      {
        int
          x,
--- 5197,5203 ----
      return(False);
    DestroyImage(*image);
    *image=flipped_image;
!   if (windows->image.clip_geometry != (char *) NULL)
      {
        int
          x,
***************
*** 5366,5375 ****
          width;
  
        /*
!         Flip crop geometry.
        */
!       (void) XParseGeometry(windows->image.crop_geometry,&x,&y,&width,&height);
!       (void) sprintf(windows->image.crop_geometry,"%ux%u%+d%+d",width,height,
          x,(int) (*image)->rows-(int) height-y);
      }
    /*
--- 5208,5217 ----
          width;
  
        /*
!         Flip clip geometry.
        */
!       (void) XParseGeometry(windows->image.clip_geometry,&x,&y,&width,&height);
!       (void) sprintf(windows->image.clip_geometry,"%ux%u%+d%+d",width,height,
          x,(int) (*image)->rows-(int) height-y);
      }
    /*
***************
*** 5451,5457 ****
      return(False);
    DestroyImage(*image);
    *image=flopped_image;
!   if (windows->image.crop_geometry != (char *) NULL)
      {
        int
          x,
--- 5293,5299 ----
      return(False);
    DestroyImage(*image);
    *image=flopped_image;
!   if (windows->image.clip_geometry != (char *) NULL)
      {
        int
          x,
***************
*** 5462,5471 ****
          width;
  
        /*
!         Flop crop geometry.
        */
!       (void) XParseGeometry(windows->image.crop_geometry,&x,&y,&width,&height);
!       (void) sprintf(windows->image.crop_geometry,"%ux%u%+d%+d",width,height,
          (int) (*image)->columns-(int) width-x,y);
      }
    /*
--- 5304,5313 ----
          width;
  
        /*
!         Flop clip geometry.
        */
!       (void) XParseGeometry(windows->image.clip_geometry,&x,&y,&width,&height);
!       (void) sprintf(windows->image.clip_geometry,"%ux%u%+d%+d",width,height,
          (int) (*image)->columns-(int) width-x,y);
      }
    /*
***************
*** 5544,5549 ****
--- 5386,5392 ----
    XMapWindow(display,windows->info.id);
    XDisplayInfoString(display,&windows->info,LoadImageText);
    XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
+   XCheckRefreshWindow(display,&windows->image);
    /*
      Load the image.
    */
***************
*** 5695,5701 ****
        height;
  
      char
!       *crop_geometry;
  
      Image
        *image;
--- 5538,5544 ----
        height;
  
      char
!       *clip_geometry;
  
      Image
        *image;
***************
*** 5724,5742 ****
        "              Load...",
        "              Next",
        "              Former",
-       "              Quicken",
        "            Edit",
        "              Undo",
        "              Restore",
        "              Refresh",
!       "            Size",
        "              Half Size",
        "              Original Size",
        "              Double Size",
        "              Resize...",
!       "            Pixel Transform",
        "              Trim Edges",
!       "              Crop",
        "              Cut",
        "              Flop",
        "              Flip",
--- 5567,5584 ----
        "              Load...",
        "              Next",
        "              Former",
        "            Edit",
        "              Undo",
        "              Restore",
        "              Refresh",
!       "            View",
        "              Half Size",
        "              Original Size",
        "              Double Size",
        "              Resize...",
!       "            Transform",
        "              Trim Edges",
!       "              Clip",
        "              Cut",
        "              Flop",
        "              Flip",
***************
*** 5744,5759 ****
        "              Rotate Left",
        "              Rotate...",
        "              Shear...",
!       "            Color Enhance",
!       "              Brighten",
!       "              Darken",
!       "              Gamma...",
!       "              Spiff",
!       "              Dull",
!       "              Saturate...",
        "              Equalize",
        "              Normalize",
!       "              Negate",
        "            Effects",
        "              Despeckle",
        "              Peak Noisy",
--- 5586,5596 ----
        "              Rotate Left",
        "              Rotate...",
        "              Shear...",
!       "            Enhance",
!       "              Negate",
        "              Equalize",
        "              Normalize",
!       "              Gamma...",
        "            Effects",
        "              Despeckle",
        "              Peak Noisy",
***************
*** 5760,5766 ****
        "              Sharpen",
        "              Blur",
        "              Edge Detect",
-       "              Emboss",
        "              Grayscale",
        "              Quantize...",
        "            Image Edit",
--- 5597,5602 ----
***************
*** 5804,5811 ****
        "",
        "   f    Press to display the former image.",
        "",
-       "   Q    Press to display the next image after pausing.",
-       "",
        "   u    Press to undo last image transformation.",
        "",
        "   r    Press to restore the image to its original size.",
--- 5640,5645 ----
***************
*** 5812,5819 ****
        "",
        "   @    Press to refresh the image window.",
        "",
-       "   F7   Press to toggle the colormap type: Shared or Private.",
-       "",
        "   <    Press to half the image size.",
        "",
        "   o    Press to return to the original image size",
--- 5646,5651 ----
***************
*** 5843,5865 ****
        "   s    Press to shear the image the number of degrees you",
        "        specify.",
        "",
!       "   F8   Press to brighten the image.",
!       "",
!       "   F9   Press to darken the image.",
!       "",
!       "   g    Press to gamma correct the image.",
!       "",
!       "   F10  Press to sharpen the image contrast.",
!       "",
!       "   F11  Press to dull the image contrast.",
!       "",
!       "   F12  Press to increase or decrease the color saturation",
        "",
        "   =    Press to perform histogram equalization on the image.",
        "",
        "   N    Press to perform histogram normalization on the image",
        "",
!       "   ~    Press to invert the colors of the image.",
        "",
        "   D    Press to reduce the speckles within an image.",
        "",
--- 5675,5687 ----
        "   s    Press to shear the image the number of degrees you",
        "        specify.",
        "",
!       "   ~    Press to invert the colors of the image.",
        "",
        "   =    Press to perform histogram equalization on the image.",
        "",
        "   N    Press to perform histogram normalization on the image",
        "",
!       "   g    Press to gamma correct the image.",
        "",
        "   D    Press to reduce the speckles within an image.",
        "",
***************
*** 5871,5881 ****
        "",
        "   E    Press to detect edges within an image.",
        "",
-       "   M    Press to detect emboss an image.",
-       "",
        "   G    Press to convert the image colors to gray.",
        "",
!       "   #    Press to set the maximum number of unique colors in the",
        "        image.",
        "",
        "   a    Press to annotate the image with text.",
--- 5693,5701 ----
        "",
        "   E    Press to detect edges within an image.",
        "",
        "   G    Press to convert the image colors to gray.",
        "",
!       "   Q    Press to set the maximum number of unique colors in the",
        "        image.",
        "",
        "   a    Press to annotate the image with text.",
***************
*** 5888,5894 ****
        "",
        "   m    Press to edit the image matte information.",
        "",
!       "   !    Press to add an image comment.",
        "",
        "   h    Press to display helpful information about display(1).",
        "",
--- 5708,5714 ----
        "",
        "   m    Press to edit the image matte information.",
        "",
!       "   #    Press to add an image comment.",
        "",
        "   h    Press to display helpful information about display(1).",
        "",
***************
*** 5922,5928 ****
      status;
  
    XCheckRefreshWindow(display,&windows->image);
!   if ((key_symbol == XK_u) || (key_symbol == XK_Undo))
      {
        /*
          Undo the last image transformation.
--- 5742,5748 ----
      status;
  
    XCheckRefreshWindow(display,&windows->image);
!   if (key_symbol == XK_u)
      {
        /*
          Undo the last image transformation.
***************
*** 5934,5947 ****
          }
        windows->image.window_changes.width=undo_image.width;
        windows->image.window_changes.height=undo_image.height;
!       if (windows->image.crop_geometry != (char *) NULL)
!         (void) free((char *) windows->image.crop_geometry);
!       windows->image.crop_geometry=undo_image.crop_geometry;
        DestroyImage(*image);
        *image=undo_image.image;
        XConfigureImageColormap(display,resource_info,windows,*image);
        (void) XConfigureImageWindow(display,resource_info,windows,*image);
!       undo_image.crop_geometry=(char *) NULL;
        undo_image.image=(Image *) NULL;
        return((Image *) NULL);
      }
--- 5754,5767 ----
          }
        windows->image.window_changes.width=undo_image.width;
        windows->image.window_changes.height=undo_image.height;
!       if (windows->image.clip_geometry != (char *) NULL)
!         (void) free((char *) windows->image.clip_geometry);
!       windows->image.clip_geometry=undo_image.clip_geometry;
        DestroyImage(*image);
        *image=undo_image.image;
        XConfigureImageColormap(display,resource_info,windows,*image);
        (void) XConfigureImageWindow(display,resource_info,windows,*image);
!       undo_image.clip_geometry=(char *) NULL;
        undo_image.image=(Image *) NULL;
        return((Image *) NULL);
      }
***************
*** 5962,5987 ****
      case XK_asciitilde:
      case XK_equal:
      case XK_N:
-     case XK_F8:
-     case XK_F9:
      case XK_g:
-     case XK_F10:
-     case XK_F11:
-     case XK_F12:
      case XK_D:
      case XK_P:
      case XK_S:
      case XK_B:
      case XK_E:
-     case XK_M:
      case XK_G:
!     case XK_numbersign:
      case XK_a:
      case XK_b:
      case XK_x:
      case XK_c:
      case XK_m:
-     case XK_exclam:
      {
        /*
          Save image before transformation.
--- 5782,5800 ----
      case XK_asciitilde:
      case XK_equal:
      case XK_N:
      case XK_g:
      case XK_D:
      case XK_P:
      case XK_S:
      case XK_B:
      case XK_E:
      case XK_G:
!     case XK_Q:
      case XK_a:
      case XK_b:
      case XK_x:
      case XK_c:
      case XK_m:
      {
        /*
          Save image before transformation.
***************
*** 5990,6004 ****
        XFlush(display);
        undo_image.width=windows->image.ximage->width;
        undo_image.height=windows->image.ximage->height;
!       if (undo_image.crop_geometry != (char *) NULL)
!         (void) free((char *) undo_image.crop_geometry);
!       undo_image.crop_geometry=windows->image.crop_geometry;
!       if (windows->image.crop_geometry != (char *) NULL)
!         {
!           undo_image.crop_geometry=(char *) malloc(MaxTextLength*sizeof(char));
!           if (undo_image.crop_geometry != (char *) NULL)
!             (void) strcpy(undo_image.crop_geometry,
!               windows->image.crop_geometry);
          }
        if (undo_image.image != (Image *) NULL)
          DestroyImage(undo_image.image);
--- 5803,5817 ----
        XFlush(display);
        undo_image.width=windows->image.ximage->width;
        undo_image.height=windows->image.ximage->height;
!       if (undo_image.clip_geometry != (char *) NULL)
!         (void) free((char *) undo_image.clip_geometry);
!       undo_image.clip_geometry=windows->image.clip_geometry;
!       if (windows->image.clip_geometry != (char *) NULL)
!         {
!           undo_image.clip_geometry=(char *) malloc(MaxTextLength*sizeof(char));
!           if (undo_image.clip_geometry != (char *) NULL)
!             (void) strcpy(undo_image.clip_geometry,
!               windows->image.clip_geometry);
          }
        if (undo_image.image != (Image *) NULL)
          DestroyImage(undo_image.image);
***************
*** 6048,6065 ****
        (void) sprintf(text,"%s  depth: %d\n",text,windows->image.depth);
        (void) sprintf(text,"%s  geometry: %dx%d\n",text,
          windows->image.ximage->width,windows->image.ximage->height);
!       if (windows->image.crop_geometry != (char *) NULL)
!         (void) sprintf(text,"%s  crop geometry: %s\n",text,
!           windows->image.crop_geometry);
!       if (resource_info->colormap== SharedColormap)
!         (void) strcat(text,"  colormap type: Shared\n");
!       else
!         (void) strcat(text,"  colormap type: Private\n");
!       (void) strcat(text,"\n");
!       (void) sprintf(text,"%sImage\n  file: %s\n",text,(*image)->filename);
!       (void) sprintf(text,"%s  format: %s\n",text,(*image)->magick);
!       if ((*image)->filesize != 0)
!         (void) sprintf(text,"%s  bytes: %ld\n",text,(*image)->filesize);
        if ((*image)->class == DirectClass)
          (void) strcat(text,"  class: DirectClass\n");
        else
--- 5861,5870 ----
        (void) sprintf(text,"%s  depth: %d\n",text,windows->image.depth);
        (void) sprintf(text,"%s  geometry: %dx%d\n",text,
          windows->image.ximage->width,windows->image.ximage->height);
!       if (windows->image.clip_geometry != (char *) NULL)
!         (void) sprintf(text,"%s  clip geometry: %s\n",text,
!           windows->image.clip_geometry);
!       (void) sprintf(text,"%sImage\n  format: %s\n",text,(*image)->magick);
        if ((*image)->class == DirectClass)
          (void) strcat(text,"  class: DirectClass\n");
        else
***************
*** 6174,6216 ****
          windows->im_former_image,CurrentTime);
        break;
      }
-     case XK_Q:
-     {
-       char
-         delay[MaxTextLength];
- 
-       /*
-         Quicken images.
-       */
-       resource_info->delay=0;
-       XDialogWidget(display,windows,"Quicken",
-         "Pause how many seconds between images:",delay);
-       if (*delay == '\0')
-         break;
-       resource_info->delay=atoi(delay);
-       XClientMessage(display,windows->image.id,windows->im_protocols,
-         windows->im_next_image,CurrentTime);
-       break;
-     }
-     case XK_F7:
-     {
-       /*
-         Toggle X colormap type: Shared or Private.
-       */
-       if (resource_info->colormap == SharedColormap)
-         {
-           resource_info->colormap=PrivateColormap;
-           XNoticeWidget(display,windows,"X Colormap Type:","Private");
-         }
-       else
-         {
-           resource_info->colormap=SharedColormap;
-           XNoticeWidget(display,windows,"X Colormap Type:","Shared");
-         }
-       XConfigureImageColormap(display,resource_info,windows,*image);
-       (void) XConfigureImageWindow(display,resource_info,windows,*image);
-       break;
-     }
      case XK_less:
      {
        /*
--- 5979,5984 ----
***************
*** 6270,6276 ****
        */
        if ((windows->image.width == (*image)->columns) &&
            (windows->image.height == (*image)->rows) &&
!           (windows->image.crop_geometry == (char *) NULL))
          {
            XBell(display,0);
            break;
--- 6038,6044 ----
        */
        if ((windows->image.width == (*image)->columns) &&
            (windows->image.height == (*image)->rows) &&
!           (windows->image.clip_geometry == (char *) NULL))
          {
            XBell(display,0);
            break;
***************
*** 6277,6286 ****
          }
        windows->image.window_changes.width=(*image)->columns;
        windows->image.window_changes.height=(*image)->rows;
!       if (windows->image.crop_geometry != (char *) NULL)
          {
!           (void) free((char *) windows->image.crop_geometry);
!           windows->image.crop_geometry=(char *) NULL;
            windows->image.x=0;
            windows->image.y=0;
          }
--- 6045,6054 ----
          }
        windows->image.window_changes.width=(*image)->columns;
        windows->image.window_changes.height=(*image)->rows;
!       if (windows->image.clip_geometry != (char *) NULL)
          {
!           (void) free((char *) windows->image.clip_geometry);
!           windows->image.clip_geometry=(char *) NULL;
            windows->image.x=0;
            windows->image.y=0;
          }
***************
*** 6309,6317 ****
      case XK_bracketleft:
      {
        /*
!         Crop image.
        */
!       (void) XCropImageWindow(display,resource_info,windows,*image);
        break;
      }
      case XK_bracketright:
--- 6077,6085 ----
      case XK_bracketleft:
      {
        /*
!         Clip image.
        */
!       (void) XClipImageWindow(display,resource_info,windows,*image);
        break;
      }
      case XK_bracketright:
***************
*** 6418,6424 ****
          Negate colors in image.
        */
        XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
!       XFlush(display);
        NegateImage(*image);
        XDefineCursor(display,windows->image.id,windows->image.cursor);
        XConfigureImageColormap(display,resource_info,windows,*image);
--- 6186,6192 ----
          Negate colors in image.
        */
        XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
!       XCheckRefreshWindow(display,&windows->image);
        NegateImage(*image);
        XDefineCursor(display,windows->image.id,windows->image.cursor);
        XConfigureImageColormap(display,resource_info,windows,*image);
***************
*** 6431,6437 ****
          Perform histogram equalization on the image.
        */
        XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
!       XFlush(display);
        EqualizeImage(*image);
        XDefineCursor(display,windows->image.id,windows->image.cursor);
        XConfigureImageColormap(display,resource_info,windows,*image);
--- 6199,6205 ----
          Perform histogram equalization on the image.
        */
        XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
!       XCheckRefreshWindow(display,&windows->image);
        EqualizeImage(*image);
        XDefineCursor(display,windows->image.id,windows->image.cursor);
        XConfigureImageColormap(display,resource_info,windows,*image);
***************
*** 6444,6450 ****
          Perform histogram normalization on the image.
        */
        XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
!       XFlush(display);
        NormalizeImage(*image);
        XDefineCursor(display,windows->image.id,windows->image.cursor);
        XConfigureImageColormap(display,resource_info,windows,*image);
--- 6212,6218 ----
          Perform histogram normalization on the image.
        */
        XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
!       XCheckRefreshWindow(display,&windows->image);
        NormalizeImage(*image);
        XDefineCursor(display,windows->image.id,windows->image.cursor);
        XConfigureImageColormap(display,resource_info,windows,*image);
***************
*** 6451,6470 ****
        (void) XConfigureImageWindow(display,resource_info,windows,*image);
        break;
      }
-     case XK_F8:
-     case XK_F9:
-     {
-       /*
-         Brighten the image.
-       */
-       XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
-       XFlush(display);
-       GammaImage(*image,key_symbol == XK_F8 ? "1.25" : "0.75");
-       XDefineCursor(display,windows->image.id,windows->image.cursor);
-       XConfigureImageColormap(display,resource_info,windows,*image);
-       (void) XConfigureImageWindow(display,resource_info,windows,*image);
-       break;
-     }
      case XK_g:
      {
        static char
--- 6219,6224 ----
***************
*** 6477,6483 ****
        if (*gamma == '\0')
          break;
        XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
!       XFlush(display);
        GammaImage(*image,gamma);
        XDefineCursor(display,windows->image.id,windows->image.cursor);
        XConfigureImageColormap(display,resource_info,windows,*image);
--- 6231,6237 ----
        if (*gamma == '\0')
          break;
        XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
!       XCheckRefreshWindow(display,&windows->image);
        GammaImage(*image,gamma);
        XDefineCursor(display,windows->image.id,windows->image.cursor);
        XConfigureImageColormap(display,resource_info,windows,*image);
***************
*** 6484,6523 ****
        (void) XConfigureImageWindow(display,resource_info,windows,*image);
        break;
      }
-     case XK_F10:
-     case XK_F11:
-     {
-       /*
-         Sharpen the image contrast.
-       */
-       XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
-       XFlush(display);
-       ContrastImage(*image,key_symbol == XK_F10);
-       XDefineCursor(display,windows->image.id,windows->image.cursor);
-       XConfigureImageColormap(display,resource_info,windows,*image);
-       (void) XConfigureImageWindow(display,resource_info,windows,*image);
-       break;
-     }
-     case XK_F12:
-     {
-       static char
-         saturate[MaxTextLength] = "20";
- 
-       /*
-         Increase or decrease the color saturation
-       */
-       XDialogWidget(display,windows,"Saturate",
-         "Enter percent change in color saturation:",saturate);
-       if (*saturate == '\0')
-         break;
-       XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
-       XFlush(display);
-       SaturateImage(*image,atoi(saturate));
-       XDefineCursor(display,windows->image.id,windows->image.cursor);
-       XConfigureImageColormap(display,resource_info,windows,*image);
-       (void) XConfigureImageWindow(display,resource_info,windows,*image);
-       break;
-     }
      case XK_D:
      {
        /*
--- 6238,6243 ----
***************
*** 6588,6607 ****
          }
        break;
      }
-     case XK_M:
-     {
-       /*
-         Emboss an image.
-       */
-       status=XEmbossImageWindow(display,resource_info,windows,image);
-       if (status == False)
-         {
-           XNoticeWidget(display,windows,"Unable to emboss image",
-             (*image)->filename);
-           break;
-         }
-       break;
-     }
      case XK_G:
      {
        /*
--- 6308,6313 ----
***************
*** 6608,6614 ****
          Convert image to grayscale.
        */
        XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
!       XFlush(display);
        QuantizeImage(*image,256,8,resource_info->dither,GRAYColorspace,True);
        XDefineCursor(display,windows->image.id,windows->image.cursor);
        XConfigureImageColormap(display,resource_info,windows,*image);
--- 6314,6320 ----
          Convert image to grayscale.
        */
        XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
!       XCheckRefreshWindow(display,&windows->image);
        QuantizeImage(*image,256,8,resource_info->dither,GRAYColorspace,True);
        XDefineCursor(display,windows->image.id,windows->image.cursor);
        XConfigureImageColormap(display,resource_info,windows,*image);
***************
*** 6615,6621 ****
        (void) XConfigureImageWindow(display,resource_info,windows,*image);
        break;
      }
!     case XK_numbersign:
      {
        static char
          colors[MaxTextLength] = "256";
--- 6321,6327 ----
        (void) XConfigureImageWindow(display,resource_info,windows,*image);
        break;
      }
!     case XK_Q:
      {
        static char
          colors[MaxTextLength] = "256";
***************
*** 6628,6634 ****
        if (*colors == '\0')
          break;
        XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
!       XFlush(display);
        QuantizeImage(*image,(unsigned int) atoi(colors),
          resource_info->tree_depth,resource_info->dither,
          resource_info->colorspace,True);
--- 6334,6340 ----
        if (*colors == '\0')
          break;
        XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
!       XCheckRefreshWindow(display,&windows->image);
        QuantizeImage(*image,(unsigned int) atoi(colors),
          resource_info->tree_depth,resource_info->dither,
          resource_info->colorspace,True);
***************
*** 6678,6683 ****
--- 6384,6390 ----
        XColorBrowserWidget(display,windows,"Select",color_name);
        if (*color_name == '\0')
          break;
+       XCheckRefreshWindow(display,&windows->image);
        (void) XParseColor(display,windows->image.map_info->colormap,color_name,
          &color);
        border_color.red=color.red >> 8;
***************
*** 6688,6694 ****
        if (*geometry == '\0')
          break;
        XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
!       XFlush(display);
        border_info.width=0;
        border_info.height=0;
        flags=XParseGeometry(geometry,&border_info.x,&border_info.y,
--- 6395,6401 ----
        if (*geometry == '\0')
          break;
        XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
!       XCheckRefreshWindow(display,&windows->image);
        border_info.width=0;
        border_info.height=0;
        flags=XParseGeometry(geometry,&border_info.x,&border_info.y,
***************
*** 6751,6760 ****
          }
        break;
      }
!     case XK_exclam:
      {
        char
          command[MaxTextLength],
          filename[MaxTextLength];
  
        FILE
--- 6458,6468 ----
          }
        break;
      }
!     case XK_numbersign:
      {
        char
          command[MaxTextLength],
+         *directory,
          filename[MaxTextLength];
  
        FILE
***************
*** 6763,6769 ****
        /*
          Edit image comment.
        */
!       TemporaryFilename(filename);
        if ((*image)->comments != (char *) NULL)
          {
            register char
--- 6471,6481 ----
        /*
          Edit image comment.
        */
!       directory=(char *) getenv("TMPDIR");
!       if (directory == (char *) NULL)
!         directory="/tmp";
!       (void) sprintf(filename,"%s/magickXXXXXX",directory);
!       (void) mktemp(filename);
        if ((*image)->comments != (char *) NULL)
          {
            register char
***************
*** 6834,6865 ****
        if (state & Mod1Mask)
          {
            RectangleInfo
!             crop_info;
  
            /*
              Trim one pixel from edge of image.
            */
!           crop_info.x=0;
!           crop_info.y=0;
!           crop_info.width=windows->image.ximage->width;
!           crop_info.height=windows->image.ximage->height;
            if ((key_symbol == XK_Up) || (key_symbol == XK_KP_Up))
!             crop_info.height--;
            if ((key_symbol == XK_Down) || (key_symbol == XK_KP_Down))
              {
!               crop_info.y++;
!               crop_info.height--;
              }
            if ((key_symbol == XK_Left) || (key_symbol == XK_KP_Left))
!             crop_info.width--;
            if ((key_symbol == XK_Right) || (key_symbol == XK_KP_Right))
              {
!               crop_info.x++;
!               crop_info.width--;
              }
!           XSetCropGeometry(display,windows,&crop_info,*image);
!           windows->image.window_changes.width=crop_info.width;
!           windows->image.window_changes.height=crop_info.height;
            XSetWindowBackgroundPixmap(display,windows->image.id,None);
            (void) XConfigureImageWindow(display,resource_info,windows,*image);
            break;
--- 6546,6577 ----
        if (state & Mod1Mask)
          {
            RectangleInfo
!             clip_info;
  
            /*
              Trim one pixel from edge of image.
            */
!           clip_info.x=0;
!           clip_info.y=0;
!           clip_info.width=windows->image.ximage->width;
!           clip_info.height=windows->image.ximage->height;
            if ((key_symbol == XK_Up) || (key_symbol == XK_KP_Up))
!             clip_info.height--;
            if ((key_symbol == XK_Down) || (key_symbol == XK_KP_Down))
              {
!               clip_info.y++;
!               clip_info.height--;
              }
            if ((key_symbol == XK_Left) || (key_symbol == XK_KP_Left))
!             clip_info.width--;
            if ((key_symbol == XK_Right) || (key_symbol == XK_KP_Right))
              {
!               clip_info.x++;
!               clip_info.width--;
              }
!           XSetClipGeometry(display,windows,&clip_info,*image);
!           windows->image.window_changes.width=clip_info.width;
!           windows->image.window_changes.height=clip_info.height;
            XSetWindowBackgroundPixmap(display,windows->image.id,None);
            (void) XConfigureImageWindow(display,resource_info,windows,*image);
            break;
***************
*** 7067,7077 ****
    */
    switch (key_symbol)
    {
-     case XK_q:
-     {
-       XWithdrawWindow(display,windows->magnify.id,windows->magnify.screen);
-       break;
-     }
      case XK_Home:
      case XK_KP_Home:
      {
--- 6779,6784 ----
***************
*** 7270,7277 ****
        "",
        "1    Press to select a pixel within an image window to set",
        "     it's matte value.  The matte value of any pixel within",
!       "     the region you select that matches the color of the",
!       "     choosen pixel is initialized.",
        "",
        "2    Press an a dialog appears requesting a matte value.",
        "     Enter a value between 0 and 255.  This value is",
--- 6977,6984 ----
        "",
        "1    Press to select a pixel within an image window to set",
        "     it's matte value.  The matte value of any pixel within",
!       "     the image that matches the color of the selected pixel",
!       "     is initialized.",
        "",
        "2    Press an a dialog appears requesting a matte value.",
        "     Enter a value between 0 and 255.  This value is",
***************
*** 7278,7302 ****
        "     assigned as the matte value of the selected pixel or",
        "     pixels.",
        "",
-       "3    Press and drag to select a delta factor from a pop-up",
-       "     menu.  Choose from these delta factor:",
-       "",
-       "         0",
-       "         2",
-       "         4",
-       "         8",
-       "         16",
-       "         32",
-       "         64",
-       "         Dialog...",
-       "",
-       "     The delta factor you choose creates a range of colors",
-       "     that are considered candidates for recoloring.  The",
-       "     factor is added then subtracted from each color",
-       "     component of the pixel you choose with button 1.  Any",
-       "     pixel within the region you selected that falls in this",
-       "     range is initialized with the matte value.",
-       "",
        "Matte information is only valid in a DirectClass image.",
        "Therefore, any PseudoClass image is promoted to",
        "DirectClass.  Note that matte information for PseudoClass",
--- 6985,6990 ----
***************
*** 7321,7331 ****
      y,
      y_offset;
  
!   static char
!     matte[MaxTextLength] = "255";
  
!   static int
!     delta = 0;
  
    unsigned int
      height,
--- 7009,7022 ----
      y,
      y_offset;
  
!   register RunlengthPacket
!     *p;
  
!   RunlengthPacket
!     pixel;
! 
!   static char
!     matte[MaxTextLength]="255";
  
    unsigned int
      height,
***************
*** 7408,7455 ****
              XDefineCursor(display,windows->image.id,cursor);
              break;
            }
-           case Button3:
-           {
-             char
-               command[MaxTextLength];
- 
-             int
-               factor;
- 
-             static char
-               *DeltaMenu[]=
-               {
-                 "0",
-                 "2",
-                 "4",
-                 "8",
-                 "16",
-                 "32",
-                 "64",
-                 "Dialog...",
-                 (char *) NULL,
-               };
- 
-             /*
-               Select a delta from the pop-up menu.
-             */
-             factor=XMenuWidget(display,windows,"Delta",DeltaMenu,command);
-             if (factor >= 0)
-               if (factor != 7)
-                 delta=atoi(command);
-               else
-                 {
-                   /*
-                     Select a delta from a dialog widget.
-                   */
-                   (void) sprintf(command,"%d",delta);
-                   XDialogWidget(display,windows,"Delta","Enter color delta:",
-                     command);
-                   if (*command != '\0')
-                     delta=atoi(command);
-                 }
-             break;
-           }
          }
          break;
        }
--- 7099,7104 ----
***************
*** 7525,7556 ****
            x,
            y;
  
!         register RunlengthPacket
!           *p,
!           *q;
! 
!         RunlengthPacket
!           target;
! 
!         /*
!           Matte edit is relative to image configuration.
!         */
!         x=0;
!         y=0;
!         width=image->columns;
!         height=image->rows;
!         if (windows->image.crop_geometry != (char *) NULL)
!           (void) XParseGeometry(windows->image.crop_geometry,&x,&y,
!             &width,&height);
!         x_factor=UpShift(width)/windows->image.ximage->width;
!         x_offset=DownShift((windows->image.x+x_offset)*x_factor)+x;
!         y_factor=UpShift(height)/windows->image.ximage->height;
!         y_offset=DownShift((windows->image.y+y_offset)*y_factor)+y;
!         if (!image->matte)
            {
              /*
!               Initialize matte data.
              */
              p=image->pixels;
              for (i=0; i < image->packets; i++)
              {
--- 7174,7185 ----
            x,
            y;
  
!         if (image->class == PseudoClass)
            {
              /*
!               Promote PseudoClass image to DirectClass & initialize matte data.
              */
+             image->class=DirectClass;
              p=image->pixels;
              for (i=0; i < image->packets; i++)
              {
***************
*** 7557,7602 ****
                p->index=0;
                p++;
              }
-             image->matte=True;
            }
          /*
!           Image must be uncompressed.
          */
!         image->class=DirectClass;
!         if (!UncompressImage(image))
!           break;
          /*
!           Update matte information using flood fill algorithm.
          */
!         p=image->pixels+(y_offset*image->columns+x_offset);
!         target=(*p);
!         for (y=y_offset ; y > 0; y--)
          {
!           p-=image->columns;
!           if (!FuzzyColorMatch(p,target,delta))
              break;
          }
!         p=image->pixels+(y*image->columns+x_offset);
!         for ( ; y < image->rows; y++)
!         {
!           if (!FuzzyColorMatch(p,target,delta))
!             break;
!           q=p;
!           for (x=x_offset ; x > 0; x--)
!           {
!             q--;
!             if (!FuzzyColorMatch(q,target,delta))
!               break;
!           }
!           q=image->pixels+(y*image->columns+x);
!           for ( ; x < image->columns; x++)
!           {
!             if (!FuzzyColorMatch(q,target,delta))
!               break;
!             q->index=atoi(matte) & 0xff;
!             q++;
!           }
!           p+=image->columns;
          }
          if ((resource_info->map_type != (char *) NULL) ||
              (windows->image.class == DirectColor) ||
--- 7186,7227 ----
                p->index=0;
                p++;
              }
            }
+         image->matte=True;
          /*
!           Matte edit is relative to image configuration.
          */
!         x=0;
!         y=0;
!         width=image->columns;
!         height=image->rows;
!         if (windows->image.clip_geometry != (char *) NULL)
!           (void) XParseGeometry(windows->image.clip_geometry,&x,&y,
!             &width,&height);
!         x_factor=UpShift(width)/windows->image.ximage->width;
!         x_offset=DownShift((windows->image.x+x_offset+1)*x_factor)+x;
!         y_factor=UpShift(height)/windows->image.ximage->height;
!         y_offset=DownShift((windows->image.y+y_offset+1)*y_factor)+y;
          /*
!           Update matte information.
          */
!         x=0;
!         p=image->pixels;
!         for (i=0; i < image->packets; i++)
          {
!           x+=(p->length+1);
!           if (x >= (y_offset*image->columns+x_offset))
              break;
+           p++;
          }
!         pixel=image->pixels[i];
!         p=image->pixels;
!         for (i=0; i < image->packets; i++)
!         {
!           if ((p->red == pixel.red) && (p->green == pixel.green) &&
!               (p->blue == pixel.blue))
!             p->index=atoi(matte) & 0xff;
!           p++;
          }
          if ((resource_info->map_type != (char *) NULL) ||
              (windows->image.class == DirectColor) ||
***************
*** 7608,7614 ****
              XConfigureImageColormap(display,resource_info,windows,image);
              (void) XConfigureImageWindow(display,resource_info,windows,image);
            }
-         XDefineCursor(display,windows->image.id,cursor);
          state&=(~UpdateConfigurationState);
        }
    } while (!(state & ExitState));
--- 7233,7238 ----
***************
*** 7917,7980 ****
  #define PrintImageText  "  Printing image...  "
  
    char
!     command[MaxTextLength],
!     geometry[MaxTextLength];
  
    Image
!     *print_image;
! 
!   ImageInfo
!     *image_info;
  
    int
      status;
  
-   static char
-     *PageSizes[]=
-     {
-       "612x792   Letter",
-       "540x720   Note",
-       "612x1008  Legal",
-       "842x1190  A3",
-       "595x842   A4",
-       "421x595   A5",
-       "297x421   A6",
-       "709x1002  B4",
-       "612x936   U.S. Foolscap",
-       "612x936   European Foolscap",
-       "396x612   Half Letter",
-       "792x1224  11x17",
-       "1224x792  Ledger",
-       (char *) NULL
-     };
- 
-   /*
-     Request Postscript page geometry from user.
-   */
-   image_info=resource_info->image_info;
-   (void) sprintf(geometry,PSPageGeometry);
-   if (image_info->page != (char *) NULL)
-     (void) strcpy(geometry,image_info->page);
-   XListBrowserWidget(display,windows,PageSizes,"Select",
-     "Select Postscript Page Geometry:",geometry);
-   if (*geometry != '\0')
-     {
-       /*
-         Copy page geometry.
-       */
-       image_info->page=(char *) malloc((strlen(geometry)+1)*sizeof(char));
-       if (image_info->page != (char *) NULL)
-         {
-           register char
-             *p,
-             *q;
- 
-           q=image_info->page;
-           for (p=geometry; ((*p != ' ') && (*p != '\0')); p++)
-             *q++=(*p);
-           *q='\0';
-         }
-     }
    /*
      Request file name from user.
    */
--- 7541,7554 ----
  #define PrintImageText  "  Printing image...  "
  
    char
!     command[MaxTextLength];
  
    Image
!     *output_image;
  
    int
      status;
  
    /*
      Request file name from user.
    */
***************
*** 7994,8020 ****
      Copy image before applying image transforms.
    */
    image->orphan=True;
!   print_image=CopyImage(image,image->columns,image->rows,True);
    image->orphan=False;
!   if (print_image == (Image *) NULL)
      {
        XDefineCursor(display,windows->image.id,windows->image.cursor);
        XWithdrawWindow(display,windows->info.id,windows->info.screen);
        return(False);
      }
!   if ((windows->image.crop_geometry != (char *) NULL) ||
!      (print_image->columns != windows->image.ximage->width) ||
!      (print_image->rows != windows->image.ximage->height))
      {
        char
          image_geometry[MaxTextLength];
  
        /*
!         Crop and/or scale image.
        */
!       (void) sprintf(image_geometry,"%dx%d!",windows->image.ximage->width,
          windows->image.ximage->height);
!       TransformImage(&print_image,windows->image.crop_geometry,image_geometry);
      }
    if (resource_info->number_colors != 0)
      {
--- 7568,7594 ----
      Copy image before applying image transforms.
    */
    image->orphan=True;
!   output_image=CopyImage(image,image->columns,image->rows,True);
    image->orphan=False;
!   if (output_image == (Image *) NULL)
      {
        XDefineCursor(display,windows->image.id,windows->image.cursor);
        XWithdrawWindow(display,windows->info.id,windows->info.screen);
        return(False);
      }
!   if ((windows->image.clip_geometry != (char *) NULL) ||
!      (output_image->columns != windows->image.ximage->width) ||
!      (output_image->rows != windows->image.ximage->height))
      {
        char
          image_geometry[MaxTextLength];
  
        /*
!         Clip and/or scale image.
        */
!       (void) sprintf(image_geometry,"%dx%d",windows->image.ximage->width,
          windows->image.ximage->height);
!       TransformImage(&output_image,windows->image.clip_geometry,image_geometry);
      }
    if (resource_info->number_colors != 0)
      {
***************
*** 8021,8037 ****
        /*
          Reduce the number of colors in the image.
        */
!       if ((print_image->class == DirectClass) ||
!           (print_image->colors > resource_info->number_colors) ||
            (resource_info->colorspace == GRAYColorspace))
!         QuantizeImage(print_image,resource_info->number_colors,
            resource_info->tree_depth,resource_info->dither,
            resource_info->colorspace,True);
!       SyncImage(print_image);
      }
!   (void) sprintf(print_image->filename,"ps:|%s",command);
!   status=WriteImage(image_info,print_image);
!   DestroyImage(print_image);
    XDefineCursor(display,windows->image.id,windows->image.cursor);
    XWithdrawWindow(display,windows->info.id,windows->info.screen);
    return(status);
--- 7595,7611 ----
        /*
          Reduce the number of colors in the image.
        */
!       if ((output_image->class == DirectClass) ||
!           (output_image->colors > resource_info->number_colors) ||
            (resource_info->colorspace == GRAYColorspace))
!         QuantizeImage(output_image,resource_info->number_colors,
            resource_info->tree_depth,resource_info->dither,
            resource_info->colorspace,True);
!       SyncImage(output_image);
      }
!   (void) sprintf(output_image->filename,"ps:|%s",command);
!   status=WriteImage(resource_info->image_info,output_image);
!   DestroyImage(output_image);
    XDefineCursor(display,windows->image.id,windows->image.cursor);
    XWithdrawWindow(display,windows->info.id,windows->info.screen);
    return(status);
***************
*** 8451,8457 ****
    for (rotations=0; normalized_degrees > 45.0; rotations++)
      normalized_degrees-=90.0;
    if (normalized_degrees != 0.0)
!     if ((windows->image.crop_geometry != (char *) NULL) ||
          ((*image)->columns != windows->image.ximage->width) ||
          ((*image)->rows != windows->image.ximage->height))
        {
--- 8025,8031 ----
    for (rotations=0; normalized_degrees > 45.0; rotations++)
      normalized_degrees-=90.0;
    if (normalized_degrees != 0.0)
!     if ((windows->image.clip_geometry != (char *) NULL) ||
          ((*image)->columns != windows->image.ximage->width) ||
          ((*image)->rows != windows->image.ximage->height))
        {
***************
*** 8461,8473 ****
          /*
            Update image with user transforms.
          */
!         (void) sprintf(image_geometry,"%dx%d!",windows->image.ximage->width,
            windows->image.ximage->height);
!         TransformImage(image,windows->image.crop_geometry,image_geometry);
!         if (windows->image.crop_geometry != (char *) NULL)
            {
!             (void) free((char *) windows->image.crop_geometry);
!             windows->image.crop_geometry=(char *) NULL;
            }
          windows->image.x=0;
          windows->image.y=0;
--- 8035,8047 ----
          /*
            Update image with user transforms.
          */
!         (void) sprintf(image_geometry,"%dx%d",windows->image.ximage->width,
            windows->image.ximage->height);
!         TransformImage(image,windows->image.clip_geometry,image_geometry);
!         if (windows->image.clip_geometry != (char *) NULL)
            {
!             (void) free((char *) windows->image.clip_geometry);
!             windows->image.clip_geometry=(char *) NULL;
            }
          windows->image.x=0;
          windows->image.y=0;
***************
*** 8482,8493 ****
      return(False);
    DestroyImage(*image);
    *image=rotated_image;
!   if (windows->image.crop_geometry != (char *) NULL)
      {
        /*
!         Rotate crop geometry.
        */
!       (void) XParseGeometry(windows->image.crop_geometry,&x,&y,&width,&height);
        switch (rotations % 4)
        {
          default:
--- 8056,8067 ----
      return(False);
    DestroyImage(*image);
    *image=rotated_image;
!   if (windows->image.clip_geometry != (char *) NULL)
      {
        /*
!         Rotate clip geometry.
        */
!       (void) XParseGeometry(windows->image.clip_geometry,&x,&y,&width,&height);
        switch (rotations % 4)
        {
          default:
***************
*** 8498,8504 ****
            /*
              Rotate 90 degrees.
            */
!           (void) sprintf(windows->image.crop_geometry,"%ux%u%+d%+d",
              height,width,(int) (*image)->columns-(int) height-y,x);
            break;
          }
--- 8072,8078 ----
            /*
              Rotate 90 degrees.
            */
!           (void) sprintf(windows->image.clip_geometry,"%ux%u%+d%+d",
              height,width,(int) (*image)->columns-(int) height-y,x);
            break;
          }
***************
*** 8507,8513 ****
            /*
              Rotate 180 degrees.
            */
!           (void) sprintf(windows->image.crop_geometry,"%ux%u%+d%+d",
              width,height,(int) width-x,(int) height-y);
            break;
          }
--- 8081,8087 ----
            /*
              Rotate 180 degrees.
            */
!           (void) sprintf(windows->image.clip_geometry,"%ux%u%+d%+d",
              width,height,(int) width-x,(int) height-y);
            break;
          }
***************
*** 8516,8522 ****
            /*
              Rotate 270 degrees.
            */
!           (void) sprintf(windows->image.crop_geometry,"%ux%u%+d%+d",
              height,width,y,(int) (*image)->rows-(int) width-x);
            break;
          }
--- 8090,8096 ----
            /*
              Rotate 270 degrees.
            */
!           (void) sprintf(windows->image.clip_geometry,"%ux%u%+d%+d",
              height,width,y,(int) (*image)->rows-(int) width-x);
            break;
          }
***************
*** 8529,8540 ****
        */
        windows->image.window_changes.width=(*image)->columns;
        windows->image.window_changes.height=(*image)->rows;
!       if (windows->image.crop_geometry != (char *) NULL)
          {
            /*
!             Obtain dimensions of image from crop geometry.
            */
!           (void) XParseGeometry(windows->image.crop_geometry,&x,&y,
              &width,&height);
            windows->image.window_changes.width=width;
            windows->image.window_changes.height=height;
--- 8103,8114 ----
        */
        windows->image.window_changes.width=(*image)->columns;
        windows->image.window_changes.height=(*image)->rows;
!       if (windows->image.clip_geometry != (char *) NULL)
          {
            /*
!             Obtain dimensions of image from clip geometry.
            */
!           (void) XParseGeometry(windows->image.clip_geometry,&x,&y,
              &width,&height);
            windows->image.window_changes.width=width;
            windows->image.window_changes.height=height;
***************
*** 8706,8711 ****
--- 8280,8286 ----
    XColorBrowserWidget(display,windows,"Select",color_name);
    if (*color_name == '\0')
      return(True);
+   XCheckRefreshWindow(display,&windows->image);
    XDialogWidget(display,windows,"Shear","Enter shear geometry:",geometry);
    if (*geometry == '\0')
      return(True);
***************
*** 8716,8739 ****
    XMapWindow(display,windows->info.id);
    XDisplayInfoString(display,&windows->info,ShearImageText);
    XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
!   XFlush(display);
!   if ((windows->image.crop_geometry != (char *) NULL) ||
        ((*image)->columns != windows->image.ximage->width) ||
        ((*image)->rows != windows->image.ximage->height))
      {
        char
          image_geometry[MaxTextLength];
! 
        /*
          Update image with user transforms.
        */
!       (void) sprintf(image_geometry,"%dx%d!",windows->image.ximage->width,
          windows->image.ximage->height);
!       TransformImage(image,windows->image.crop_geometry,image_geometry);
!       if (windows->image.crop_geometry != (char *) NULL)
          {
!           (void) free((char *) windows->image.crop_geometry);
!           windows->image.crop_geometry=(char *) NULL;
          }
        windows->image.x=0;
        windows->image.y=0;
--- 8291,8314 ----
    XMapWindow(display,windows->info.id);
    XDisplayInfoString(display,&windows->info,ShearImageText);
    XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
!   XCheckRefreshWindow(display,&windows->image);
!   if ((windows->image.clip_geometry != (char *) NULL) ||
        ((*image)->columns != windows->image.ximage->width) ||
        ((*image)->rows != windows->image.ximage->height))
      {
        char
          image_geometry[MaxTextLength];
!   
        /*
          Update image with user transforms.
        */
!       (void) sprintf(image_geometry,"%dx%d",windows->image.ximage->width,
          windows->image.ximage->height);
!       TransformImage(image,windows->image.clip_geometry,image_geometry);
!       if (windows->image.clip_geometry != (char *) NULL)
          {
!           (void) free((char *) windows->image.clip_geometry);
!           windows->image.clip_geometry=(char *) NULL;
          }
        windows->image.x=0;
        windows->image.y=0;
***************
*** 8984,8996 ****
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Function XSetCropGeometry accepts a cropping geometry relative to the
! %  image window and translates it to a cropping geometry relative to the
  %  image.
  %
! %  The format of the XSetCropGeometry routine is:
  %
! %    XSetCropGeometry(display,windows,crop_info,image)
  %
  %  A description of each parameter follows:
  %
--- 8559,8571 ----
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Function XSetClipGeometry accepts a clipping geometry relative to the
! %  image window and translates it to a clipping geometry relative to the
  %  image.
  %
! %  The format of the XSetClipGeometry routine is:
  %
! %    XSetClipGeometry(display,windows,clip_info,image)
  %
  %  A description of each parameter follows:
  %
***************
*** 8999,9012 ****
  %
  %    o windows: Specifies a pointer to a XWindows structure.
  %
! %    o crop_info:  A pointer to a RectangleInfo that defines a region of the
! %      image window to crop.
  %
  %    o image: Specifies a pointer to a Image structure.
  %
  %
  */
! static void XSetCropGeometry(display,windows,crop_info,image)
  Display
    *display;
  
--- 8574,8587 ----
  %
  %    o windows: Specifies a pointer to a XWindows structure.
  %
! %    o clip_info:  A pointer to a RectangleInfo that defines a region of the
! %      image window to clip.
  %
  %    o image: Specifies a pointer to a Image structure.
  %
  %
  */
! static void XSetClipGeometry(display,windows,clip_info,image)
  Display
    *display;
  
***************
*** 9014,9020 ****
    *windows;
  
  RectangleInfo
!   *crop_info;
  
  Image
    *image;
--- 8589,8595 ----
    *windows;
  
  RectangleInfo
!   *clip_info;
  
  Image
    *image;
***************
*** 9036,9087 ****
    if (windows->info.mapped)
      {
        /*
!         Display info on cropping rectangle.
        */
        (void) sprintf(text," %ux%u+%u+%u ",windows->image.width,
          windows->image.height,windows->image.width,windows->image.height);
        XSetWindowExtents(display,&windows->info,text);
        XMapWindow(display,windows->info.id);
!       (void) sprintf(text," %ux%u%+d%+d",crop_info->width,crop_info->height,
!         crop_info->x,crop_info->y);
        XDisplayInfoString(display,&windows->info,text);
      }
    /*
!     Cropping geometry is relative to any previous crop geometry.
    */
    x=0;
    y=0;
    width=image->columns;
    height=image->rows;
!   if (windows->image.crop_geometry != (char *) NULL)
!     (void) XParseGeometry(windows->image.crop_geometry,&x,&y,&width,&height);
    else
      {
        /*
!         Allocate crop geometry string.
        */
!       windows->image.crop_geometry=(char *) malloc(MaxTextLength*sizeof(char));
!       if (windows->image.crop_geometry == (char *) NULL)
!         Error("Unable to crop X image",windows->image.name);
      }
    /*
!     Define the crop geometry string from the cropping rectangle.
    */
    scale_factor=UpShift(width)/windows->image.ximage->width;
!   crop_info->x+=windows->image.x;
!   if (crop_info->x > 0)
!     x+=DownShift(crop_info->x*scale_factor);
!   width=DownShift(crop_info->width*scale_factor);
    if (width == 0)
      width=1;
    scale_factor=UpShift(height)/windows->image.ximage->height;
!   crop_info->y+=windows->image.y;
!   if (crop_info->y > 0)
!     y+=DownShift(crop_info->y*scale_factor);
!   height=DownShift(crop_info->height*scale_factor);
    if (height == 0)
      height=1;
!   (void) sprintf(windows->image.crop_geometry,"%ux%u%+d%+d",width,height,x,y);
  }
  
  /*
--- 8611,8662 ----
    if (windows->info.mapped)
      {
        /*
!         Display info on clipping rectangle.
        */
        (void) sprintf(text," %ux%u+%u+%u ",windows->image.width,
          windows->image.height,windows->image.width,windows->image.height);
        XSetWindowExtents(display,&windows->info,text);
        XMapWindow(display,windows->info.id);
!       (void) sprintf(text," %ux%u%+d%+d",clip_info->width,clip_info->height,
!         clip_info->x,clip_info->y);
        XDisplayInfoString(display,&windows->info,text);
      }
    /*
!     Clipping geometry is relative to any previous clip geometry.
    */
    x=0;
    y=0;
    width=image->columns;
    height=image->rows;
!   if (windows->image.clip_geometry != (char *) NULL)
!     (void) XParseGeometry(windows->image.clip_geometry,&x,&y,&width,&height);
    else
      {
        /*
!         Allocate clip geometry string.
        */
!       windows->image.clip_geometry=(char *) malloc(MaxTextLength*sizeof(char));
!       if (windows->image.clip_geometry == (char *) NULL)
!         Error("Unable to clip X image",windows->image.name);
      }
    /*
!     Define the clip geometry string from the clipping rectangle.
    */
    scale_factor=UpShift(width)/windows->image.ximage->width;
!   clip_info->x+=windows->image.x;
!   if (clip_info->x > 0)
!     x+=DownShift(clip_info->x*scale_factor);
!   width=DownShift(clip_info->width*scale_factor);
    if (width == 0)
      width=1;
    scale_factor=UpShift(height)/windows->image.ximage->height;
!   clip_info->y+=windows->image.y;
!   if (clip_info->y > 0)
!     y+=DownShift(clip_info->y*scale_factor);
!   height=DownShift(clip_info->height*scale_factor);
    if (height == 0)
      height=1;
!   (void) sprintf(windows->image.clip_geometry,"%ux%u%+d%+d",width,height,x,y);
  }
  
  /*
***************
*** 9169,9176 ****
    y=0;
    width=image->columns;
    height=image->rows;
!   if (windows->image.crop_geometry != (char *) NULL)
!     (void) XParseGeometry(windows->image.crop_geometry,&x,&y,&width,&height);
    scale_factor=UpShift(width)/windows->image.ximage->width;
    event->xbutton.x+=windows->image.x;
    event->xbutton.x=DownShift(event->xbutton.x*scale_factor)+x;
--- 8744,8751 ----
    y=0;
    width=image->columns;
    height=image->rows;
!   if (windows->image.clip_geometry != (char *) NULL)
!     (void) XParseGeometry(windows->image.clip_geometry,&x,&y,&width,&height);
    scale_factor=UpShift(width)/windows->image.ximage->width;
    event->xbutton.x+=windows->image.x;
    event->xbutton.x=DownShift(event->xbutton.x*scale_factor)+x;
***************
*** 9377,9383 ****
  %  A description of each parameter follows:
  %
  %    o status: Function XTrimImageWindow returns True if the image is
! %      cropped.  False is returned is there is a memory shortage or if the
  %      image fails to be cropped.
  %
  %    o display: Specifies a connection to an X server; returned from
--- 8952,8958 ----
  %  A description of each parameter follows:
  %
  %    o status: Function XTrimImageWindow returns True if the image is
! %      clipped.  False is returned is there is a memory shortage or if the
  %      image fails to be cropped.
  %
  %    o display: Specifies a connection to an X server; returned from
***************
*** 9492,9498 ****
        /*
          Reconfigure image window as defined by the trimming rectangle.
        */
!       XSetCropGeometry(display,windows,&trim_info,image);
        windows->image.window_changes.width=trim_info.width;
        windows->image.window_changes.height=trim_info.height;
        (void) XConfigureImageWindow(display,resource_info,windows,image);
--- 9067,9073 ----
        /*
          Reconfigure image window as defined by the trimming rectangle.
        */
!       XSetClipGeometry(display,windows,&trim_info,image);
        windows->image.window_changes.width=trim_info.width;
        windows->image.window_changes.height=trim_info.height;
        (void) XConfigureImageWindow(display,resource_info,windows,image);
***************
*** 9507,9548 ****
  %                                                                             %
  %                                                                             %
  %                                                                             %
- %   X W a r n i n g                                                           %
- %                                                                             %
- %                                                                             %
- %                                                                             %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- %  Function XWarning displays a warning message in a Notice widget.
- %
- %  The format of the XWarning routine is:
- %
- %      XWarning(message,qualifier)
- %
- %  A description of each parameter follows:
- %
- %    o message: Specifies the message to display before terminating the
- %      program.
- %
- %    o qualifier: Specifies any qualifier to the message.
- %
- %
- */
- static void XWarning(message,qualifier)
- char
-   *message,
-   *qualifier;
- {
-   if (message == (char *) NULL)
-     return;
-   XNoticeWidget(display,windows,message,qualifier);
- }
- 
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %                                                                             %
- %                                                                             %
- %                                                                             %
  %   X W r i t e I m a g e W i n d o w                                         %
  %                                                                             %
  %                                                                             %
--- 9082,9087 ----
***************
*** 9623,9631 ****
        */
        (void) sprintf(quality,"%u",image_info->quality);
        XDialogWidget(display,windows,"Write","Enter JPEG quality:",quality);
!       if (*quality == '\0')
!         return(True);
!       image_info->quality=atoi(quality);
      }
    if ((strcmp(image_info->magick,"EPS") == 0) ||
        (strcmp(image_info->magick,"PS") == 0) ||
--- 9162,9169 ----
        */
        (void) sprintf(quality,"%u",image_info->quality);
        XDialogWidget(display,windows,"Write","Enter JPEG quality:",quality);
!       if (*quality != '\0')
!         image_info->quality=atoi(quality);
      }
    if ((strcmp(image_info->magick,"EPS") == 0) ||
        (strcmp(image_info->magick,"PS") == 0) ||
***************
*** 9634,9658 ****
        char
          geometry[MaxTextLength];
  
-       static char
-         *PageSizes[]=
-         {
-           "612x792   Letter",
-           "540x720   Note",
-           "612x1008  Legal",
-           "842x1190  A3",
-           "595x842   A4",
-           "421x595   A5",
-           "297x421   A6",
-           "709x1002  B4",
-           "612x936   U.S. Foolscap",
-           "612x936   European Foolscap",
-           "396x612   Half Letter",
-           "792x1224  11x17",
-           "1224x792  Ledger",
-           (char *) NULL
-         };
- 
        /*
          Request Postscript page geometry from user.
        */
--- 9172,9177 ----
***************
*** 9659,9683 ****
        (void) sprintf(geometry,PSPageGeometry);
        if (image_info->page != (char *) NULL)
          (void) strcpy(geometry,image_info->page);
!       XListBrowserWidget(display,windows,PageSizes,"Select",
!         "Select Postscript Page Geometry:",geometry);
        if (*geometry != '\0')
          {
-           /*
-             Copy page geometry.
-           */
            image_info->page=(char *) malloc((strlen(geometry)+1)*sizeof(char));
            if (image_info->page != (char *) NULL)
!             {
!               register char
!                 *p,
!                 *q;
! 
!               q=image_info->page;
!               for (p=geometry; ((*p != ' ') && (*p != '\0')); p++)
!                 *q++=(*p);
!               *q='\0';
!             }
          }
      }
    /*
--- 9178,9190 ----
        (void) sprintf(geometry,PSPageGeometry);
        if (image_info->page != (char *) NULL)
          (void) strcpy(geometry,image_info->page);
!       XDialogWidget(display,windows,"Write","Enter Postscript page geometry:",
!         geometry);
        if (*geometry != '\0')
          {
            image_info->page=(char *) malloc((strlen(geometry)+1)*sizeof(char));
            if (image_info->page != (char *) NULL)
!             (void) sprintf(image_info->page,geometry);
          }
      }
    /*
***************
*** 9687,9693 ****
    XSetWindowExtents(display,&windows->info,WriteImageText);
    XMapWindow(display,windows->info.id);
    XDisplayInfoString(display,&windows->info,WriteImageText);
!   XFlush(display);
    /*
      Copy image before applying image transforms.
    */
--- 9194,9200 ----
    XSetWindowExtents(display,&windows->info,WriteImageText);
    XMapWindow(display,windows->info.id);
    XDisplayInfoString(display,&windows->info,WriteImageText);
!   XCheckRefreshWindow(display,&windows->image);
    /*
      Copy image before applying image transforms.
    */
***************
*** 9700,9706 ****
        XWithdrawWindow(display,windows->info.id,windows->info.screen);
        return(False);
      }
!   if ((windows->image.crop_geometry != (char *) NULL) ||
       (write_image->columns != windows->image.ximage->width) ||
       (write_image->rows != windows->image.ximage->height))
      {
--- 9207,9213 ----
        XWithdrawWindow(display,windows->info.id,windows->info.screen);
        return(False);
      }
!   if ((windows->image.clip_geometry != (char *) NULL) ||
       (write_image->columns != windows->image.ximage->width) ||
       (write_image->rows != windows->image.ximage->height))
      {
***************
*** 9708,9718 ****
          image_geometry[MaxTextLength];
  
        /*
!         Crop and/or scale image.
        */
!       (void) sprintf(image_geometry,"%dx%d!",windows->image.ximage->width,
          windows->image.ximage->height);
!       TransformImage(&write_image,windows->image.crop_geometry,image_geometry);
      }
    if (resource_info->number_colors != 0)
      {
--- 9215,9225 ----
          image_geometry[MaxTextLength];
  
        /*
!         Clip and/or scale image.
        */
!       (void) sprintf(image_geometry,"%dx%d",windows->image.ximage->width,
          windows->image.ximage->height);
!       TransformImage(&write_image,windows->image.clip_geometry,image_geometry);
      }
    if (resource_info->number_colors != 0)
      {
***************
*** 9759,9766 ****
--- 9266,9275 ----
  
    char
      *comment,
+     *density,
      *label,
      *option,
+     *page_geometry,
      *resource_value,
      *server_name;
  
***************
*** 9767,9772 ****
--- 9276,9284 ----
    ColorPacket
      border_color;
  
+   Display
+     *display;
+ 
    Image
      *image,
      *next_image;
***************
*** 9777,9783 ****
    int
      flags,
      i,
!     j,
      x,
      y;
  
--- 9289,9296 ----
    int
      flags,
      i,
!     p,
!     q,
      x,
      y;
  
***************
*** 9786,9794 ****
      first_scene,
      *image_marker,
      image_number,
      last_scene,
      matte,
!     scene;
  
    unsigned long
      state;
--- 9299,9310 ----
      first_scene,
      *image_marker,
      image_number,
+     interlace,
      last_scene,
      matte,
!     quality,
!     scene,
!     verbose;
  
    unsigned long
      state;
***************
*** 9815,9821 ****
    for (i=0; i <= argc; i++)
      image_marker[i]=argc;
    image_number=0;
-   GetImageInfo(&image_info);
    matte=NotInitialized;
    last_scene=0;
    resource_database=(XrmDatabase) NULL;
--- 9331,9336 ----
***************
*** 9881,9913 ****
      compression=RunlengthEncodedCompression;
    comment=
      XGetResourceClass(resource_database,client_name,"comment",(char *) NULL);
!   image_info.density=
      XGetResourceClass(resource_database,client_name,"density",(char *) NULL);
    resource_value=
      XGetResourceClass(resource_database,client_name,"interlace","none");
!   image_info.interlace=UndefinedInterlace;
    if (Latin1Compare("none",resource_value) == 0)
!     image_info.interlace=NoneInterlace;
    if (Latin1Compare("line",resource_value) == 0)
!     image_info.interlace=LineInterlace;
    if (Latin1Compare("plane",resource_value) == 0)
!     image_info.interlace=PlaneInterlace;
!   if (image_info.interlace == UndefinedInterlace)
      Warning("Unrecognized interlace type",resource_value);
    label=XGetResourceClass(resource_database,client_name,"label",(char *) NULL);
!   image_info.page=XGetResourceClass(resource_database,client_name,
!     "pageGeometry",(char *) NULL);
    resource_value=
      XGetResourceClass(resource_database,client_name,"quality","85");
!   image_info.quality=atoi(resource_value);
    resource_value=XGetResourceClass(resource_database,client_name,"scene","0");
    scene=atoi(resource_value);
    resource_value=
      XGetResourceClass(resource_database,client_name,"verbose","False");
!   image_info.verbose=IsTrue(resource_value);
    /*
      Parse command line.
    */
    for (i=1; ((i <= argc) && !(state & ExitState)); i++)
    {
      if (i < argc)
--- 9396,9429 ----
      compression=RunlengthEncodedCompression;
    comment=
      XGetResourceClass(resource_database,client_name,"comment",(char *) NULL);
!   density=
      XGetResourceClass(resource_database,client_name,"density",(char *) NULL);
    resource_value=
      XGetResourceClass(resource_database,client_name,"interlace","none");
!   interlace=UndefinedInterlace;
    if (Latin1Compare("none",resource_value) == 0)
!     interlace=NoneInterlace;
    if (Latin1Compare("line",resource_value) == 0)
!     interlace=LineInterlace;
    if (Latin1Compare("plane",resource_value) == 0)
!     interlace=PlaneInterlace;
!   if (interlace == UndefinedInterlace)
      Warning("Unrecognized interlace type",resource_value);
    label=XGetResourceClass(resource_database,client_name,"label",(char *) NULL);
!   page_geometry=XGetResourceClass(resource_database,client_name,"pageGeometry",
!     (char *) NULL);
    resource_value=
      XGetResourceClass(resource_database,client_name,"quality","85");
!   quality=atoi(resource_value);
    resource_value=XGetResourceClass(resource_database,client_name,"scene","0");
    scene=atoi(resource_value);
    resource_value=
      XGetResourceClass(resource_database,client_name,"verbose","False");
!   verbose=IsTrue(resource_value);
    /*
      Parse command line.
    */
+   p=1;
    for (i=1; ((i <= argc) && !(state & ExitState)); i++)
    {
      if (i < argc)
***************
*** 9975,9987 ****
                  }
                break;
              }
-           if (strncmp("brighten",option+1,2) == 0)
-             break;
            Error("Unrecognized option",option);
            break;
          }
          case 'c':
          {
            if (strncmp("colormap",option+1,6) == 0)
              {
                resource_info.colormap=PrivateColormap;
--- 9491,9511 ----
                  }
                break;
              }
            Error("Unrecognized option",option);
            break;
          }
          case 'c':
          {
+           if (strncmp("clip",option+1,2) == 0)
+             {
+               if (*option == '-')
+                 {
+                   i++;
+                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
+                     Error("Missing geometry on -clip",(char *) NULL);
+                 }
+               break;
+             }
            if (strncmp("colormap",option+1,6) == 0)
              {
                resource_info.colormap=PrivateColormap;
***************
*** 10077,10094 ****
                  }
                break;
              }
-           if (strncmp("contrast",option+1,3) == 0)
-             break;
-           if (strncmp("crop",option+1,2) == 0)
-             {
-               if (*option == '-')
-                 {
-                   i++;
-                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
-                     Error("Missing geometry on -crop",(char *) NULL);
-                 }
-               break;
-             }
            Error("Unrecognized option",option);
            break;
          }
--- 9601,9606 ----
***************
*** 10113,10125 ****
              }
            if (strncmp("density",option+1,3) == 0)
              {
!               image_info.density=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -density",(char *) NULL);
!                   image_info.density=argv[i];
                  }
                break;
              }
--- 9625,9637 ----
              }
            if (strncmp("density",option+1,3) == 0)
              {
!               density=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -density",(char *) NULL);
!                   density=argv[i];
                  }
                break;
              }
***************
*** 10248,10254 ****
              }
            if (strncmp("interlace",option+1,3) == 0)
              {
!               image_info.interlace=NoneInterlace;
                if (*option == '-')
                  {
                    i++;
--- 9760,9766 ----
              }
            if (strncmp("interlace",option+1,3) == 0)
              {
!               interlace=NoneInterlace;
                if (*option == '-')
                  {
                    i++;
***************
*** 10255,10268 ****
                    if (i == argc)
                      Error("Missing type on -interlace",(char *) NULL);
                    option=argv[i];
!                   image_info.interlace=UndefinedInterlace;
                    if (Latin1Compare("none",option) == 0)
!                     image_info.interlace=NoneInterlace;
                    if (Latin1Compare("line",option) == 0)
!                     image_info.interlace=LineInterlace;
                    if (Latin1Compare("plane",option) == 0)
!                     image_info.interlace=PlaneInterlace;
!                   if (image_info.interlace == UndefinedInterlace)
                      Error("Invalid interlace type on -interlace",option);
                  }
                break;
--- 9767,9780 ----
                    if (i == argc)
                      Error("Missing type on -interlace",(char *) NULL);
                    option=argv[i];
!                   interlace=UndefinedInterlace;
                    if (Latin1Compare("none",option) == 0)
!                     interlace=NoneInterlace;
                    if (Latin1Compare("line",option) == 0)
!                     interlace=LineInterlace;
                    if (Latin1Compare("plane",option) == 0)
!                     interlace=PlaneInterlace;
!                   if (interlace == UndefinedInterlace)
                      Error("Invalid interlace type on -interlace",option);
                  }
                break;
***************
*** 10371,10383 ****
          {
            if (strncmp("page",option+1,2) == 0)
              {
!               image_info.page=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing page geometry on -page",(char *) NULL);
!                   image_info.page=argv[i];
                  }
                break;
              }
--- 9883,9895 ----
          {
            if (strncmp("page",option+1,2) == 0)
              {
!               page_geometry=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing page geometry on -page",(char *) NULL);
!                   page_geometry=argv[i];
                  }
                break;
              }
***************
*** 10389,10395 ****
            i++;
            if ((i == argc) || !sscanf(argv[i],"%d",&x))
              Error("Missing quality on -quality",(char *) NULL);
!           image_info.quality=atoi(argv[i]);;
            break;
          }
          case 'r':
--- 9901,9907 ----
            i++;
            if ((i == argc) || !sscanf(argv[i],"%d",&x))
              Error("Missing quality on -quality",(char *) NULL);
!           quality=atoi(argv[i]);;
            break;
          }
          case 'r':
***************
*** 10419,10444 ****
          }
          case 's':
          {
-           if (strncmp("sample",option+1,2) == 0)
-             {
-               if (*option == '-')
-                 {
-                   i++;
-                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
-                     Error("Missing geometry on -sample",(char *) NULL);
-                 }
-               break;
-             }
-           if (strncmp("saturate",option+1,2) == 0)
-             {
-               if (*option == '-')
-                 {
-                   i++;
-                   if ((i == argc) || !sscanf(argv[i],"%d",(int *) &x))
-                     Error("Missing value on -saturate",(char *) NULL);
-                 }
-               break;
-             }
            if (strncmp("scene",option+1,3) == 0)
              {
                first_scene=0;
--- 9931,9936 ----
***************
*** 10524,10530 ****
          {
            if (strncmp("verbose",option+1,2) == 0)
              {
!               image_info.verbose=(*option == '-');
                break;
              }
            if (strncmp("visual",option+1,2) == 0)
--- 10016,10022 ----
          {
            if (strncmp("verbose",option+1,2) == 0)
              {
!               verbose=(*option == '-');
                break;
              }
            if (strncmp("visual",option+1,2) == 0)
***************
*** 10612,10618 ****
            Option is a file name: begin by reading image from specified file.
          */
          start_time=time((time_t *) NULL);
!         (void) strcpy(image_info.filename,option);
          if (first_scene != last_scene)
            {
              char
--- 10104,10110 ----
            Option is a file name: begin by reading image from specified file.
          */
          start_time=time((time_t *) NULL);
!         GetImageInfo(option,&image_info);
          if (first_scene != last_scene)
            {
              char
***************
*** 10629,10636 ****
          image_info.server_name=resource_info.server_name;
          image_info.font=resource_info.font;
          image_info.geometry=resource_info.image_geometry;
!         image_info.dither=resource_info.dither;
          image_info.monochrome=resource_info.monochrome;
          resource_info.image_info=(&image_info);
          image=ReadImage(&image_info);
          if (image == (Image *) NULL)
--- 10121,10132 ----
          image_info.server_name=resource_info.server_name;
          image_info.font=resource_info.font;
          image_info.geometry=resource_info.image_geometry;
!         image_info.page=page_geometry;
!         image_info.density=density;
!         image_info.interlace=interlace;
          image_info.monochrome=resource_info.monochrome;
+         image_info.quality=quality;
+         image_info.verbose=verbose;
          resource_info.image_info=(&image_info);
          image=ReadImage(&image_info);
          if (image == (Image *) NULL)
***************
*** 10656,10664 ****
            /*
              Transform image as defined by the image geometries.
            */
!           for (j=1; j < i; j++)
            {
!             option=argv[j];
              if (strncmp("-blur",option,3) == 0)
                {
                  Image
--- 10152,10160 ----
            /*
              Transform image as defined by the image geometries.
            */
!           for (q=p; q < i; q++)
            {
!             option=argv[q];
              if (strncmp("-blur",option,3) == 0)
                {
                  Image
***************
*** 10687,10693 ****
                  */
                  border_info.width=0;
                  border_info.height=0;
!                 flags=XParseGeometry(argv[++j],&border_info.x,&border_info.y,
                    &border_info.width,&border_info.height);
                  if ((flags & HeightValue) == 0)
                    border_info.height=border_info.width;
--- 10183,10189 ----
                  */
                  border_info.width=0;
                  border_info.height=0;
!                 flags=XParseGeometry(argv[++q],&border_info.x,&border_info.y,
                    &border_info.width,&border_info.height);
                  if ((flags & HeightValue) == 0)
                    border_info.height=border_info.width;
***************
*** 10708,10728 ****
                    Get border color.
                  */
                  colormap=XDefaultColormap(display,XDefaultScreen(display));
!                 (void) XParseColor(display,colormap,argv[++j],&color);
                  border_color.red=color.red >> 8;
                  border_color.green=color.green >> 8;
                  border_color.blue=color.blue >> 8;
                }
!             if (strncmp("-brighten",option,3) == 0)
!               GammaImage(image,"1.25");
!             if (strncmp("+brighten",option,3) == 0)
!               GammaImage(image,"0.75");
!             if (strncmp("-contrast",option,4) == 0)
!               ContrastImage(image,True);
!             if (strncmp("+contrast",option,4) == 0)
!               ContrastImage(image,False);
!             if (strncmp("-crop",option,3) == 0)
!               TransformImage(&image,argv[++j],(char *) NULL);
              if (strncmp("-despeckle",option,4) == 0)
                {
                  Image
--- 10204,10216 ----
                    Get border color.
                  */
                  colormap=XDefaultColormap(display,XDefaultScreen(display));
!                 (void) XParseColor(display,colormap,argv[++q],&color);
                  border_color.red=color.red >> 8;
                  border_color.green=color.green >> 8;
                  border_color.blue=color.blue >> 8;
                }
!             if (strncmp("-clip",option,3) == 0)
!               TransformImage(&image,argv[++q],(char *) NULL);
              if (strncmp("-despeckle",option,4) == 0)
                {
                  Image
***************
*** 10801,10809 ****
                    }
                }
              if (strncmp("-gamma",option,3) == 0)
!               GammaImage(image,argv[++j]);
              if (strncmp("-geometry",option,4) == 0)
!               TransformImage(&image,(char *) NULL,argv[++j]);
              if (strncmp("-negate",option,4) == 0)
                NegateImage(image);
              if (strncmp("-noise",option,4) == 0)
--- 10289,10297 ----
                    }
                }
              if (strncmp("-gamma",option,3) == 0)
!               GammaImage(image,argv[++q]);
              if (strncmp("-geometry",option,4) == 0)
!               TransformImage(&image,(char *) NULL,argv[++q]);
              if (strncmp("-negate",option,4) == 0)
                NegateImage(image);
              if (strncmp("-noise",option,4) == 0)
***************
*** 10837,10843 ****
                  */
                  x=0;
                  y=0;
!                 flags=XParseGeometry(argv[++j],&x,&y,&width,&height);
                  rolled_image=RollImage(image,x,y);
                  if (rolled_image != (Image *) NULL)
                    {
--- 10325,10331 ----
                  */
                  x=0;
                  y=0;
!                 flags=XParseGeometry(argv[++q],&x,&y,&width,&height);
                  rolled_image=RollImage(image,x,y);
                  if (rolled_image != (Image *) NULL)
                    {
***************
*** 10853,10859 ****
                  /*
                    Rotate image.
                  */
!                 rotated_image=RotateImage(image,(double) atof(argv[++j]),
                    &border_color,False);
                  if (rotated_image != (Image *) NULL)
                    {
--- 10341,10347 ----
                  /*
                    Rotate image.
                  */
!                 rotated_image=RotateImage(image,(double) atof(argv[++q]),
                    &border_color,False);
                  if (rotated_image != (Image *) NULL)
                    {
***************
*** 10861,10890 ****
                      image=rotated_image;
                    }
                }
-             if (strncmp("-sample",option,3) == 0)
-               {
-                 Image
-                   *sampled_image;
- 
-                 unsigned int
-                   height,
-                   width;
- 
-                 /*
-                   Sample image with pixel replication.
-                 */
-                 width=image->columns;
-                 height=image->rows;
-                 ParseImageGeometry(argv[++j],&width,&height);
-                 sampled_image=SampleImage(image,width,height);
-                 if (sampled_image != (Image *) NULL)
-                   {
-                     DestroyImage(image);
-                     image=sampled_image;
-                   }
-               }
-             if (strncmp("-saturate",option,4) == 0)
-               SaturateImage(image,atoi(argv[++j]));
              if (strncmp("-sharpen",option,4) == 0)
                {
                  Image
--- 10349,10354 ----
***************
*** 10914,10920 ****
                  */
                  x_shear=0.0;
                  y_shear=0.0;
!                 (void) sscanf(argv[++j],"%fx%f",&x_shear,&y_shear);
                  sheared_image=ShearImage(image,(double) x_shear,
                    (double) y_shear,&border_color,False);
                  if (sheared_image != (Image *) NULL)
--- 10378,10384 ----
                  */
                  x_shear=0.0;
                  y_shear=0.0;
!                 (void) sscanf(argv[++q],"%fx%f",&x_shear,&y_shear);
                  sheared_image=ShearImage(image,(double) x_shear,
                    (double) y_shear,&border_color,False);
                  if (sheared_image != (Image *) NULL)
***************
*** 10936,10942 ****
                  QuantizeImage(image,resource_info.number_colors,
                    resource_info.tree_depth,resource_info.dither,
                    resource_info.colorspace,True);
!               if (image_info.verbose)
                  {
                    /*
                      Measure quantization error.
--- 10400,10406 ----
                  QuantizeImage(image,resource_info.number_colors,
                    resource_info.tree_depth,resource_info.dither,
                    resource_info.colorspace,True);
!               if (verbose)
                  {
                    /*
                      Measure quantization error.
***************
*** 10987,10993 ****
                (void) strcpy(image->filename,resource_info.write_filename);
                (void) WriteImage(&image_info,image);
              }
!           if (image_info.verbose)
              {
                /*
                  Display detailed info about the image.
--- 10451,10457 ----
                (void) strcpy(image->filename,resource_info.write_filename);
                (void) WriteImage(&image_info,image);
              }
!           if (verbose)
              {
                /*
                  Display detailed info about the image.
***************
*** 11046,11051 ****
--- 10510,10516 ----
              if (image_number != 0)
                image_number--;
            }
+         p=i+1;
          if (state & ExitState)
            break;
        }
diff -c -r ImageMagick-3.1/display.man ImageMagick/display.man
*** ImageMagick-3.1/display.man	Wed Jul 13 10:52:16 1994
--- ImageMagick/display.man	Fri Jun  3 22:04:05 1994
***************
*** 27,33 ****
      o double the image size
      o resize the image
      o trim the image edges
!     o crop the image
      o cut the image
      o flop image in the horizontal direction
      o flip image in the vertical direction
--- 27,33 ----
      o double the image size
      o resize the image
      o trim the image edges
!     o clip the image
      o cut the image
      o flop image in the horizontal direction
      o flip image in the vertical direction
***************
*** 36,53 ****
      o rotate the image
      o shear the image
      o invert the colors of the image
-     o brighten the image
-     o darken the image
-     o gamma correct the image
-     o sharpen the image contrast
-     o dull the image contrast
-     o increase or decrease the color saturation
      o perform histogram equalization on the image
      o perform histogram normalization on the image
      o reduce the speckles within an image
      o eliminate peak noise from an image
      o detect edges within the image
-     o emboss an image
      o convert the image to grayscale
      o set the maximum number of unique colors in the image
      o annotate the image with text
--- 36,47 ----
      o rotate the image
      o shear the image
      o invert the colors of the image
      o perform histogram equalization on the image
      o perform histogram normalization on the image
+     o gamma correct the image
      o reduce the speckles within an image
      o eliminate peak noise from an image
      o detect edges within the image
      o convert the image to grayscale
      o set the maximum number of unique colors in the image
      o annotate the image with text
***************
*** 102,113 ****
  The color of the border is obtained from the X server and is defined as
  \fBbordercolor\fP (class \fBborderColor\fP).  See \fBX(1)\fP for details.
  .TP 5
! .B "-brighten"
! brighten or darken an image.
  
! This option increases or decreases the intensity of an image.  Use
! \fB-brighten\fP to brighten the image or \fB+brighten\fP to darken the
! image intensity.
  .TP 5
  .B "-colormap \fItype\fP"
  the type of colormap: \fBShared\fP or \fBPrivate\fP.
--- 96,111 ----
  The color of the border is obtained from the X server and is defined as
  \fBbordercolor\fP (class \fBborderColor\fP).  See \fBX(1)\fP for details.
  .TP 5
! .B "-clip \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
! preferred size and location of the clipped image.  See \fBX(1)\fP for details
! about the geometry specification.
! 
! Use clipping to apply image processing options to, or display, a
! particular area of an image.  Use \fB-clip 0x0\fP to remove edges that are
! the background color.
  
! The equivalent X resource for this option is \fBclipGeometry\fP
! (class \fBClipGeometry\fP).  See \fBX RESOURCES\fP for details.
  .TP 5
  .B "-colormap \fItype\fP"
  the type of colormap: \fBShared\fP or \fBPrivate\fP.
***************
*** 175,198 ****
  Specify \fB\+compress\fP to store the binary image in an uncompressed format.
  The default is the compression type of the specified image file.
  .TP 5
- .B "-contrast"
- enhance or reduce the image contrast.
- 
- This option enhances the intensity differences between the
- lighter and darker elements of the image.  Use \fB-contrast\fP to
- enhance the image or \fB+contrast\fP to reduce the image contrast.
- .TP 5
- .B "-crop \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
- preferred size and location of the cropped image.  See \fBX(1)\fP for details
- about the geometry specification.
- 
- Use cropping to apply image processing options to, or display, a
- particular area of an image.  Use \fB-crop 0x0\fP to remove edges that are
- the background color.
- 
- The equivalent X resource for this option is \fBcropGeometry\fP
- (class \fBCropGeometry\fP).  See \fBX RESOURCES\fP for details.
- .TP 5
  .B "-delay \fIseconds\fP"
  display the next image after pausing.
  
--- 173,178 ----
***************
*** 356,364 ****
  
  Use this option to specify the dimensions of the Postscript page in
  picas or a TEXT page in pixels.  The default for a Postscript page is
! to center the image on a letter page 612 by 792 dots per inch. The
  left and right margins are 18 picas and the top and bottom 94 picas
! (i.e.  612x792+36+36).  Other common sizes are:
  
      540x720   Note
      612x1008  Legal
--- 336,344 ----
  
  Use this option to specify the dimensions of the Postscript page in
  picas or a TEXT page in pixels.  The default for a Postscript page is
! to center the image on a letter page 612 by 792 dots per inch.  The
  left and right margins are 18 picas and the top and bottom 94 picas
! (i.e.  612x792+18+94).  Other common sizes are:
  
      540x720   Note
      612x1008  Legal
***************
*** 397,408 ****
  the color defined as \fBbordercolor\fP (class \fBborderColor\fP).
  See \fBX(1)\fP for details.
  .TP 5
- .B "-sample \fIgeometry\fP"
- scale image with pixel sampling.
- .TP 5
- .B "-saturate \fIvalue\fP"
- precent increase or decrease in color saturation.
- .TP 5
  .B "-scene \fIvalue\fP"
  image scene number.
  
--- 377,382 ----
***************
*** 575,593 ****
        Load...
        Next
        Former
-       Quicken
      Edit
        Undo
        Restore
        Refresh
!     Size
        Half Size
        Original Size
        Double Size
        Resize...
!     Pixel Transform
        Trim Edges
!       Crop
        Cut
        Flop
        Flip
--- 549,566 ----
        Load...
        Next
        Former
      Edit
        Undo
        Restore
        Refresh
!     View
        Half Size
        Original Size
        Double Size
        Resize...
!     Transform
        Trim Edges
!       Clip
        Cut
        Flop
        Flip
***************
*** 594,609 ****
        Rotate Right
        Rotate Left
        Rotate...
!     Color Enhance
!       Brighten
!       Darken
!       Gamma...
!       Sharpen
!       Dull
!       Saturate...
        Equalize
        Normalize
!       Negate
      Effects
        Despeckle
        Peak Noise
--- 567,577 ----
        Rotate Right
        Rotate Left
        Rotate...
!     Enhance
!       Negate
        Equalize
        Normalize
!       Gamma...
      Effects
        Despeckle
        Peak Noise
***************
*** 610,616 ****
        Sharpen
        Blur
        Edge Detect
-       Emboss
        Grayscale
        Quantize...
      Image Edit
--- 578,583 ----
***************
*** 658,666 ****
  .B "f"
  Press to display the former image.
  .TP 5
- .B "Q"
- Press to display the next image after pausing.
- .TP 5
  .B "u"
  Press to undo last image transformation.
  .TP 5
--- 625,630 ----
***************
*** 715,737 ****
  .B "s"
  Press to shear the image the number of degrees you specify.
  .TP 5
! .B "F8"
! Press to brighten the image.
! .TP 5
! .B "F9"
! Press to darken the image.
! .TP 5
! .B "g"
! Press to gamma correct the image.
! .TP 5
! .B "F10"
! Press to sharpen the image contrast.
! .TP 5
! .B "F11"
! Press to dull the image contrast.
! .TP 5
! .B "F12"
! Press to increase or decrease the color saturation.
  .TP 5
  .B "="
  Press to perform histogram equalization on the image.
--- 679,686 ----
  .B "s"
  Press to shear the image the number of degrees you specify.
  .TP 5
! .B "~"
! Press to invert the colors of the image.
  .TP 5
  .B "="
  Press to perform histogram equalization on the image.
***************
*** 739,746 ****
  .B "N"
  Press to perform histogram normalization on the image.
  .TP 5
! .B "~"
! Press to invert the colors of the image.
  .TP 5
  .B "D"
  Press to reduce the speckles in an image.
--- 688,695 ----
  .B "N"
  Press to perform histogram normalization on the image.
  .TP 5
! .B "g"
! Press to gamma correct the image.
  .TP 5
  .B "D"
  Press to reduce the speckles in an image.
***************
*** 757,769 ****
  .B "E"
  Press to detect edges within an image.
  .TP 5
- .B "M"
- Press to emboss an image.
- .TP 5
  .B "G"
  Press to convert the image colors to gray.
  .TP 5
! .B "#"
  Press to set the maximum number of unique colors in the image.
  .TP 5
  .B "a"
--- 706,715 ----
  .B "E"
  Press to detect edges within an image.
  .TP 5
  .B "G"
  Press to convert the image colors to gray.
  .TP 5
! .B "Q"
  Press to set the maximum number of unique colors in the image.
  .TP 5
  .B "a"
***************
*** 779,785 ****
  
  Refer to \fBIMAGE COMPOSITING\fP for more details.
  .TP 5
! .B "C"
  Press to edit an image pixel color.
  
  Refer to \fBCOLOR EDITING\fP for more details.
--- 725,731 ----
  
  Refer to \fBIMAGE COMPOSITING\fP for more details.
  .TP 5
! .B "c"
  Press to edit an image pixel color.
  
  Refer to \fBCOLOR EDITING\fP for more details.
***************
*** 789,795 ****
  
  Refer to \fBMATTE EDITING\fP for more details.
  .TP 5
! .B "!"
  Press to add an image comment.
  .TP 5
  .B "h"
--- 735,741 ----
  
  Refer to \fBMATTE EDITING\fP for more details.
  .TP 5
! .B "#"
  Press to add an image comment.
  .TP 5
  .B "h"
***************
*** 924,947 ****
  If you force the panning window to withdraw, the image is restored to
  its original size.
  .SH IMAGE CROPPING
! To begin, press button 1 and choose \fICrop\fP from the command menu
  (see \fBBUTTONS\fP).  Alternatively, press \fIc\fP in the image window
  (see \fBKEYBOARD ACCELERATORS\fP).  To exit immediately, press
  \fIESC\fP.
  
  A small window appears showing the location of the cursor in the image
! window.  You are now in \fIcrop mode\fP.  To exit immediately,
  press \fIESC\fP.
  
! To define a cropping region, press button 1 and drag.  The cropping
  region is defined by a highlighted rectangle that expands or contracts
! as it follows the pointer.  Once you are satisfied with the cropping region,
! release the button.  You can make adjustments to the cropping rectangle
  with the arrow keys.  Press an arrow key to expand the region by one
! pixel.  Press \fBALT\fP and an arrow key to contract the cropping
  region.
  
! Finally, press \fIRETURN\fP to commit your cropping region.  To exit without
  cropping the image, press \fIESC\fP.
  .SH IMAGE CUTTING
  An image is cut interactively.  There is no command line argument to
--- 870,893 ----
  If you force the panning window to withdraw, the image is restored to
  its original size.
  .SH IMAGE CROPPING
! To begin, press button 1 and choose \fIClip\fP from the command menu
  (see \fBBUTTONS\fP).  Alternatively, press \fIc\fP in the image window
  (see \fBKEYBOARD ACCELERATORS\fP).  To exit immediately, press
  \fIESC\fP.
  
  A small window appears showing the location of the cursor in the image
! window.  You are now in \fIclip mode\fP.  To exit immediately,
  press \fIESC\fP.
  
! To define a clipping region, press button 1 and drag.  The clipping
  region is defined by a highlighted rectangle that expands or contracts
! as it follows the pointer.  Once you are satisfied with the clipping region,
! release the button.  You can make adjustments to the clipping rectangle
  with the arrow keys.  Press an arrow key to expand the region by one
! pixel.  Press \fBALT\fP and an arrow key to contract the clipping
  region.
  
! Finally, press \fIRETURN\fP to commit your clipping region.  To exit without
  cropping the image, press \fIESC\fP.
  .SH IMAGE CUTTING
  An image is cut interactively.  There is no command line argument to
***************
*** 1173,1183 ****
  .TP 9
  .B plus
  The result is just the sum of the image data.  Output values are
! cropped to 255 (no overflow).  This operation is independent
  of the matte channels.
  .TP 9
  .B minus
! The result of \fIimage\fP \- \fIimage window\fP, with underflow cropped
  to zero.  The matte channel is ignored (set to 255, full coverage).
  .TP 9
  .B add
--- 1119,1129 ----
  .TP 9
  .B plus
  The result is just the sum of the image data.  Output values are
! clipped to 255 (no overflow).  This operation is independent
  of the matte channels.
  .TP 9
  .B minus
! The result of \fIimage\fP \- \fIimage window\fP, with underflow clipped
  to zero.  The matte channel is ignored (set to 255, full coverage).
  .TP 9
  .B add
***************
*** 1241,1248 ****
  .TP 5
  .B "1"
  Press to select a pixel within the image window to change its color.
! Any pixel within the image that matches the color within the region you
! selected is recolored. 
  .TP 5
  .B "2"
  Press and drag to select a pixel color from a pop-up menu.  Choose from
--- 1187,1194 ----
  .TP 5
  .B "1"
  Press to select a pixel within the image window to change its color.
! Any pixel within the image that matches the color of the selected pixel is
! recolored. 
  .TP 5
  .B "2"
  Press and drag to select a pixel color from a pop-up menu.  Choose from
***************
*** 1279,1285 ****
  The delta factor you choose creates a range of colors that are
  considered candidates for recoloring.  The factor is added then
  subtracted from each color component of the pixel you choose with button
! 1.  Any pixel within the selected region that falls in this range is recolored.
  .PP
  The actual color you request for the pixels is saved in the image.
  However, the color that appears in your image window may be different.
--- 1225,1231 ----
  The delta factor you choose creates a range of colors that are
  considered candidates for recoloring.  The factor is added then
  subtracted from each color component of the pixel you choose with button
! 1.  Any pixel within the image that falls in this range is recolored.
  .PP
  The actual color you request for the pixels is saved in the image.
  However, the color that appears in your image window may be different.
***************
*** 1312,1343 ****
  .TP 5
  .B "1"
  Press to select a pixel within the image window to set it's matte value.
! The matte value of any pixel within the region you select that matches
! the color of the choosen pixel is initialized to the matte value.
  .TP 5
  .B "2"
  Press an a dialog appears requesting a matte value.  Enter a value between
  0 and 255.  This value is assigned as the matte value of the selected pixel
  or pixels.
- .TP 5
- .B "3"
- Press and drag to select a delta factor from a pop-up menu.  Choose from
- these delta factor:
- 
-     0
-     2
-     4
-     8
-     16
-     32
-     64
-     Dialog...
- 
- The delta factor you choose creates a range of colors that are
- considered candidates for setting a matte value.  The factor is added then
- subtracted from each color component of the pixel you choose with button
- 1.  Any pixel within the region you selected that falls in this range is
- initialized with the matte value.
  .PP
  Matte information is only valid in a \fIDirectClass\fP image.
  Therefore, any \fIPseudoClass\fP image is promoted to \fIDirectClass\fP
--- 1258,1270 ----
  .TP 5
  .B "1"
  Press to select a pixel within the image window to set it's matte value.
! The matte value of any pixel within the image that matches the color of the
! selected pixel is initialized.
  .TP 5
  .B "2"
  Press an a dialog appears requesting a matte value.  Enter a value between
  0 and 255.  This value is assigned as the matte value of the selected pixel
  or pixels.
  .PP
  Matte information is only valid in a \fIDirectClass\fP image.
  Therefore, any \fIPseudoClass\fP image is promoted to \fIDirectClass\fP
diff -c -r ImageMagick-3.1/import.c ImageMagick/import.c
*** ImageMagick-3.1/import.c	Wed Jul 13 10:52:10 1994
--- ImageMagick/import.c	Thu Jun  2 15:15:57 1994
***************
*** 56,66 ****
  %
  %  Where options include:
  %    -border             include image borders in the output image
  %    -colors value       preferred number of colors in the image
  %    -colorspace type    GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV
  %    -comment string     annotate image with comment
  %    -compress type      RunlengthEncoded or QEncoded
- %    -crop geometry      preferred size and location of the cropped image
  %    -delay seconds      pause before selecting target window
  %    -density geometry   vertical and horizontal density of the image
  %    -descend            obtain image by descending window hierarchy
--- 56,66 ----
  %
  %  Where options include:
  %    -border             include image borders in the output image
+ %    -clip geometry      preferred size and location of the clipped image
  %    -colors value       preferred number of colors in the image
  %    -colorspace type    GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV
  %    -comment string     annotate image with comment
  %    -compress type      RunlengthEncoded or QEncoded
  %    -delay seconds      pause before selecting target window
  %    -density geometry   vertical and horizontal density of the image
  %    -descend            obtain image by descending window hierarchy
***************
*** 127,137 ****
      *options[]=
      {
        "-border             include image borders in the output image",
        "-colors value       preferred number of colors in the image",
        "-colorspace type    GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV",
        "-comment string     annotate image with comment",
        "-compress type      RunlengthEncoded or QEncoded",
-       "-crop geometry      preferred size and location of the cropped image",
        "-delay seconds      pause before selecting target window",
        "-density geometry   vertical and horizontal density of the image",
        "-descend            obtain image by descending window hierarchy",
--- 127,137 ----
      *options[]=
      {
        "-border             include image borders in the output image",
+       "-clip geometry      preferred size and location of the clipped image",
        "-colors value       preferred number of colors in the image",
        "-colorspace type    GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV",
        "-comment string     annotate image with comment",
        "-compress type      RunlengthEncoded or QEncoded",
        "-delay seconds      pause before selecting target window",
        "-density geometry   vertical and horizontal density of the image",
        "-descend            obtain image by descending window hierarchy",
***************
*** 193,204 ****
    *argv[];
  {
    char
      *comment,
!     *crop_geometry,
      *filename,
      *label,
      *option,
      *resource_value,
      *target_window;
  
    Display
--- 193,207 ----
    *argv[];
  {
    char
+     *clip_geometry,
      *comment,
!     *density,
      *filename,
      *label,
      *option,
+     *page_geometry,
      *resource_value,
+     *server_name,
      *target_window;
  
    Display
***************
*** 227,236 ****
      compression,
      descend,
      frame,
      mean_error_per_pixel,
      negate,
      scene,
!     screen;
  
    unsigned long
      total_colors;
--- 230,242 ----
      compression,
      descend,
      frame,
+     interlace,
      mean_error_per_pixel,
      negate,
+     quality,
      scene,
!     screen,
!     verbose;
  
    unsigned long
      total_colors;
***************
*** 251,257 ****
    /*
      Connect to X server.
    */
!   image_info.server_name=(char *) NULL;
    for (i=1; i < argc; i++)
    {
      /*
--- 257,263 ----
    /*
      Connect to X server.
    */
!   server_name=(char *) NULL;
    for (i=1; i < argc; i++)
    {
      /*
***************
*** 267,279 ****
            i++;
            if (i == argc)
              Error("Missing server name on -display",(char *) NULL);
!           image_info.server_name=argv[i];
            break;
          }
    }
!   display=XOpenDisplay(image_info.server_name);
    if (display == (Display *) NULL)
!     Error("Unable to connect to X server",XDisplayName(image_info.server_name));
    /*
      Set our forgiving error handler.
    */
--- 273,285 ----
            i++;
            if (i == argc)
              Error("Missing server name on -display",(char *) NULL);
!           server_name=argv[i];
            break;
          }
    }
!   display=XOpenDisplay(server_name);
    if (display == (Display *) NULL)
!     Error("Unable to connect to X server",XDisplayName(server_name));
    /*
      Set our forgiving error handler.
    */
***************
*** 292,302 ****
    /*
      Get user defaults from X resource database.
    */
-   GetImageInfo(&image_info);
    XGetResourceInfo(resource_database,client_name,&resource_info);
    resource_value=
      XGetResourceClass(resource_database,client_name,"border","False");
    borders=IsTrue(resource_value);
    comment=
      XGetResourceClass(resource_database,client_name,"comment",(char *) NULL);
    resource_value=
--- 298,309 ----
    /*
      Get user defaults from X resource database.
    */
    XGetResourceInfo(resource_database,client_name,&resource_info);
    resource_value=
      XGetResourceClass(resource_database,client_name,"border","False");
    borders=IsTrue(resource_value);
+   clip_geometry=XGetResourceClass(resource_database,client_name,
+     "clipGeometry",(char *) NULL);
    comment=
      XGetResourceClass(resource_database,client_name,"comment",(char *) NULL);
    resource_value=
***************
*** 305,313 ****
      compression=QEncodedCompression;
    else
      compression=RunlengthEncodedCompression;
!   crop_geometry=XGetResourceClass(resource_database,client_name,
!     "cropGeometry",(char *) NULL);
!   image_info.density=XGetResourceClass(resource_database,client_name,"density",
      (char *) NULL);
    resource_value=
      XGetResourceClass(resource_database,client_name,"descend","False");
--- 312,318 ----
      compression=QEncodedCompression;
    else
      compression=RunlengthEncodedCompression;
!   density=XGetResourceClass(resource_database,client_name,"density",
      (char *) NULL);
    resource_value=
      XGetResourceClass(resource_database,client_name,"descend","False");
***************
*** 317,340 ****
    frame=IsTrue(resource_value);
    resource_value=
      XGetResourceClass(resource_database,client_name,"interlace","none");
!   image_info.interlace=UndefinedInterlace;
    if (Latin1Compare("none",resource_value) == 0)
!     image_info.interlace=NoneInterlace;
    if (Latin1Compare("line",resource_value) == 0)
!     image_info.interlace=LineInterlace;
    if (Latin1Compare("plane",resource_value) == 0)
!     image_info.interlace=PlaneInterlace;
!   if (image_info.interlace == UndefinedInterlace)
      Warning("Unrecognized interlace type",resource_value);
    resource_value=
      XGetResourceClass(resource_database,client_name,"negate","False");
    negate=IsTrue(resource_value);
    label=XGetResourceClass(resource_database,client_name,"label",(char *) NULL);
!   image_info.geometry=XGetResourceClass(resource_database,client_name,
      "pageGeometry",(char *) NULL);
    resource_value=
      XGetResourceClass(resource_database,client_name,"quality","85");
!   image_info.quality=atoi(resource_value);
    resource_value=XGetResourceClass(resource_database,client_name,"rotate","0");
    degrees=atoi(resource_value);
    resource_value=XGetResourceClass(resource_database,client_name,"scene","0");
--- 322,345 ----
    frame=IsTrue(resource_value);
    resource_value=
      XGetResourceClass(resource_database,client_name,"interlace","none");
!   interlace=UndefinedInterlace;
    if (Latin1Compare("none",resource_value) == 0)
!     interlace=NoneInterlace;
    if (Latin1Compare("line",resource_value) == 0)
!     interlace=LineInterlace;
    if (Latin1Compare("plane",resource_value) == 0)
!     interlace=PlaneInterlace;
!   if (interlace == UndefinedInterlace)
      Warning("Unrecognized interlace type",resource_value);
    resource_value=
      XGetResourceClass(resource_database,client_name,"negate","False");
    negate=IsTrue(resource_value);
    label=XGetResourceClass(resource_database,client_name,"label",(char *) NULL);
!   page_geometry=XGetResourceClass(resource_database,client_name,
      "pageGeometry",(char *) NULL);
    resource_value=
      XGetResourceClass(resource_database,client_name,"quality","85");
!   quality=atoi(resource_value);
    resource_value=XGetResourceClass(resource_database,client_name,"rotate","0");
    degrees=atoi(resource_value);
    resource_value=XGetResourceClass(resource_database,client_name,"scene","0");
***************
*** 344,350 ****
    screen=IsTrue(resource_value);
    resource_value=
      XGetResourceClass(resource_database,client_name,"verbose","False");
!   image_info.verbose=IsTrue(resource_value);
    total_colors=0;
    /*
      Check command syntax.
--- 349,355 ----
    screen=IsTrue(resource_value);
    resource_value=
      XGetResourceClass(resource_database,client_name,"verbose","False");
!   verbose=IsTrue(resource_value);
    total_colors=0;
    /*
      Check command syntax.
***************
*** 383,388 ****
--- 388,405 ----
          }
          case 'c':
          {
+           if (strncmp("clip",option+1,2) == 0)
+             {
+               clip_geometry=(char *) NULL;
+               if (*option == '-')
+                 {
+                   i++;
+                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
+                     Error("Missing geometry on -clip",(char *) NULL);
+                   clip_geometry=argv[i];
+                 }
+               break;
+             }
            if (strncmp("colors",option+1,7) == 0)
              {
                resource_info.number_colors=0;
***************
*** 459,476 ****
                  }
                break;
              }
-           if (strncmp("crop",option+1,2) == 0)
-             {
-               crop_geometry=(char *) NULL;
-               if (*option == '-')
-                 {
-                   i++;
-                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
-                     Error("Missing geometry on -crop",(char *) NULL);
-                   crop_geometry=argv[i];
-                 }
-               break;
-             }
            Error("Unrecognized option",option);
            break;
          }
--- 476,481 ----
***************
*** 490,502 ****
              }
            if (strncmp("density",option+1,3) == 0)
              {
!               image_info.density=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -density",(char *) NULL);
!                   image_info.density=argv[i];
                  }
                break;
              }
--- 495,507 ----
              }
            if (strncmp("density",option+1,3) == 0)
              {
!               density=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -density",(char *) NULL);
!                   density=argv[i];
                  }
                break;
              }
***************
*** 507,525 ****
              }
            if (strncmp("display",option+1,3) == 0)
              {
!               image_info.server_name=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if (i == argc)
                      Error("Missing server name on -display",(char *) NULL);
!                   image_info.server_name=argv[i];
                  }
                break;
              }
            if (strncmp("dither",option+1,3) == 0)
              {
!               image_info.dither=(*option == '-');
                break;
              }
            Error("Unrecognized option",option);
--- 512,530 ----
              }
            if (strncmp("display",option+1,3) == 0)
              {
!               server_name=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if (i == argc)
                      Error("Missing server name on -display",(char *) NULL);
!                   server_name=argv[i];
                  }
                break;
              }
            if (strncmp("dither",option+1,3) == 0)
              {
!               resource_info.dither=(*option == '-');
                break;
              }
            Error("Unrecognized option",option);
***************
*** 534,546 ****
          {
            if (strncmp("geometry",option+1,2) == 0)
              {
!               image_info.geometry=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -geometry",(char *) NULL);
!                   image_info.geometry=argv[i];
                  }
                break;
              }
--- 539,551 ----
          {
            if (strncmp("geometry",option+1,2) == 0)
              {
!               resource_info.image_geometry=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -geometry",(char *) NULL);
!                   resource_info.image_geometry=argv[i];
                  }
                break;
              }
***************
*** 556,562 ****
          {
            if (strncmp("interlace",option+1,3) == 0)
              {
!               image_info.interlace=NoneInterlace;
                if (*option == '-')
                  {
                    i++;
--- 561,567 ----
          {
            if (strncmp("interlace",option+1,3) == 0)
              {
!               interlace=NoneInterlace;
                if (*option == '-')
                  {
                    i++;
***************
*** 563,576 ****
                    if (i == argc)
                      Error("Missing type on -interlace",(char *) NULL);
                    option=argv[i];
!                   image_info.interlace=UndefinedInterlace;
                    if (Latin1Compare("none",option) == 0)
!                     image_info.interlace=NoneInterlace;
                    if (Latin1Compare("line",option) == 0)
!                     image_info.interlace=LineInterlace;
                    if (Latin1Compare("plane",option) == 0)
!                     image_info.interlace=PlaneInterlace;
!                   if (image_info.interlace == UndefinedInterlace)
                      Error("Invalid interlace type on -interlace",option);
                  }
                break;
--- 568,581 ----
                    if (i == argc)
                      Error("Missing type on -interlace",(char *) NULL);
                    option=argv[i];
!                   interlace=UndefinedInterlace;
                    if (Latin1Compare("none",option) == 0)
!                     interlace=NoneInterlace;
                    if (Latin1Compare("line",option) == 0)
!                     interlace=LineInterlace;
                    if (Latin1Compare("plane",option) == 0)
!                     interlace=PlaneInterlace;
!                   if (interlace == UndefinedInterlace)
                      Error("Invalid interlace type on -interlace",option);
                  }
                break;
***************
*** 599,606 ****
          {
            if (strncmp("monochrome",option+1,2) == 0)
              {
!               image_info.monochrome=(*option == '-');
!               if (image_info.monochrome)
                  {
                    resource_info.number_colors=2;
                    resource_info.tree_depth=8;
--- 604,611 ----
          {
            if (strncmp("monochrome",option+1,2) == 0)
              {
!               resource_info.monochrome=(*option == '-');
!               if (resource_info.monochrome)
                  {
                    resource_info.number_colors=2;
                    resource_info.tree_depth=8;
***************
*** 623,635 ****
          {
            if (strncmp("page",option+1,2) == 0)
              {
!               image_info.page=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing page geometry on -page",(char *) NULL);
!                   image_info.page=argv[i];
                  }
                break;
              }
--- 628,640 ----
          {
            if (strncmp("page",option+1,2) == 0)
              {
!               page_geometry=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing page geometry on -page",(char *) NULL);
!                   page_geometry=argv[i];
                  }
                break;
              }
***************
*** 641,647 ****
            i++;
            if ((i == argc) || !sscanf(argv[i],"%d",&x))
              Error("Missing quality on -quality",(char *) NULL);
!           image_info.quality=atoi(argv[i]);
            break;
          }
          case 'r':
--- 646,652 ----
            i++;
            if ((i == argc) || !sscanf(argv[i],"%d",&x))
              Error("Missing quality on -quality",(char *) NULL);
!           quality=atoi(argv[i]);
            break;
          }
          case 'r':
***************
*** 706,712 ****
          }
          case 'v':
          {
!           image_info.verbose=(*option == '-');
            break;
          }
          default:
--- 711,717 ----
          }
          case 'v':
          {
!           verbose=(*option == '-');
            break;
          }
          default:
***************
*** 721,728 ****
    /*
      Read image from X server.
    */
!   if (target_window != (char *) NULL)
!     (void) strcpy(image_info.filename,target_window);
    if (resource_info.delay != 0)
      (void) sleep(resource_info.delay);
    start_time=time((time_t *) NULL);
--- 726,741 ----
    /*
      Read image from X server.
    */
!   GetImageInfo(target_window,&image_info);
!   image_info.server_name=resource_info.server_name;
!   image_info.font=resource_info.font;
!   image_info.geometry=resource_info.image_geometry;
!   image_info.density=density;
!   image_info.page=page_geometry;
!   image_info.interlace=interlace;
!   image_info.monochrome=resource_info.monochrome;
!   image_info.quality=quality;
!   image_info.verbose=verbose;
    if (resource_info.delay != 0)
      (void) sleep(resource_info.delay);
    start_time=time((time_t *) NULL);
***************
*** 736,744 ****
    else
      CommentImage(image,"  Imported from %m image: %f");
    /*
!     Transform image as defined by the crop, image and scale geometries.
    */
!   TransformImage(&image,crop_geometry,image_info.geometry);
    if ((degrees % 360) != 0)
      {
        Colormap
--- 749,757 ----
    else
      CommentImage(image,"  Imported from %m image: %f");
    /*
!     Transform image as defined by the clip, image and scale geometries.
    */
!   TransformImage(&image,clip_geometry,resource_info.image_geometry);
    if ((degrees % 360) != 0)
      {
        Colormap
***************
*** 779,787 ****
            (image->colors > resource_info.number_colors) ||
            (resource_info.colorspace == GRAYColorspace))
          QuantizeImage(image,resource_info.number_colors,
!           resource_info.tree_depth,image_info.dither,resource_info.colorspace,
!           True);
!       if (image_info.verbose)
          {
            /*
              Measure quantization error.
--- 792,800 ----
            (image->colors > resource_info.number_colors) ||
            (resource_info.colorspace == GRAYColorspace))
          QuantizeImage(image,resource_info.number_colors,
!           resource_info.tree_depth,resource_info.dither,
!           resource_info.colorspace,True);
!       if (verbose)
          {
            /*
              Measure quantization error.
***************
*** 802,808 ****
    (void) strcpy(image->magick,"PS");
    (void) strcpy(image->filename,filename);
    (void) WriteImage(&image_info,image);
!   if (image_info.verbose)
      {
        /*
          Display detailed info about the image.
--- 815,821 ----
    (void) strcpy(image->magick,"PS");
    (void) strcpy(image->filename,filename);
    (void) WriteImage(&image_info,image);
!   if (verbose)
      {
        /*
          Display detailed info about the image.
diff -c -r ImageMagick-3.1/import.man ImageMagick/import.man
*** ImageMagick-3.1/import.man	Wed Jul 13 10:52:15 1994
--- ImageMagick/import.man	Wed Jun  1 22:12:56 1994
***************
*** 47,52 ****
--- 47,60 ----
  .TP 5
  .B "-border"
  include image borders in the output image.
+ .TP 5
+ .B "-clip \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
+ preferred size and location of the clipped image.  See \fBX(1)\fP for details
+ about the geometry specification.
+  
+ Use clipping to crop a particular area of an image.   Use \fB-clip
+ 0x0\fP to remove edges that are the background color.
+ .TP 5
  .B "-colors \fIvalue\fP"
  preferred number of colors in the image.
   
***************
*** 99,112 ****
  Specify \fB\+compress\fP to store the binary image in an uncompressed format.
  The default is the compression type of the specified image file.
  .TP 5
- .B "-crop \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
- preferred size and location of the cropped image.  See \fBX(1)\fP for details
- about the geometry specification.
-  
- Use cropping to crop a particular area of an image.   Use \fB-crop
- 0x0\fP to remove edges that are the background color.
- .TP 5
- .TP 5
  .B "-delay \fIseconds\fP"
  pause before selecting target window.
  
--- 107,112 ----
***************
*** 207,213 ****
  picas or a TEXT page in pixels.  The default for a Postscript page is
  to center the image on a letter page 612 by 792 dots per inch.  The
  left and right margins are 18 picas and the top and bottom 94 picas
! (i.e.  612x792+36+36).  Other common sizes are:
  
      540x720   Note
      612x1008  Legal
--- 207,213 ----
  picas or a TEXT page in pixels.  The default for a Postscript page is
  to center the image on a letter page 612 by 792 dots per inch.  The
  left and right margins are 18 picas and the top and bottom 94 picas
! (i.e.  612x792+18+94).  Other common sizes are:
  
      540x720   Note
      612x1008  Legal
diff -c -r ImageMagick-3.1/magick/X.c ImageMagick/magick/X.c
*** ImageMagick-3.1/magick/X.c	Wed Jul 13 10:52:12 1994
--- ImageMagick/magick/X.c	Fri Jun  3 15:30:38 1994
***************
*** 646,653 ****
    */
    width=image->columns;
    height=image->rows;
!   if (window->crop_geometry)
!     (void) XParseGeometry(window->crop_geometry,&i,&i,&width,&height);
    /*
      Look for an icon size that maintains the aspect ratio of image.
    */
--- 646,653 ----
    */
    width=image->columns;
    height=image->rows;
!   if (window->clip_geometry)
!     (void) XParseGeometry(window->clip_geometry,&i,&i,&width,&height);
    /*
      Look for an icon size that maintains the aspect ratio of image.
    */
***************
*** 2450,2456 ****
      y;
  
    RectangleInfo
!     crop_info;
  
    unsigned int
      status;
--- 2450,2456 ----
      y;
  
    RectangleInfo
!     clip_info;
  
    unsigned int
      status;
***************
*** 2470,2476 ****
    /*
      Choose a pixel from the X server.
    */
!   target_window=XSelectWindow(display,&crop_info);
    root_window=XRootWindow(display,XDefaultScreen(display));
    client_window=target_window;
    if (target_window != root_window)
--- 2470,2476 ----
    /*
      Choose a pixel from the X server.
    */
!   target_window=XSelectWindow(display,&clip_info);
    root_window=XRootWindow(display,XDefaultScreen(display));
    client_window=target_window;
    if (target_window != root_window)
***************
*** 2497,2504 ****
    /*
      Get window X image.
    */
!   XTranslateCoordinates(display,root_window,target_window,crop_info.x,
!     crop_info.y,&x,&y,&child);
    ximage=XGetImage(display,target_window,x,y,1,1,AllPlanes,ZPixmap);
    if (ximage == (XImage *) NULL)
      return(False);
--- 2497,2504 ----
    /*
      Get window X image.
    */
!   XTranslateCoordinates(display,root_window,target_window,clip_info.x,
!     clip_info.y,&x,&y,&child);
    ximage=XGetImage(display,target_window,x,y,1,1,AllPlanes,ZPixmap);
    if (ximage == (XImage *) NULL)
      return(False);
***************
*** 2590,2596 ****
      y_offset;
  
    RectangleInfo
!     crop_info;
  
    register int
      i,
--- 2590,2596 ----
      y_offset;
  
    RectangleInfo
!     clip_info;
  
    register int
      i,
***************
*** 2629,2686 ****
    if ((status == False) || (window_attributes.map_state != IsViewable))
      return((Image *) NULL);
    /*
!     Cropping rectangle is relative to root window.
    */
    root_window=XRootWindow(display,XDefaultScreen(display));
    XTranslateCoordinates(display,window,root_window,0,0,&x_offset,&y_offset,
      &child);
!   crop_info.x=x_offset;
!   crop_info.y=y_offset;
!   crop_info.width=window_attributes.width;
!   crop_info.height=window_attributes.height;
    if (borders)
      {
        /*
          Include border in image.
        */
!       crop_info.x-=window_attributes.border_width;
!       crop_info.y-=window_attributes.border_width;
!       crop_info.width+=window_attributes.border_width << 1;
!       crop_info.height+=window_attributes.border_width << 1;
      }
    /*
!     Crop to root window.
    */
!   if (crop_info.x < 0)
      {
!       if ((crop_info.x+(int) crop_info.width) < 0)
          return((Image *) NULL);
!       crop_info.width+=crop_info.x;
!       crop_info.x=0;
      }
!   if (crop_info.y < 0)
      {
!       if ((crop_info.y+(int) crop_info.height) < 0)
          return((Image *) NULL);
!       crop_info.height+=crop_info.y;
!       crop_info.y=0;
      }
    display_width=XDisplayWidth(display,XDefaultScreen(display));
!   if ((crop_info.x+(int) crop_info.width) > display_width)
      {
!       if (crop_info.x >= display_width)
          return((Image *) NULL);
!       crop_info.width=display_width-crop_info.x;
      }
    display_height=XDisplayHeight(display,XDefaultScreen(display));
!   if ((crop_info.y+(int) crop_info.height) > display_height)
      {
!       if (crop_info.y >= display_height)
          return((Image *) NULL);
!       crop_info.height=display_height-crop_info.y;
      }
!   crop_info.x-=x_offset;
!   crop_info.y-=y_offset;
    /*
      Alert user we are about to get an X region by flashing a border.
    */
--- 2629,2686 ----
    if ((status == False) || (window_attributes.map_state != IsViewable))
      return((Image *) NULL);
    /*
!     Clipping rectangle is relative to root window.
    */
    root_window=XRootWindow(display,XDefaultScreen(display));
    XTranslateCoordinates(display,window,root_window,0,0,&x_offset,&y_offset,
      &child);
!   clip_info.x=x_offset;
!   clip_info.y=y_offset;
!   clip_info.width=window_attributes.width;
!   clip_info.height=window_attributes.height;
    if (borders)
      {
        /*
          Include border in image.
        */
!       clip_info.x-=window_attributes.border_width;
!       clip_info.y-=window_attributes.border_width;
!       clip_info.width+=window_attributes.border_width << 1;
!       clip_info.height+=window_attributes.border_width << 1;
      }
    /*
!     Clip to root window.
    */
!   if (clip_info.x < 0)
      {
!       if ((clip_info.x+(int) clip_info.width) < 0)
          return((Image *) NULL);
!       clip_info.width+=clip_info.x;
!       clip_info.x=0;
      }
!   if (clip_info.y < 0)
      {
!       if ((clip_info.y+(int) clip_info.height) < 0)
          return((Image *) NULL);
!       clip_info.height+=clip_info.y;
!       clip_info.y=0;
      }
    display_width=XDisplayWidth(display,XDefaultScreen(display));
!   if ((clip_info.x+(int) clip_info.width) > display_width)
      {
!       if (clip_info.x >= display_width)
          return((Image *) NULL);
!       clip_info.width=display_width-clip_info.x;
      }
    display_height=XDisplayHeight(display,XDefaultScreen(display));
!   if ((clip_info.y+(int) clip_info.height) > display_height)
      {
!       if (clip_info.y >= display_height)
          return((Image *) NULL);
!       clip_info.height=display_height-clip_info.y;
      }
!   clip_info.x-=x_offset;
!   clip_info.y-=y_offset;
    /*
      Alert user we are about to get an X region by flashing a border.
    */
***************
*** 2694,2708 ****
      GCFunction | GCPlaneMask | GCSubwindowMode,&context_values);
    if (annotate_context != (GC) NULL)
      {
!       XHighlightRegion(display,window,annotate_context,&crop_info);
        XDelay(display,(unsigned long) (SuspendTime << 2));
!       XHighlightRegion(display,window,annotate_context,&crop_info);
      }
    /*
      Get window X image.
    */
!   ximage=XGetImage(display,window,crop_info.x,crop_info.y,crop_info.width,
!     crop_info.height,AllPlanes,ZPixmap);
    if (ximage == (XImage *) NULL)
      return((Image *) NULL);
    number_colors=0;
--- 2694,2708 ----
      GCFunction | GCPlaneMask | GCSubwindowMode,&context_values);
    if (annotate_context != (GC) NULL)
      {
!       XHighlightRegion(display,window,annotate_context,&clip_info);
        XDelay(display,(unsigned long) (SuspendTime << 2));
!       XHighlightRegion(display,window,annotate_context,&clip_info);
      }
    /*
      Get window X image.
    */
!   ximage=XGetImage(display,window,clip_info.x,clip_info.y,clip_info.width,
!     clip_info.height,AllPlanes,ZPixmap);
    if (ximage == (XImage *) NULL)
      return((Image *) NULL);
    number_colors=0;
***************
*** 2935,2943 ****
        /*
          Alert user we got the X region by flashing a border.
        */
!       XHighlightRegion(display,window,annotate_context,&crop_info);
        XFlush(display);
!       XHighlightRegion(display,window,annotate_context,&crop_info);
        XFreeGC(display,annotate_context);
      }
    if (level != 0)
--- 2935,2943 ----
        /*
          Alert user we got the X region by flashing a border.
        */
!       XHighlightRegion(display,window,annotate_context,&clip_info);
        XFlush(display);
!       XHighlightRegion(display,window,annotate_context,&clip_info);
        XFreeGC(display,annotate_context);
      }
    if (level != 0)
***************
*** 2972,2981 ****
                  */
                  XTranslateCoordinates(display,children[i],window,0,0,&x_offset,
                    &y_offset,&child);
!                 x_offset-=crop_info.x;
                  if (x_offset < 0)
                    x_offset=0;
!                 y_offset-=crop_info.y;
                  if (y_offset < 0)
                    y_offset=0;
                  CompositeImage(image,ReplaceCompositeOp,child_image,x_offset,
--- 2972,2981 ----
                  */
                  XTranslateCoordinates(display,children[i],window,0,0,&x_offset,
                    &y_offset,&child);
!                 x_offset-=clip_info.x;
                  if (x_offset < 0)
                    x_offset=0;
!                 y_offset-=clip_info.y;
                  if (y_offset < 0)
                    y_offset=0;
                  CompositeImage(image,ReplaceCompositeOp,child_image,x_offset,
***************
*** 3070,3098 ****
    /*
      Initialize window info.
    */
-   if (window->id != (Window) NULL)
-     {
-       XFreeCursor(display,window->cursor);
-       XFreeCursor(display,window->busy_cursor);
-       if (window->highlight_stipple != (Pixmap) NULL)
-         XFreePixmap(display,window->highlight_stipple);
-       if (window->shadow_stipple != (Pixmap) NULL)
-         XFreePixmap(display,window->shadow_stipple);
-     }
-   else
-     {
-       window->id=(Window) NULL;
-       window->ximage=(XImage *) NULL;
-       window->matte_image=(XImage *) NULL;
-       window->pixmap=(Pixmap) NULL;
-       window->matte_pixmap=(Pixmap) NULL;
-       window->mapped=False;
-       window->stasis=False;
-       window->shared_memory=False;
- #ifdef HasSharedMemory
-       window->shared_memory=XShmQueryExtension(display);
- #endif
-     }
    window->screen=visual_info->screen;
    window->visual=visual_info->visual;
    window->class=visual_info->class;
--- 3070,3075 ----
***************
*** 3107,3113 ****
    window->geometry=(char *) NULL;
    window->icon_name=(char *) NULL;
    window->icon_geometry=resource_info->icon_geometry;
!   window->crop_geometry=(char *) NULL;
    window->flags=PSize;
    window->x=0;
    window->y=0;
--- 3084,3090 ----
    window->geometry=(char *) NULL;
    window->icon_name=(char *) NULL;
    window->icon_geometry=resource_info->icon_geometry;
!   window->clip_geometry=(char *) NULL;
    window->flags=PSize;
    window->x=0;
    window->y=0;
***************
*** 3139,3144 ****
--- 3116,3131 ----
    window->attributes.override_redirect=False;
    window->attributes.save_under=False;
    window->attributes.win_gravity=NorthWestGravity;
+   if (window->id == (Window) NULL)
+     {
+       window->id=(Window) NULL;
+       window->ximage=(XImage *) NULL;
+       window->matte_image=(XImage *) NULL;
+       window->pixmap=(Pixmap) NULL;
+       window->matte_pixmap=(Pixmap) NULL;
+       window->mapped=False;
+       window->stasis=False;
+     }
  }
  
  /*
***************
*** 3257,3263 ****
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
  %  Function XListColors reads the X client color database and returns a list
! %  of colors contained in the database sorted in ascending alphabetic order.
  %
  %  The format of the XListColors function is:
  %
--- 3244,3250 ----
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
  %  Function XListColors reads the X client color database and returns a list
! %  of colors contained in the database sorted in ascending mattebetic order.
  %
  %  The format of the XListColors function is:
  %
***************
*** 3531,3541 ****
    int
      format;
  
- #ifdef HasSharedMemory
-   static XShmSegmentInfo
-     segment_info;
- #endif
- 
    XImage
      *matte_image,
      *ximage;
--- 3518,3523 ----
***************
*** 3553,3579 ****
        /*
          Apply user transforms to the image.
        */
!       if (window->crop_geometry)
          {
            Image
!             *cropped_image;
  
            RectangleInfo
!             crop_info;
  
            /*
!             Crop image.
            */
!           (void) XParseGeometry(window->crop_geometry,&crop_info.x,&crop_info.y,
!             &crop_info.width,&crop_info.height);
            transformed_image->orphan=True;
!           cropped_image=CropImage(transformed_image,&crop_info);
            transformed_image->orphan=False;
            if (transformed_image != image)
              DestroyImage(transformed_image);
!           if (cropped_image == (Image *) NULL)
              return(False);
!           transformed_image=cropped_image;
          }
        if ((width != transformed_image->columns) ||
            (height != transformed_image->rows))
--- 3535,3561 ----
        /*
          Apply user transforms to the image.
        */
!       if (window->clip_geometry)
          {
            Image
!             *clipped_image;
  
            RectangleInfo
!             clip_info;
  
            /*
!             Clip image.
            */
!           (void) XParseGeometry(window->clip_geometry,&clip_info.x,&clip_info.y,
!             &clip_info.width,&clip_info.height);
            transformed_image->orphan=True;
!           clipped_image=ClipImage(transformed_image,&clip_info);
            transformed_image->orphan=False;
            if (transformed_image != image)
              DestroyImage(transformed_image);
!           if (clipped_image == (Image *) NULL)
              return(False);
!           transformed_image=clipped_image;
          }
        if ((width != transformed_image->columns) ||
            (height != transformed_image->rows))
***************
*** 3603,3623 ****
      Create X image.
    */
    format=(window->depth == 1) ? XYBitmap : ZPixmap;
! #ifdef HasSharedMemory
!   if (window->shared_memory)
!     {
!       ximage=XShmCreateImage(display,window->visual,window->depth,format,0,
!         &segment_info,width,height);
!       segment_info.shmid=shmget(IPC_PRIVATE,ximage->bytes_per_line*
!         ximage->height,IPC_CREAT | 0777);
!       window->shared_memory=segment_info.shmid >= 0;
!       if (window->shared_memory)
!         segment_info.shmaddr=(char *) shmat(segment_info.shmid,0,0);
!     }
! #endif
!   if (!window->shared_memory)
!     ximage=XCreateImage(display,window->visual,window->depth,format,0,
!       (char *) NULL,width,height,XBitmapPad(display),0);
    if (ximage == (XImage *) NULL)
      {
        /*
--- 3585,3592 ----
      Create X image.
    */
    format=(window->depth == 1) ? XYBitmap : ZPixmap;
!   ximage=XCreateImage(display,window->visual,window->depth,format,0,
!     (char *) NULL,width,height,XBitmapPad(display),0);
    if (ximage == (XImage *) NULL)
      {
        /*
***************
*** 3644,3663 ****
    /*
      Allocate X image pixel data.
    */
! #ifdef HasSharedMemory
!   if (window->shared_memory)
!     {
!       segment_info.readOnly=False;
!       XShmAttach(display,&segment_info);
!       ximage->data=segment_info.shmaddr;
!     }
! #endif
!   if (!window->shared_memory)
!     if (ximage->format == XYBitmap)
!       ximage->data=(char *)
!         malloc(ximage->bytes_per_line*ximage->height*ximage->depth);
!     else
!       ximage->data=(char *) malloc(ximage->bytes_per_line*ximage->height);
    if (ximage->data == (char *) NULL)
      {
        /*
--- 3613,3623 ----
    /*
      Allocate X image pixel data.
    */
!   if (ximage->format == XYBitmap)
!     ximage->data=(char *)
!       malloc(ximage->bytes_per_line*ximage->height*ximage->depth);
!   else
!     ximage->data=(char *) malloc(ximage->bytes_per_line*ximage->height);
    if (ximage->data == (char *) NULL)
      {
        /*
***************
*** 3668,3689 ****
        return(False);
      }
    if (window->ximage != (XImage *) NULL)
!     {
! #ifdef HasSharedMemory
!       if (window->shared_memory)
!         {
!           XShmDetach(display,&window->segment_info);
!           XDestroyImage(window->ximage);
!           shmdt(window->segment_info.shmaddr);
!           shmctl(window->segment_info.shmid,IPC_RMID,0);
!         }
! #endif
!       if (!window->shared_memory)
!         XDestroyImage(window->ximage);
!     }
! #ifdef HasSharedMemory
!   window->segment_info=segment_info;
! #endif
    window->ximage=ximage;
    matte_image=(XImage *) NULL;
    if (transformed_image != (Image *) NULL)
--- 3628,3634 ----
        return(False);
      }
    if (window->ximage != (XImage *) NULL)
!     XDestroyImage(window->ximage);
    window->ximage=ximage;
    matte_image=(XImage *) NULL;
    if (transformed_image != (Image *) NULL)
***************
*** 3699,3706 ****
              /*
                Allocate matte image pixel data.
              */
!             matte_image->data=(char *) malloc(matte_image->bytes_per_line*
!               matte_image->height*matte_image->depth);
              if (matte_image->data == (char *) NULL)
                {
                  XDestroyImage(matte_image);
--- 3644,3651 ----
              /*
                Allocate matte image pixel data.
              */
!             matte_image->data=(char *)
!               malloc(matte_image->bytes_per_line*matte_image->height);
              if (matte_image->data == (char *) NULL)
                {
                  XDestroyImage(matte_image);
***************
*** 4273,4279 ****
          for (j=0; j <= ((int) p->length); j++)
          {
            byte>>=1;
!           if (p->index == TransparentIndex)
              byte|=0x01;
            bit++;
            if (bit == 8)
--- 4218,4224 ----
          for (j=0; j <= ((int) p->length); j++)
          {
            byte>>=1;
!           if (p->index != 0)
              byte|=0x01;
            bit++;
            if (bit == 8)
***************
*** 4821,4827 ****
          for (j=0; j <= ((int) p->length); j++)
          {
            byte<<=1;
!           if (p->index == TransparentIndex)
              byte|=0x01;
            bit++;
            if (bit == 8)
--- 4766,4772 ----
          for (j=0; j <= ((int) p->length); j++)
          {
            byte<<=1;
!           if (p->index != 0)
              byte|=0x01;
            bit++;
            if (bit == 8)
***************
*** 5335,5348 ****
    /*
      Copy X image to pixmap.
    */
! #ifdef HasSharedMemory
!   if (window->shared_memory)
!     XShmPutImage(display,window->pixmap,window->annotate_context,window->ximage,
!       0,0,0,0,width,height,True);
! #endif
!   if (!window->shared_memory)
!     XPutImage(display,window->pixmap,window->annotate_context,window->ximage,
!       0,0,0,0,width,height);
    if (window->matte_image != (XImage *) NULL)
      {
        /*
--- 5280,5287 ----
    /*
      Copy X image to pixmap.
    */
!   XPutImage(display,window->pixmap,window->annotate_context,window->ximage,
!     0,0,0,0,width,height);
    if (window->matte_image != (XImage *) NULL)
      {
        /*
***************
*** 6266,6284 ****
            x+window->x,y+window->y,width,height,x,y,1L);
      }
    else
!     {
! #ifdef HasSharedMemory
!       if (window->shared_memory)
!         {
!           XShmPutImage(display,window->id,window->annotate_context,
!             window->ximage,x+window->x,y+window->y,x,y,width,height,True);
!           XSync(display,False);
!         }
! #endif
!       if (!window->shared_memory)
!         XPutImage(display,window->id,window->annotate_context,window->ximage,
!           x+window->x,y+window->y,x,y,width,height);
!     }
  }
  
  /*
--- 6205,6212 ----
            x+window->x,y+window->y,width,height,x,y,1L);
      }
    else
!     XPutImage(display,window->id,window->annotate_context,window->ximage,
!       x+window->x,y+window->y,x,y,width,height);
  }
  
  /*
***************
*** 6353,6364 ****
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
  %  Function XSelectWindow allows a user to select a window using the mouse.  If
! %  the mouse moves, a cropping rectangle is drawn and the extents of the
! %  rectangle is returned in the crop_info structure.
  %
  %  The format of the XSelectWindow function is:
  %
! %      target_window=XSelectWindow(display,crop_info)
  %
  %  A description of each parameter follows:
  %
--- 6281,6292 ----
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
  %  Function XSelectWindow allows a user to select a window using the mouse.  If
! %  the mouse moves, a clipping rectangle is drawn and the extents of the
! %  rectangle is returned in the clip_info structure.
  %
  %  The format of the XSelectWindow function is:
  %
! %      target_window=XSelectWindow(display,clip_info)
  %
  %  A description of each parameter follows:
  %
***************
*** 6367,6385 ****
  %    o display: Specifies a pointer to the Display structure;  returned from
  %      XOpenDisplay.
  %
! %    o crop_info: Specifies a pointer to a RectangleInfo structure.  It
! %      contains the extents of any cropping rectangle.
  %
  %
  */
! Window XSelectWindow(display,crop_info)
  Display
    *display;
  
  RectangleInfo
!   *crop_info;
  {
! #define MinimumCropArea  (unsigned int) 9
  
    Cursor
      target_cursor;
--- 6295,6313 ----
  %    o display: Specifies a pointer to the Display structure;  returned from
  %      XOpenDisplay.
  %
! %    o clip_info: Specifies a pointer to a RectangleInfo structure.  It
! %      contains the extents of any clipping rectangle.
  %
  %
  */
! Window XSelectWindow(display,clip_info)
  Display
    *display;
  
  RectangleInfo
!   *clip_info;
  {
! #define MinimumClipArea  (unsigned int) 9
  
    Cursor
      target_cursor;
***************
*** 6430,6437 ****
    /*
      Select a window.
    */
!   crop_info->width=0;
!   crop_info->height=0;
    presses=0;
    target_window=(Window) NULL;
    x_offset=0;
--- 6358,6365 ----
    /*
      Select a window.
    */
!   clip_info->width=0;
!   clip_info->height=0;
    presses=0;
    target_window=(Window) NULL;
    x_offset=0;
***************
*** 6438,6446 ****
    y_offset=0;
    do
    {
!     if ((crop_info->width*crop_info->height) >= MinimumCropArea)
!       XDrawRectangle(display,root_window,annotate_context,crop_info->x,
!         crop_info->y,crop_info->width-1,crop_info->height-1);
      /*
        Allow another event.
      */
--- 6366,6374 ----
    y_offset=0;
    do
    {
!     if ((clip_info->width*clip_info->height) >= MinimumClipArea)
!       XDrawRectangle(display,root_window,annotate_context,clip_info->x,
!         clip_info->y,clip_info->width-1,clip_info->height-1);
      /*
        Allow another event.
      */
***************
*** 6447,6455 ****
      XAllowEvents(display,SyncPointer,CurrentTime);
      XWindowEvent(display,root_window,ButtonPressMask | ButtonReleaseMask |
        ButtonMotionMask,&event);
!     if ((crop_info->width*crop_info->height) >= MinimumCropArea)
!       XDrawRectangle(display,root_window,annotate_context,crop_info->x,
!         crop_info->y,crop_info->width-1,crop_info->height-1);
      switch (event.type)
      {
        case ButtonPress:
--- 6375,6383 ----
      XAllowEvents(display,SyncPointer,CurrentTime);
      XWindowEvent(display,root_window,ButtonPressMask | ButtonReleaseMask |
        ButtonMotionMask,&event);
!     if ((clip_info->width*clip_info->height) >= MinimumClipArea)
!       XDrawRectangle(display,root_window,annotate_context,clip_info->x,
!         clip_info->y,clip_info->width-1,clip_info->height-1);
      switch (event.type)
      {
        case ButtonPress:
***************
*** 6462,6471 ****
            }
          x_offset=event.xbutton.x_root;
          y_offset=event.xbutton.y_root;
!         crop_info->x=x_offset;
!         crop_info->y=y_offset;
!         crop_info->width=0;
!         crop_info->height=0;
          presses++;
          break;
        }
--- 6390,6399 ----
            }
          x_offset=event.xbutton.x_root;
          y_offset=event.xbutton.y_root;
!         clip_info->x=x_offset;
!         clip_info->y=y_offset;
!         clip_info->width=0;
!         clip_info->height=0;
          presses++;
          break;
        }
***************
*** 6480,6503 ****
            Discard pending button motion events.
          */
          while (XCheckMaskEvent(display,ButtonMotionMask,&event));
!         crop_info->x=event.xmotion.x;
!         crop_info->y=event.xmotion.y;
          /*
            Check boundary conditions.
          */
!         if (crop_info->x < x_offset)
!           crop_info->width=(unsigned int) (x_offset-crop_info->x);
          else
            {
!             crop_info->width=(unsigned int) (crop_info->x-x_offset);
!             crop_info->x=x_offset;
            }
!         if (crop_info->y < y_offset)
!           crop_info->height=(unsigned int) (y_offset-crop_info->y);
          else
            {
!             crop_info->height=(unsigned int) (crop_info->y-y_offset);
!             crop_info->y=y_offset;
            }
        }
        default:
--- 6408,6431 ----
            Discard pending button motion events.
          */
          while (XCheckMaskEvent(display,ButtonMotionMask,&event));
!         clip_info->x=event.xmotion.x;
!         clip_info->y=event.xmotion.y;
          /*
            Check boundary conditions.
          */
!         if (clip_info->x < x_offset)
!           clip_info->width=(unsigned int) (x_offset-clip_info->x);
          else
            {
!             clip_info->width=(unsigned int) (clip_info->x-x_offset);
!             clip_info->x=x_offset;
            }
!         if (clip_info->y < y_offset)
!           clip_info->height=(unsigned int) (y_offset-clip_info->y);
          else
            {
!             clip_info->height=(unsigned int) (clip_info->y-y_offset);
!             clip_info->y=y_offset;
            }
        }
        default:
***************
*** 6508,6519 ****
    XUngrabPointer(display,CurrentTime);
    XFreeCursor(display,target_cursor);
    XFreeGC(display,annotate_context);
!   if ((crop_info->width*crop_info->height) < MinimumCropArea)
      {
!       crop_info->width=0;
!       crop_info->height=0;
      }
!   if ((crop_info->width != 0) && (crop_info->height != 0))
      target_window=root_window;
    return(target_window);
  }
--- 6436,6447 ----
    XUngrabPointer(display,CurrentTime);
    XFreeCursor(display,target_cursor);
    XFreeGC(display,annotate_context);
!   if ((clip_info->width*clip_info->height) < MinimumClipArea)
      {
!       clip_info->width=0;
!       clip_info->height=0;
      }
!   if ((clip_info->width != 0) && (clip_info->height != 0))
      target_window=root_window;
    return(target_window);
  }
diff -c -r ImageMagick-3.1/magick/X.h ImageMagick/magick/X.h
*** ImageMagick-3.1/magick/X.h	Wed Jul 13 10:52:14 1994
--- ImageMagick/magick/X.h	Thu May 26 18:01:24 1994
***************
*** 12,22 ****
  #ifdef HasShape
  #include <X11/extensions/shape.h>
  #endif
- #ifdef HasSharedMemory
- #include <sys/ipc.h>
- #include <sys/shm.h>
- #include <X11/extensions/XShm.h>
- #endif
  #undef index
  #ifdef hpux
  #undef SYSV
--- 12,17 ----
***************
*** 52,68 ****
  /*
    Define declarations.
  */
- #ifndef vms
  #define EditorCommand  "xterm -title 'Image Comment Editor' -e vi %s"
- #define PrintCommand  "lpr"
- #define RGBColorDatabase  "/usr/lib/X11/rgb.txt"
- #else
- #define EditorCommand  "cre/term edit/tpu %s"
- #define PrintCommand  "print"
- #define RGBColorDatabase  "sys$common:[sysmgr]decw$rgb.dat"
- #endif
  #define MaxNumberFonts  10
  #define MaxNumberPens  10
  #define SuspendTime  40
  #define XStandardPixel(map,color,dx)  (unsigned long) (map->base_pixel+  \
    ((color.red*map->red_max+(1 << (dx-1)))/((1 << dx)-1))*map->red_mult+  \
--- 47,57 ----
  /*
    Define declarations.
  */
  #define EditorCommand  "xterm -title 'Image Comment Editor' -e vi %s"
  #define MaxNumberFonts  10
  #define MaxNumberPens  10
+ #define PrintCommand  "lpr"
+ #define RGBColorDatabase  "/usr/lib/X11/rgb.txt"
  #define SuspendTime  40
  #define XStandardPixel(map,color,dx)  (unsigned long) (map->base_pixel+  \
    ((color.red*map->red_max+(1 << (dx-1)))/((1 << dx)-1))*map->red_mult+  \
***************
*** 258,264 ****
      *geometry,
      *icon_name,
      *icon_geometry,
!     *crop_geometry;
  
    unsigned long
      flags;
--- 247,253 ----
      *geometry,
      *icon_name,
      *icon_geometry,
!     *clip_geometry;
  
    unsigned long
      flags;
***************
*** 299,312 ****
      window_changes;
  
    unsigned int
-     shared_memory;
- 
- #ifdef HasSharedMemory
-   XShmSegmentInfo
-     segment_info;
- #endif
- 
-   unsigned int
      mapped,
      stasis;
  } XWindowInfo;
--- 288,293 ----
***************
*** 329,335 ****
      wm_delete_window,
      wm_take_focus,
      im_protocols,
!     im_update_colormap,
      im_former_image,
      im_next_image,
      im_exit;
--- 310,316 ----
      wm_delete_window,
      wm_take_focus,
      im_protocols,
!     im_window_colormap,
      im_former_image,
      im_next_image,
      im_exit;
diff -c -r ImageMagick-3.1/magick/colors.c ImageMagick/magick/colors.c
*** ImageMagick-3.1/magick/colors.c	Wed Jul 13 10:52:12 1994
--- ImageMagick/magick/colors.c	Fri Jun  3 15:22:07 1994
***************
*** 230,368 ****
  %                                                                             %
  %                                                                             %
  %                                                                             %
- %  I s P s e u d o C l a s s                                                  %
- %                                                                             %
- %                                                                             %
- %                                                                             %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- %  Function IsPseudoClass returns True if the image is PseudoClass or has 256
- %  unique colors or less.  If the image is DirectClass and has less 256 colors
- %  or less, the image is demoted to PseudoClass.
- %
- %  The format of the IsPseudoClass routine is:
- %
- %      status=IsPseudoClass(image)
- %
- %  A description of each parameter follows.
- %
- %    o status:  Function IsPseudoClass returns True is the image is
- %      PseudoClass or has 256 color or less.
- %
- %    o image: The address of a byte (8 bits) array of run-length
- %      encoded pixel data of your source image.  The sum of the
- %      run-length counts in the source image must be equal to or exceed
- %      the number of pixels.
- %
- %
- */
- unsigned int IsPseudoClass(image)
- Image
-   *image;
- {
-   Nodes
-     *nodes;
- 
-   register RunlengthPacket
-     *p;
- 
-   register int
-     i;
- 
-   register Node
-     *node;
- 
-   register unsigned int
-     count,
-     id,
-     level;
- 
-   unsigned int
-     bisect;
- 
-   if (image->class == PseudoClass)
-     return(True);
-   if (image->matte)
-     return(False);
-   /*
-     Initialize color description tree.
-   */
-   cube.node_list=(Nodes *) NULL;
-   cube.colors=0;
-   cube.free_nodes=0;
-   cube.root=InitializeNode(0,(unsigned int) (MaxRGB+1) >> 1,
-     (unsigned int) (MaxRGB+1) >> 1,(unsigned int) (MaxRGB+1) >> 1);
-   if (cube.root == (Node *) NULL)
-     {
-       Warning("Unable to count colors","Memory allocation failed");
-       return(0);
-     }
-   p=image->pixels;
-   for (i=0; ((i < image->packets) && (cube.colors <= 256)); i++)
-   {
-     /*
-       Start at the root and proceed level by level.
-     */
-     count=p->length+1;
-     node=cube.root;
-     for (level=1; level <= MaxTreeDepth; level++)
-     {
-       id=(p->red >= node->mid_red ? 1 : 0) |
-         (p->green >= node->mid_green ? 1 : 0) << 1 |
-         (p->blue >= node->mid_blue ? 1 : 0) << 2;
-       if (node->child[id] == (Node *) NULL)
-         {
-           if (level == MaxTreeDepth)
-             {
-               node->child[id]=InitializeNode(level,(unsigned int) p->red,
-                 (unsigned int) p->green,(unsigned int) p->blue);
-               cube.colors++;
-             }
-           else
-             {
-               bisect=(unsigned int) (1 << (MaxTreeDepth-level)) >> 1;
-               node->child[id]=InitializeNode(level,
-                 node->mid_red+(id & 1 ? bisect : -bisect),
-                 node->mid_green+(id & 2 ? bisect : -bisect),
-                 node->mid_blue+(id & 4 ? bisect : -bisect));
-             }
-           if (node->child[id] == (Node *) NULL)
-             {
-               Warning("Unable to count colors","Memory allocation failed");
-               return(0);
-             }
-         }
-       node=node->child[id];
-     }
-     node->number_colors+=count;
-     p++;
-   }
-   /*
-     Release color cube tree storage.
-   */
-   do
-   {
-     nodes=cube.node_list->next;
-     (void) free((char *) cube.node_list);
-     cube.node_list=nodes;
-   }
-   while (cube.node_list != (Nodes *) NULL);
-   if (cube.colors <= 256)
-     {
-       /*
-         Demote DirectClass to PseudoClass.
-       */
-       QuantizeImage(image,256,8,False,RGBColorspace,True);
-       SyncImage(image);
-     }
-   return(image->class == PseudoClass);
- }
- 
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %                                                                             %
- %                                                                             %
- %                                                                             %
  %  N u m b e r C o l o r s                                                    %
  %                                                                             %
  %                                                                             %
--- 230,235 ----
diff -c -r ImageMagick-3.1/magick/decode.c ImageMagick/magick/decode.c
*** ImageMagick-3.1/magick/decode.c	Wed Jul 13 10:52:13 1994
--- ImageMagick/magick/decode.c	Fri Jun  3 15:28:11 1994
***************
*** 1295,1300 ****
--- 1295,1301 ----
    int
      pass,
      status,
+     transparency_index,
      x,
      y;
  
***************
*** 1307,1315 ****
    register unsigned char
      *p;
  
-   short int
-     transparency_index;
- 
    unsigned char
      c,
      *global_colormap,
--- 1308,1313 ----
***************
*** 1342,1348 ****
      Determine if this is a GIF file.
    */
    status=ReadData((char *) magick,1,6,image->file);
-   status|=ReadData((char *) header,1,7,image->file);
    if ((status == False) || ((strncmp((char *) magick,"GIF87",5) != 0) &&
        (strncmp((char *) magick,"GIF89",5) != 0)))
      {
--- 1340,1345 ----
***************
*** 1350,1355 ****
--- 1347,1362 ----
        DestroyImage(image);
        return((Image *) NULL);
      }
+   /*
+     Read the screen descriptor.
+   */
+   status=ReadData((char *) header,1,7,image->file);
+   if (status == False)
+     {
+       Warning("Failed to read screen descriptor",(char *) NULL );
+       DestroyImage(image);
+       return((Image *) NULL);
+     }
    global_colors=0;
    global_colormap=(unsigned char *) NULL;
    if (BitSet(header[4],0x80))
***************
*** 1547,1553 ****
      status=LZWDecodeImage(image);
      if (status == False)
        {
!         Warning("Corrupt GIF image",image->filename);
          break;
        }
      if (interlace)
--- 1554,1560 ----
      status=LZWDecodeImage(image);
      if (status == False)
        {
!         Warning("Unable to read image data","file is truncated");
          break;
        }
      if (interlace)
***************
*** 1604,1610 ****
            if (q->index != transparency_index)
              q->index=0;
            else
!             q->index=TransparentIndex;
            q++;
          }
          transparency_index=(-1);
--- 1611,1617 ----
            if (q->index != transparency_index)
              q->index=0;
            else
!             q->index=MaxRGB;
            q++;
          }
          transparency_index=(-1);
***************
*** 1612,1625 ****
          image->matte=True;
        }
    }
!   if (global_colormap != (unsigned char *) NULL)
!     (void) free((char *) global_colormap);
!   if (image->pixels == (RunlengthPacket *) NULL)
!     {
!       Warning("Corrupt GIF image",image->filename);
!       DestroyImages(image);
!       return((Image *) NULL);
!     }
    while (image->previous != (Image *) NULL)
      image=image->previous;
    CloseImage(image);
--- 1619,1625 ----
          image->matte=True;
        }
    }
!   (void) free((char *) global_colormap);
    while (image->previous != (Image *) NULL)
      image=image->previous;
    CloseImage(image);
***************
*** 2207,2221 ****
  }
  
  #ifdef HasJPEG
! #include <setjmp.h>
! #include "jpeglib.h"
! #include "jerror.h"
! 
! static Image
!   *image;
! 
! static jmp_buf
!   error_recovery;
  
  /*
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--- 2207,2218 ----
  }
  
  #ifdef HasJPEG
! #undef FREAD
! #undef FWRITE
! #undef const
! #include "jinclude.h"
! Image
!   *jpeg_image;
  
  /*
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
***************
*** 2247,2339 ****
  %
  */
  
! static unsigned int GetCharacter(jpeg_info)
! j_decompress_ptr
    jpeg_info;
  {
!   struct jpeg_source_mgr
!     *data;
! 
!   data=jpeg_info->src;
!   if (data->bytes_in_buffer == 0)
!     (*data->fill_input_buffer) (jpeg_info);
!   data->bytes_in_buffer--;
!   return(GETJOCTET(*data->next_input_byte++));
  }
  
! static int CommentHandler(jpeg_info)
! j_decompress_ptr
    jpeg_info;
- {
-   long int
-     length;
  
    register char
      *p;
  
!   /*
!     Determine length of comment.
!   */
!   length=GetCharacter(jpeg_info) << 8;
!   length+=GetCharacter(jpeg_info);
!   length-=2;
!   if (image->comments != (char *) NULL)
!     image->comments=(char *) realloc((char *) image->comments,
!       (unsigned int) (strlen(image->comments)+length+1)*sizeof(char));
    else
      {
!       image->comments=(char *)
          malloc((unsigned int) (length+1)*sizeof(char));
!       if (image->comments != (char *) NULL)
!         *image->comments='\0';
      }
!   if (image->comments == (char *) NULL)
      {
        Warning("Memory allocation error",(char *) NULL);
!       return(False);
      }
    /*
!     Read comment.
    */
!   p=image->comments+strlen(image->comments);
!   while (--length >= 0)
!     *p++=GetCharacter(jpeg_info);
!   *p='\0';
!   return(True);
  }
  
! static void EmitMessage(jpeg_info,level)
! j_common_ptr
    jpeg_info;
  
  int
!   level;
  {
!   char
!     message[JMSG_LENGTH_MAX];
  
!   struct jpeg_error_mgr
!     *jpeg_error;
  
!   jpeg_error=jpeg_info->err;
!   (jpeg_error->format_message) (jpeg_info,message);
!   if (level < 0)
!     {
!       if ((jpeg_error->num_warnings == 0) || (jpeg_error->trace_level >= 3))
!         Warning((char *) message,image->filename);
!       jpeg_error->num_warnings++;
      }
!   else
!     if (jpeg_error->trace_level >= level)
!       Warning((char *) message,image->filename);
  }
  
! static void ErrorExit(jpeg_info)
! j_common_ptr
    jpeg_info;
  {
!   EmitMessage(jpeg_info,0);
!   longjmp(error_recovery,1);
  }
  
  static Image *ReadJPEGImage(image_info)
--- 2244,2403 ----
  %
  */
  
! static void MIFFInitializeImage(jpeg_info)
! decompress_info_ptr
    jpeg_info;
  {
!   /*
!     Create JPEG image.
!   */
!   jpeg_image->columns=jpeg_info->image_width;
!   jpeg_image->rows=jpeg_info->image_height;
!   jpeg_image->packets=jpeg_image->columns*jpeg_image->rows;
!   jpeg_image->pixels=(RunlengthPacket *)
!     malloc(jpeg_image->packets*sizeof(RunlengthPacket));
!   if (jpeg_image->pixels == (RunlengthPacket *) NULL)
!     {
!       Warning("Memory allocation error",(char *) NULL);
!       exit(1);
!     }
!   jpeg_image->packet=jpeg_image->pixels;
  }
  
! static void MIFFComment(jpeg_info,length)
! decompress_info_ptr
    jpeg_info;
  
+ long
+   length;
+ {
    register char
      *p;
  
!   if (jpeg_image->comments != (char *) NULL)
!     jpeg_image->comments=(char *) realloc((char *) jpeg_image->comments,
!       (unsigned int) (strlen(jpeg_image->comments)+length+1)*sizeof(char));
    else
      {
!       jpeg_image->comments=(char *)
          malloc((unsigned int) (length+1)*sizeof(char));
!       if (jpeg_image->comments != (char *) NULL)
!         *jpeg_image->comments='\0';
      }
!   if (jpeg_image->comments == (char *) NULL)
      {
        Warning("Memory allocation error",(char *) NULL);
!       return;
      }
+   p=jpeg_image->comments+strlen(jpeg_image->comments);
+   for ( ; length > 0; length--)
+     *p++=JGETC(jpeg_info);
+   *p='\0';
+ }
+ 
+ static void MIFFOutputTermMethod(jpeg_info)
+ decompress_info_ptr
+   jpeg_info;
+ {
+ }
+ 
+ static void MIFFWriteGRAY(jpeg_info,number_rows,pixel_data)
+ decompress_info_ptr
+   jpeg_info;
+ 
+ int
+   number_rows;
+ 
+ JSAMPIMAGE
+   pixel_data;
+ {
+   register int
+     column,
+     row;
+ 
+   register JSAMPROW
+     gray;
+ 
+   register RunlengthPacket
+     *q;
+ 
    /*
!     Transfer grayscale JPEG pixel data to MIFF pixels.
    */
!   q=jpeg_image->packet;
!   for (row=0; row < number_rows; row++)
!   {
!     gray=pixel_data[0][row];
!     for (column=jpeg_info->image_width; column > 0; column--)
!     {
!       q->red=GETJSAMPLE(*gray);
!       q->green=GETJSAMPLE(*gray);
!       q->blue=GETJSAMPLE(*gray);
!       q->index=(unsigned short) GETJSAMPLE(*gray);
!       q->length=0;
!       q++;
!       gray++;
!     }
!   }
!   jpeg_image->packet=q;
  }
  
! static void MIFFWriteRGB(jpeg_info,number_rows,pixel_data)
! decompress_info_ptr
    jpeg_info;
  
  int
!   number_rows;
! 
! JSAMPIMAGE
!   pixel_data;
  {
!   register int
!     column,
!     row;
! 
!   register JSAMPROW
!     blue,
!     green,
!     red;
  
!   register RunlengthPacket
!     *q;
  
!   /*
!     Transfer JPEG pixel data to MIFF pixels.
!   */
!   q=jpeg_image->packet;
!   for (row=0; row < number_rows; row++)
!   {
!     red=pixel_data[0][row];
!     green=pixel_data[1][row];
!     blue=pixel_data[2][row];
!     for (column=jpeg_info->image_width; column > 0; column--)
!     {
!       q->red=GETJSAMPLE(*red++);
!       q->green=GETJSAMPLE(*green++);
!       q->blue=GETJSAMPLE(*blue++);
!       q->index=0;
!       q->length=0;
!       q++;
      }
!   }
!   jpeg_image->packet=q;
  }
  
! static void MIFFSelectMethod(jpeg_info)
! decompress_info_ptr
    jpeg_info;
  {
!   jpeg_info->methods->put_pixel_rows=MIFFWriteRGB;
!   jpeg_info->out_color_space=CS_RGB;
!   if (jpeg_info->jpeg_color_space == CS_GRAYSCALE)
!     {
!       jpeg_info->out_color_space=CS_GRAYSCALE;
!       jpeg_info->methods->put_pixel_rows=MIFFWriteGRAY;
!     }
!   jpeg_info->data_precision=8;
  }
  
  static Image *ReadJPEGImage(image_info)
***************
*** 2340,2371 ****
  ImageInfo
    *image_info;
  {
!   JSAMPLE
!     *jpeg_pixels,
!     **scanlines;
! 
!   register int
!     i,
!     j;
! 
!   register JSAMPLE
!     *p;
! 
!   register RunlengthPacket
!     *q;
  
!   struct jpeg_decompress_struct
      jpeg_info;
  
!   struct jpeg_error_mgr
!     jpeg_error;
  
!   unsigned int
!     count,
!     packets;
  
    /*
!     Allocate image structure.
    */
    image=AllocateImage(image_info);
    if (image == (Image *) NULL)
--- 2404,2423 ----
  ImageInfo
    *image_info;
  {
!   Image
!     *image;
  
!   struct Decompress_info_struct
      jpeg_info;
  
!   struct Decompress_methods_struct
!     jpeg_methods;
  
!   struct External_methods_struct
!     external_methods;
  
    /*
!     Allocate jpeg_image structure.
    */
    image=AllocateImage(image_info);
    if (image == (Image *) NULL)
***************
*** 2381,2501 ****
        return((Image *) NULL);
      }
    /*
!     Initialize image structure.
    */
!   jpeg_info.err=jpeg_std_error(&jpeg_error);
!   jpeg_info.err->emit_message=EmitMessage;
!   jpeg_info.err->error_exit=ErrorExit;
!   image->pixels=(RunlengthPacket *) NULL;
!   if (setjmp(error_recovery))
!     {
!       /*
!         JPEG image is corrupt.
!       */
!       jpeg_destroy_decompress(&jpeg_info);
!       CloseImage(image);
!       if ((image->columns == 0) || (image->rows == 0))
!         {
!           DestroyImage(image);
!           return((Image *) NULL);
!         }
!       return(image);
!     }
!   jpeg_create_decompress(&jpeg_info);
!   jpeg_set_marker_processor(&jpeg_info,JPEG_COM,CommentHandler);
!   jpeg_stdio_src(&jpeg_info,image->file);
!   (void) jpeg_read_header(&jpeg_info,True);
!   jpeg_start_decompress(&jpeg_info);
!   image->columns=jpeg_info.output_width;
!   image->rows=jpeg_info.output_height;
!   image->packets=image->columns*image->rows;
!   image->pixels=(RunlengthPacket *)
!     malloc(image->packets*sizeof(RunlengthPacket));
!   packets=jpeg_info.output_components*image->rows*image->columns;
!   jpeg_pixels=(JSAMPLE *) malloc(packets*sizeof(JSAMPLE));
!   scanlines=(JSAMPLE **) malloc(image->rows*sizeof(JSAMPLE *));
!   if ((image->pixels == (RunlengthPacket *) NULL) ||
!       (jpeg_pixels == (JSAMPLE *) NULL) || (scanlines == (JSAMPLE **) NULL))
!     {
!       Warning("Memory allocation error",(char *) NULL);
!       DestroyImage(image);
!       return((Image *) NULL);
!     }
!   if (jpeg_info.out_color_space == JCS_GRAYSCALE)
      {
        /*
          Initialize grayscale colormap.
        */
!       image->class=PseudoClass;
!       image->colors=256;
!       image->colormap=(ColorPacket *) malloc(image->colors*sizeof(ColorPacket));
!       if (image->colormap == (ColorPacket *) NULL)
          {
            Warning("Unable to create image colormap","Memory allocation failed");
!           DestroyImage(image);
            return((Image *) NULL);
          }
!       for (i=0; i < image->colors; i++)
        {
!         image->colormap[i].red=(unsigned short) i;
!         image->colormap[i].green=(unsigned short) i;
!         image->colormap[i].blue=(unsigned short) i;
        }
      }
!   /*
!     Initialize image.
!   */
!   q=image->pixels;
!   for (i=0; i < image->packets; i++)
!   {
!     q->red=0;
!     q->green=0;
!     q->blue=0;
!     q->index=0;
!     q->length=0;
!     q++;
!   }
!   /*
!     Convert JPEG pixels to runlength-encoded packets.
!   */
!   for (i=0; i < image->rows; i++)
!     scanlines[i]=jpeg_pixels+(i*image->columns*jpeg_info.output_components);
!   q=image->pixels;
!   for (i=0; i < image->rows; i+=count)
!   {
!     count=jpeg_read_scanlines(&jpeg_info,scanlines+i,image->rows);
!     p=scanlines[i];
!     if (jpeg_info.out_color_space == JCS_GRAYSCALE)
!       for (j=0; j < (count*image->columns); j++)
!       {
!         q->red=(unsigned char) GETJSAMPLE(*p);
!         q->green=(unsigned char) GETJSAMPLE(*p);
!         q->blue=(unsigned char) GETJSAMPLE(*p);
!         q->index=(unsigned short) GETJSAMPLE(*p);
!         q->length=0;
!         p++;
!         q++;
!       }
!     else
!       for (j=0; j < (count*image->columns); j++)
!       {
!         q->red=(unsigned char) GETJSAMPLE(*p++);
!         q->green=(unsigned char) GETJSAMPLE(*p++);
!         q->blue=(unsigned char) GETJSAMPLE(*p++);
!         q->index=0;
!         q->length=0;
!         q++;
!       }
!   }
!   /*
!     Free memory.
!   */
!   (void) free((char *) scanlines);
!   (void) free((char *) jpeg_pixels);
!   (void) jpeg_finish_decompress(&jpeg_info);
!   jpeg_destroy_decompress(&jpeg_info);
!   CloseImage(image);
!   return(image);
  }
  #else
  static Image *ReadJPEGImage(image_info)
--- 2433,2486 ----
        return((Image *) NULL);
      }
    /*
!     Initialize the JPEG system-dependent methods.
    */
!   jpeg_image=image;
!   jpeg_info.input_file=image->file;
!   jpeg_info.output_file=(FILE *) NULL;
!   jpeg_info.methods=(&jpeg_methods);
!   jpeg_info.emethods=(&external_methods);
!   jselerror(&external_methods);
!   jselmemmgr(&external_methods);
!   jpeg_info.methods->output_init=MIFFInitializeImage;
!   jpeg_info.methods->output_term=MIFFOutputTermMethod;
!   jpeg_methods.d_ui_method_selection=MIFFSelectMethod;
!   j_d_defaults(&jpeg_info,True);
! #ifdef HUFF_LOOKAHEAD
!   jpeg_info.methods->process_comment=MIFFComment;
! #endif
!   /*
!     Read a JFIF JPEG file.
!   */
!   jselrjfif(&jpeg_info);
!   jpeg_decompress(&jpeg_info);
!   if (jpeg_info.jpeg_color_space == CS_GRAYSCALE)
      {
+       register int
+         i;
+ 
        /*
          Initialize grayscale colormap.
        */
!       jpeg_image->class=PseudoClass;
!       jpeg_image->colors=256;
!       jpeg_image->colormap=(ColorPacket *)
!         malloc(image->colors*sizeof(ColorPacket));
!       if (jpeg_image->colormap == (ColorPacket *) NULL)
          {
            Warning("Unable to create image colormap","Memory allocation failed");
!           DestroyImage(jpeg_image);
            return((Image *) NULL);
          }
!       for (i=0; i < jpeg_image->colors; i++)
        {
!         jpeg_image->colormap[i].red=(unsigned short) i;
!         jpeg_image->colormap[i].green=(unsigned short) i;
!         jpeg_image->colormap[i].blue=(unsigned short) i;
        }
      }
!   CloseImage(jpeg_image);
!   return(jpeg_image);
  }
  #else
  static Image *ReadJPEGImage(image_info)
***************
*** 2905,2911 ****
              while (isspace(c) || (c == '='))
                c=fgetc(image->file);
              p=value;
!             while (!isspace(c) && (c != EOF))
              {
                if ((p-value) < (MaxTextLength-1))
                  *p++=(char) c;
--- 2890,2896 ----
              while (isspace(c) || (c == '='))
                c=fgetc(image->file);
              p=value;
!             while (!isspace(c))
              {
                if ((p-value) < (MaxTextLength-1))
                  *p++=(char) c;
***************
*** 3470,3476 ****
      Use hpcdtoppm to convert Photo CD image.
    */
    (void) strcpy(filename,image_info->filename);
!   (void) sprintf(image_info->filename,"|hpcdtoppm %s %s",options,filename);
    image=ReadPNMImage(image_info);
    if (image == (Image *) NULL)
      {
--- 3455,3461 ----
      Use hpcdtoppm to convert Photo CD image.
    */
    (void) strcpy(filename,image_info->filename);
!   (void) sprintf(image_info->filename,"|hpcdtoppm -ppm %s %s",options,filename);
    image=ReadPNMImage(image_info);
    if (image == (Image *) NULL)
      {
***************
*** 4481,4488 ****
  
    char
      command[MaxTextLength],
!     crop_geometry[MaxTextLength],
      *device,
      filename[MaxTextLength],
      options[MaxTextLength];
  
--- 4466,4474 ----
  
    char
      command[MaxTextLength],
!     clip_geometry[MaxTextLength],
      *device,
+     *directory,
      filename[MaxTextLength],
      options[MaxTextLength];
  
***************
*** 4496,4504 ****
    ImageInfo
      postscript_info;
  
-   long int
-     filesize;
- 
    unsigned int
      showpage;
  
--- 4482,4487 ----
***************
*** 4521,4527 ****
    /*
      Open temporary output file.
    */
!   TemporaryFilename(filename);
    file=fopen(filename,"wb");
    if (file == (FILE *) NULL)
      {
--- 4504,4514 ----
    /*
      Open temporary output file.
    */
!   directory=(char *) getenv("TMPDIR");
!   if (directory == (char *) NULL)
!     directory="/tmp";
!   (void) sprintf(filename,"%s/magickXXXXXX",directory);
!   (void) mktemp(filename);
    file=fopen(filename,"wb");
    if (file == (FILE *) NULL)
      {
***************
*** 4533,4539 ****
    */
    showpage=False;
    *options='\0';
!   *crop_geometry='\0';
    while (fgets(command,MaxTextLength-1,image->file) != (char *) NULL)
    {
      showpage|=GlobExpression(command,"*showpage*");
--- 4520,4526 ----
    */
    showpage=False;
    *options='\0';
!   *clip_geometry='\0';
    while (fgets(command,MaxTextLength-1,image->file) != (char *) NULL)
    {
      showpage|=GlobExpression(command,"*showpage*");
***************
*** 4591,4602 ****
              else
                (void) sprintf(options,"-g%ux%u",height,height);
            }
!         (void) strcpy(crop_geometry,"0x0");
        }
        (void) fputs(command,file);
      }
    CloseImage(image);
-   filesize=image->filesize;
    DestroyImage(image);
    /*
      Force *showpage* operator and close files.
--- 4578,4588 ----
              else
                (void) sprintf(options,"-g%ux%u",height,height);
            }
!         (void) strcpy(clip_geometry,"0x0");
        }
        (void) fputs(command,file);
      }
    CloseImage(image);
    DestroyImage(image);
    /*
      Force *showpage* operator and close files.
***************
*** 4643,4743 ****
    do
    {
      (void) strcpy(image->filename,image_info->filename);
!     image->filesize=filesize;
!     if (*crop_geometry != '\0')
!       if (Intensity(image->pixels[0]) == MaxRGB)
!         {
!           /*
!             Crop to bounding box.
!           */
!           TransformImage(&image,crop_geometry,(char *) NULL);
!           if (image->next != (Image *) NULL)
!             image->next->previous=image;
!         }
!     next_image=image->next;
!     if (next_image != (Image *) NULL)
!       image=next_image;
!   } while (next_image != (Image *) NULL);
!   while (image->previous != (Image *) NULL)
!     image=image->previous;
!   return(image);
! }
! 
! /*
! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
! %                                                                             %
! %                                                                             %
! %                                                                             %
! %  R e a d R A D I A N C E I m a g e                                          %
! %                                                                             %
! %                                                                             %
! %                                                                             %
! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
! %
! %  Function ReadRADIANCEImage reads a RADIANCE image file and returns it.
! %  It allocates the memory necessary for the new Image structure and returns
! %  a pointer to the new image.
! %
! %  The format of the ReadRADIANCEImage routine is:
! %
! %      image=ReadRADIANCEImage(image_info)
! %
! %  A description of each parameter follows:
! %
! %    o image:  Function ReadRADIANCEImage returns a pointer to the image after
! %      reading.  A null image is returned if there is a a memory shortage or
! %      if the image cannot be read.
! %
! %    o image_info: Specifies a pointer to an ImageInfo structure.
! %
! %
! */
! static Image *ReadRADIANCEImage(image_info)
! ImageInfo
!   *image_info;
! {
!   char
!     filename[MaxTextLength];
! 
!   Image
!     *image,
!     *next_image;
! 
!   /*
!     Allocate image structure.
!   */
!   image=AllocateImage(image_info);
!   if (image == (Image *) NULL)
!     return((Image *) NULL);
!   /*
!     Open image file.
!   */
!   OpenImage(image,"rb");
!   if (image->file == (FILE *) NULL)
!     {
!       Warning("Unable to open file",image->filename);
!       DestroyImage(image);
!       return((Image *) NULL);
!     }
!   CloseImage(image);
!   DestroyImage(image);
!   /*
!     Use ra_ppm to convert RADIANCE image.
!   */
!   (void) strcpy(filename,image_info->filename);
!   (void) sprintf(image_info->filename,"|ra_ppm %s",filename);
!   image=ReadPNMImage(image_info);
!   if (image == (Image *) NULL)
!     {
!       Warning("RADIANCE translation failed",image_info->filename);
!       return((Image *) NULL);
!     }
!   /*
!     Assign proper filename.
!   */
!   do
!   {
!     (void) strcpy(image->filename,filename);
      next_image=image->next;
      if (next_image != (Image *) NULL)
        image=next_image;
--- 4629,4643 ----
    do
    {
      (void) strcpy(image->filename,image_info->filename);
!     if (*clip_geometry != '\0')
!       {
!         /*
!           Clip to bounding box.
!         */
!         TransformImage(&image,clip_geometry,(char *) NULL);
!         if (image->next != (Image *) NULL)
!           image->next->previous=image;
!       }
      next_image=image->next;
      if (next_image != (Image *) NULL)
        image=next_image;
***************
*** 5852,6115 ****
    status=ReadData((char *) &targa_header.id_length,1,1,image->file);
    targa_header.colormap_type=fgetc(image->file);
    targa_header.image_type=fgetc(image->file);
!   do
!   {
!     if ((status == False) || (targa_header.image_type == 0) ||
!         (targa_header.image_type > 11))
!       {
!         Warning("Not a TARGA image file",(char *) NULL);
!         DestroyImages(image);
!         return((Image *) NULL);
!       }
!     targa_header.colormap_index=LSBFirstReadShort(image->file);
!     targa_header.colormap_length=LSBFirstReadShort(image->file);
!     targa_header.colormap_size=fgetc(image->file);
!     targa_header.x_origin=LSBFirstReadShort(image->file);
!     targa_header.y_origin=LSBFirstReadShort(image->file);
!     targa_header.width=LSBFirstReadShort(image->file);
!     targa_header.height=LSBFirstReadShort(image->file);
!     targa_header.pixel_size=fgetc(image->file);
!     targa_header.attributes=fgetc(image->file);
!     /*
!       Initialize image structure.
!     */
!     image->matte=targa_header.pixel_size == 32;
!     image->columns=targa_header.width;
!     image->rows=targa_header.height;
!     image->packets=image->columns*image->rows;
!     image->pixels=(RunlengthPacket *)
!       malloc(image->packets*sizeof(RunlengthPacket));
!     if (image->pixels == (RunlengthPacket *) NULL)
!       {
!         Warning("Memory allocation error",(char *) NULL);
!         DestroyImages(image);
!         return((Image *) NULL);
!       }
!     if (targa_header.id_length != 0)
        {
!         /*
!           TARGA image comment.
!         */
!         image->comments=(char *)
!           malloc((targa_header.id_length+1)*sizeof(char));
!         if (image->comments == (char *) NULL)
            {
!             Warning("Memory allocation error",(char *) NULL);
!             DestroyImages(image);
!             return((Image *) NULL);
            }
!         (void) ReadData(image->comments,1,(int) targa_header.id_length,
!           image->file);
!         image->comments[targa_header.id_length]='\0';
!       }
!     if (targa_header.colormap_type != 0)
!       {
!         /*
!           Read TARGA raster colormap.
!         */
!         if ((targa_header.image_type == TargaRLEColormap) ||
!             (targa_header.image_type == TargaRLERGB))
!           image->class=PseudoClass;
!         image->colors=targa_header.colormap_length;
!         image->colormap=(ColorPacket *)
!           malloc(image->colors*sizeof(ColorPacket));
!         if (image->colormap == (ColorPacket *) NULL)
            {
!             Warning("Memory allocation error",(char *) NULL);
!             DestroyImages(image);
!             return((Image *) NULL);
            }
!         for (i=0; i < image->colors; i++)
!         {
!           switch (targa_header.colormap_size)
            {
!             case 8:
!             default:
!             {
!               /*
!                 Gray scale.
!               */
!               red=fgetc(image->file);
!               green=red;
!               blue=red;
!               break;
!             }
!             case 15:
!             case 16:
!             {
!               /*
!                 5 bits each of red green and blue.
!               */
!               j=fgetc(image->file);
!               k=fgetc(image->file);
!               red=(unsigned char) ((MaxRGB*((int) (k & 0x7c) >> 2))/31);
!               green=(unsigned char)
!                 ((MaxRGB*(((int) (k & 0x03) << 3)+((int) (j & 0xe0) >> 5)))/31);
!               blue=(unsigned char) ((MaxRGB*((int) (j & 0x1f)))/31);
!               break;
!             }
!             case 32:
!             case 24:
!             {
!               /*
!                 8 bits each of blue green and red.
!               */
!               blue=fgetc(image->file);
!               green=fgetc(image->file);
!               red=fgetc(image->file);
!               break;
!             }
            }
-           image->colormap[i].red=red;
-           image->colormap[i].green=green;
-           image->colormap[i].blue=blue;
          }
        }
!     /*
!       Convert TARGA pixels to runlength-encoded packets.
!     */
!     base=0;
!     flag=0;
!     index=0;
!     skip=False;
!     real=0;
!     runlength=0;
!     true=0;
!     for (y=0; y < image->rows; y++)
!     {
!       real=true;
!       if (((unsigned char) (targa_header.attributes & 0x20) >> 5) == 0)
!         real=image->rows-real-1;
!       q=image->pixels+(real*image->columns);
!       for (x=0; x < image->columns; x++)
!       {
!         if ((targa_header.image_type == TargaRLEColormap) ||
!             (targa_header.image_type == TargaRLERGB) ||
!             (targa_header.image_type == TargaRLEMonochrome))
!           if (runlength != 0)
!             {
!               runlength--;
!               skip=flag != 0;
!             }
!           else
!             {
!               status=ReadData((char *) &runlength,1,1,image->file);
!               if (status == False)
!                 {
!                   Warning("Unable to read image data",image_info->filename);
!                   DestroyImages(image);
!                   return((Image *) NULL);
!                 }
!               flag=runlength & 0x80;
!               if (flag != 0)
!                 runlength-=128;
!               skip=False;
!             }
!         if (!skip)
!           switch (targa_header.pixel_size)
            {
!             case 8:
!             default:
!             {
!               /*
!                 Gray scale.
!               */
!               index=fgetc(image->file);
!               if (targa_header.colormap_type == 0)
!                 {
!                   red=(unsigned char) index;
!                   green=(unsigned char) index;
!                   blue=(unsigned char) index;
!                 }
!               else
!                 {
!                   red=image->colormap[index].red;
!                   green=image->colormap[index].green;
!                   blue=image->colormap[index].blue;
!                 }
!               break;
!             }
!             case 15:
!             case 16:
!             {
!               /*
!                 5 bits each of red green and blue.
!               */
!               j=fgetc(image->file);
!               k=fgetc(image->file);
!               red=(unsigned char) ((MaxRGB*((int) (k & 0x7c) >> 2))/31);
!               green=(unsigned char)
!                 ((MaxRGB*(((int) (k & 0x03) << 3)+((int) (j & 0xe0) >> 5)))/31);
!               blue=(unsigned char) ((MaxRGB*((int) (j & 0x1f)))/31);
!               index=((unsigned int) k << 8)+j;
!               break;
!             }
!             case 24:
!             case 32:
!             {
!               /*
!                 8 bits each of blue green and red.
!               */
!               blue=fgetc(image->file);
!               green=fgetc(image->file);
!               red=fgetc(image->file);
!               if (targa_header.pixel_size == 32)
!                 index=fgetc(image->file);
!               break;
!             }
            }
!         if (status == False)
            {
!             Warning("Unable to read image data",image_info->filename);
!             DestroyImages(image);
!             return((Image *) NULL);
            }
!         q->red=red;
!         q->green=green;
!         q->blue=blue;
!         q->index=index;
!         q->length=0;
!         q++;
!       }
!       if (((unsigned char) (targa_header.attributes & 0xc0) >> 6) == 4)
!         true+=4;
!       else
!         if (((unsigned char) (targa_header.attributes & 0xc0) >> 6) == 2)
!           true+=2;
!         else
!           true++;
!       if (true >= image->rows)
          {
!           base++;
!           true=base;
          }
      }
!     if (image->class == PseudoClass)
!       SyncImage(image);
!     status=ReadData((char *) &targa_header.id_length,1,1,image->file);
!     targa_header.colormap_type=fgetc(image->file);
!     targa_header.image_type=fgetc(image->file);
!     status&=((targa_header.image_type != 0) && (targa_header.image_type <= 11));
!     if (status == True)
        {
!         /*
!           Allocate image structure.
!         */
!         image->next=AllocateImage(image_info);
!         if (image->next == (Image *) NULL)
!           {
!             DestroyImages(image);
!             return((Image *) NULL);
!           }
!         (void) strcpy(image->next->filename,image_info->filename);
!         image->next->file=image->file;
!         image->next->scene=image->scene+1;
!         image->next->previous=image;
!         image=image->next;
        }
!   } while (status == True);
!   while (image->previous != (Image *) NULL)
!     image=image->previous;
    CloseImage(image);
    return(image);
  }
--- 5752,5989 ----
    status=ReadData((char *) &targa_header.id_length,1,1,image->file);
    targa_header.colormap_type=fgetc(image->file);
    targa_header.image_type=fgetc(image->file);
!   if ((status == False) || (targa_header.image_type == 0) ||
!       (targa_header.image_type > 11))
!     {
!       Warning("Not a TARGA image file",(char *) NULL);
!       DestroyImage(image);
!       return((Image *) NULL);
!     }
!   targa_header.colormap_index=LSBFirstReadShort(image->file);
!   targa_header.colormap_length=LSBFirstReadShort(image->file);
!   targa_header.colormap_size=fgetc(image->file);
!   targa_header.x_origin=LSBFirstReadShort(image->file);
!   targa_header.y_origin=LSBFirstReadShort(image->file);
!   targa_header.width=LSBFirstReadShort(image->file);
!   targa_header.height=LSBFirstReadShort(image->file);
!   targa_header.pixel_size=fgetc(image->file);
!   targa_header.attributes=fgetc(image->file);
!   /*
!     Initialize image structure.
!   */
!   image->matte=targa_header.pixel_size == 32;
!   image->columns=targa_header.width;
!   image->rows=targa_header.height;
!   image->packets=image->columns*image->rows;
!   image->pixels=(RunlengthPacket *)
!     malloc(image->packets*sizeof(RunlengthPacket));
!   if (image->pixels == (RunlengthPacket *) NULL)
!     {
!       Warning("Memory allocation error",(char *) NULL);
!       DestroyImage(image);
!       return((Image *) NULL);
!     }
!   if (targa_header.id_length != 0)
!     {
!       /*
!         TARGA image comment.
!       */
!       image->comments=(char *)
!         malloc((targa_header.id_length+1)*sizeof(char));
!       if (image->comments == (char *) NULL)
!         {
!           Warning("Memory allocation error",(char *) NULL);
!           DestroyImage(image);
!           return((Image *) NULL);
!         }
!       (void) ReadData(image->comments,1,(int) targa_header.id_length,
!         image->file);
!       image->comments[targa_header.id_length]='\0';
!     }
!   if (targa_header.colormap_type != 0)
!     {
!       /*
!         Read TARGA raster colormap.
!       */
!       if ((targa_header.image_type == TargaRLEColormap) ||
!           (targa_header.image_type == TargaRLERGB))
!         image->class=PseudoClass;
!       image->colors=targa_header.colormap_length;
!       image->colormap=(ColorPacket *)
!         malloc(image->colors*sizeof(ColorPacket));
!       if (image->colormap == (ColorPacket *) NULL)
!         {
!           Warning("Memory allocation error",(char *) NULL);
!           DestroyImage(image);
!           return((Image *) NULL);
!         }
!       for (i=0; i < image->colors; i++)
        {
!         switch (targa_header.colormap_size)
!         {
!           case 8:
!           default:
            {
!             /*
!               Gray scale.
!             */
!             red=fgetc(image->file);
!             green=red;
!             blue=red;
!             break;
            }
!           case 15:
!           case 16:
            {
!             /*
!               5 bits each of red green and blue.
!             */
!             j=fgetc(image->file);
!             k=fgetc(image->file);
!             red=(unsigned char) ((MaxRGB*((int) (k & 0x7c) >> 2))/31);
!             green=(unsigned char)
!               ((MaxRGB*(((int) (k & 0x03) << 3)+((int) (j & 0xe0) >> 5)))/31);
!             blue=(unsigned char) ((MaxRGB*((int) (j & 0x1f)))/31);
!             break;
            }
!           case 32:
!           case 24:
            {
!             /*
!               8 bits each of blue green and red.
!             */
!             blue=fgetc(image->file);
!             green=fgetc(image->file);
!             red=fgetc(image->file);
!             break;
            }
          }
+         image->colormap[i].red=red;
+         image->colormap[i].green=green;
+         image->colormap[i].blue=blue;
        }
!     }
!   /*
!     Convert TARGA pixels to runlength-encoded packets.
!   */
!   base=0;
!   flag=0;
!   index=0;
!   skip=False;
!   real=0;
!   runlength=0;
!   true=0;
!   for (y=0; y < image->rows; y++)
!   {
!     real=true;
!     if (((unsigned char) (targa_header.attributes & 0x20) >> 5) == 0)
!       real=image->rows-real-1;
!     q=image->pixels+(real*image->columns);
!     for (x=0; x < image->columns; x++)
!     {
!       if ((targa_header.image_type == TargaRLEColormap) ||
!           (targa_header.image_type == TargaRLERGB) ||
!           (targa_header.image_type == TargaRLEMonochrome))
!         if (runlength != 0)
            {
!             runlength--;
!             skip=flag != 0;
            }
!         else
            {
!             status=ReadData((char *) &runlength,1,1,image->file);
!             if (status == False)
!               {
!                 Warning("Unable to read image data",image_info->filename);
!                 DestroyImage(image);
!                 return((Image *) NULL);
!               }
!             flag=runlength & 0x80;
!             if (flag != 0)
!               runlength-=128;
!             skip=False;
            }
!       if (!skip)
!         switch (targa_header.pixel_size)
!         {
!           case 8:
!           default:
!           {
!             /*
!               Gray scale.
!             */
!             index=fgetc(image->file);
!             if (targa_header.colormap_type == 0)
!               {
!                 red=(unsigned char) index;
!                 green=(unsigned char) index;
!                 blue=(unsigned char) index;
!               }
!             else
!               {
!                 red=image->colormap[index].red;
!                 green=image->colormap[index].green;
!                 blue=image->colormap[index].blue;
!               }
!             break;
!           }
!           case 15:
!           case 16:
!           {
!             /*
!               5 bits each of red green and blue.
!             */
!             j=fgetc(image->file);
!             k=fgetc(image->file);
!             red=(unsigned char) ((MaxRGB*((int) (k & 0x7c) >> 2))/31);
!             green=(unsigned char)
!               ((MaxRGB*(((int) (k & 0x03) << 3)+((int) (j & 0xe0) >> 5)))/31);
!             blue=(unsigned char) ((MaxRGB*((int) (j & 0x1f)))/31);
!             index=((unsigned int) k << 8)+j;
!             break;
!           }
!           case 24:
!           case 32:
!           {
!             /*
!               8 bits each of blue green and red.
!             */
!             blue=fgetc(image->file);
!             green=fgetc(image->file);
!             red=fgetc(image->file);
!             if (targa_header.pixel_size == 32)
!               index=fgetc(image->file);
!             break;
!           }
!         }
!       if (status == False)
          {
!           Warning("Unable to read image data",image_info->filename);
!           DestroyImage(image);
!           return((Image *) NULL);
          }
+       q->red=red;
+       q->green=green;
+       q->blue=blue;
+       q->index=index;
+       q->length=0;
+       q++;
      }
!     if (((unsigned char) (targa_header.attributes & 0xc0) >> 6) == 4)
!       true+=4;
!     else
!       if (((unsigned char) (targa_header.attributes & 0xc0) >> 6) == 2)
!         true+=2;
!       else
!         true++;
!     if (true >= image->rows)
        {
!         base++;
!         true=base;
        }
!   }
!   if (image->class == PseudoClass)
!     SyncImage(image);
    CloseImage(image);
    return(image);
  }
***************
*** 6448,6460 ****
  }
  
  #ifdef HasTIFF
! #ifndef va_start
! #if defined(__STDC__) && !defined(NOSTDHDRS)
! #include <stdarg.h>
! #else
! #include <varargs.h>
! #endif
! #endif
  #include "tiffio.h"
  
  /*
--- 6322,6328 ----
  }
  
  #ifdef HasTIFF
! #include "tiff.h"
  #include "tiffio.h"
  
  /*
***************
*** 6486,6517 ****
  %
  %
  */
- 
- static void TIFFWarningMessage(module,format,warning)
- const char
-   *module,
-   *format;
- 
- va_list
-   warning;
- {
-   char
-     message[MaxTextLength];
- 
-   register char
-     *p;
- 
-   p=message;
-   if (module != (char *) NULL)
-     {
-       sprintf(p,"%s: ",module);
-       p+=strlen(message);
-     }
-   vsprintf(p,format,warning);
-   strcat(p,".");
-   Warning(message,(char *) NULL);
- }
- 
  static Image *ReadTIFFImage(image_info)
  ImageInfo
    *image_info;
--- 6354,6359 ----
***************
*** 6558,6603 ****
    if (image == (Image *) NULL)
      return((Image *) NULL);
    /*
!     Open image.
    */
!   OpenImage(image,"rb");
!   if (image->file != (FILE *) NULL)
!     if ((image->file == stdin) || image->pipe)
!       {
!         FILE
!           *file;
! 
!         int
!           c;
! 
!         /*
!           Copy standard input or pipe to temporary file.
!         */
!         TemporaryFilename(image_info->filename);
!         file=fopen(image_info->filename,"wb");
!         if (file == (FILE *) NULL)
!           {
!             Warning("Unable to write file",image->filename);
!             return((Image *) NULL);
!           }
!         c=fgetc(image->file);
!         while (c != EOF)
!         {
!           (void) putc(c,file);
!           c=fgetc(image->file);
!         }
!         (void) fclose(file);
!         CloseImage(image);
!         (void) strcpy(image->filename,image_info->filename);
!         OpenImage(image,"rb");
!         image->temporary=True;
!       }
!   TIFFSetErrorHandler(TIFFWarningMessage);
!   TIFFSetWarningHandler(TIFFWarningMessage);
!   tiff=TIFFFdOpen(fileno(image->file),image->filename,"rb");
    if (tiff == (TIFF *) NULL)
      {
!       Warning("Unable to open file",image->filename);
        DestroyImage(image);
        return((Image *) NULL);
      }
--- 6400,6411 ----
    if (image == (Image *) NULL)
      return((Image *) NULL);
    /*
!     Open TIFF image tiff.
    */
!   tiff=TIFFOpen(image->filename,"rb");
    if (tiff == (TIFF *) NULL)
      {
!       Warning("Unable to open tiff image",image->filename);
        DestroyImage(image);
        return((Image *) NULL);
      }
***************
*** 6911,6918 ****
        }
    } while (status == True);
    TIFFClose(tiff);
-   if (image->temporary)
-     (void) unlink(image_info->filename);
    while (image->previous != (Image *) NULL)
      image=image->previous;
    return(image);
--- 6719,6724 ----
***************
*** 7874,7880 ****
      x;
  
    RectangleInfo
!     crop_info;
  
    Window
      client_window,
--- 7680,7686 ----
      x;
  
    RectangleInfo
!     clip_info;
  
    Window
      client_window,
***************
*** 7902,7911 ****
    /*
      Select target window.
    */
!   crop_info.x=0;
!   crop_info.y=0;
!   crop_info.width=0;
!   crop_info.height=0;
    root_window=XRootWindow(display,XDefaultScreen(display));
    target_window=(Window) NULL;
    if ((image_info->filename != (char *) NULL) &&
--- 7708,7717 ----
    /*
      Select target window.
    */
!   clip_info.x=0;
!   clip_info.y=0;
!   clip_info.width=0;
!   clip_info.height=0;
    root_window=XRootWindow(display,XDefaultScreen(display));
    target_window=(Window) NULL;
    if ((image_info->filename != (char *) NULL) &&
***************
*** 7929,7935 ****
      If target window is not defined, interactively select one.
    */
    if (target_window == (Window) NULL)
!     target_window=XSelectWindow(display,&crop_info);
    client_window=target_window;
    if (target_window != root_window)
      {
--- 7735,7741 ----
      If target window is not defined, interactively select one.
    */
    if (target_window == (Window) NULL)
!     target_window=XSelectWindow(display,&clip_info);
    client_window=target_window;
    if (target_window != root_window)
      {
***************
*** 7969,7987 ****
            return((Image *) NULL);
          }
        XTranslateCoordinates(display,target_window,root_window,0,0,&x,&y,&child);
!       crop_info.x=x;
!       crop_info.y=y;
!       crop_info.width=window_attributes.width;
!       crop_info.height=window_attributes.height;
        if (borders)
          {
            /*
              Include border in image.
            */
!           crop_info.x-=window_attributes.border_width;
!           crop_info.y-=window_attributes.border_width;
!           crop_info.width+=window_attributes.border_width << 1;
!           crop_info.height+=window_attributes.border_width << 1;
          }
        target_window=root_window;
      }
--- 7775,7793 ----
            return((Image *) NULL);
          }
        XTranslateCoordinates(display,target_window,root_window,0,0,&x,&y,&child);
!       clip_info.x=x;
!       clip_info.y=y;
!       clip_info.width=window_attributes.width;
!       clip_info.height=window_attributes.height;
        if (borders)
          {
            /*
              Include border in image.
            */
!           clip_info.x-=window_attributes.border_width;
!           clip_info.y-=window_attributes.border_width;
!           clip_info.width+=window_attributes.border_width << 1;
!           clip_info.height+=window_attributes.border_width << 1;
          }
        target_window=root_window;
      }
***************
*** 8018,8036 ****
      Warning("Unable to read X window image",image_info->filename);
    else
      {
!       if ((crop_info.width != 0) && (crop_info.height != 0))
          {
            Image
!             *cropped_image;
  
            /*
!             Crop image as defined by the cropping rectangle.
            */
!           cropped_image=CropImage(image,&crop_info);
!           if (cropped_image != (Image *) NULL)
              {
                DestroyImage(image);
!               image=cropped_image;
              }
          }
        status=XGetWMName(display,target_window,&window_name);
--- 7824,7842 ----
      Warning("Unable to read X window image",image_info->filename);
    else
      {
!       if ((clip_info.width != 0) && (clip_info.height != 0))
          {
            Image
!             *clipped_image;
  
            /*
!             Clip image as defined by the clipping rectangle.
            */
!           clipped_image=ClipImage(image,&clip_info);
!           if (clipped_image != (Image *) NULL)
              {
                DestroyImage(image);
!               image=clipped_image;
              }
          }
        status=XGetWMName(display,target_window,&window_name);
***************
*** 8606,8611 ****
--- 8412,8425 ----
    xpm_attributes.colormap=map_info->colormap;
    xpm_attributes.depth=visual_info->depth;
    xpm_attributes.color_key=XPM_COLOR;
+   if (IsGrayImage(image))
+     if (image->colors > 16)
+       xpm_attributes.color_key=XPM_GRAY;
+     else
+       if (image->colors == 2)
+         xpm_attributes.color_key=XPM_MONO;
+       else
+         xpm_attributes.color_key=XPM_GRAY4;
    /*
      Read in a file in the XPM format into a X image structure.
    */
***************
*** 8803,8809 ****
        for (y=0; y < image->rows; y++)
          for (x=0; x < image->columns; x++)
          {
!           p->index=(unsigned short) XGetPixel(ximage,x,y);
            p->length=0;
            p++;
          }
--- 8617,8624 ----
        for (y=0; y < image->rows; y++)
          for (x=0; x < image->columns; x++)
          {
!           pixel=XGetPixel(ximage,x,y);
!           p->index=(unsigned short) pixel;
            p->length=0;
            p++;
          }
***************
*** 8822,8829 ****
        for (y=0; y < image->rows; y++)
          for (x=0; x < image->columns; x++)
          {
!           if (!XGetPixel(matte_image,x,y))
!             p->index=(unsigned short) TransparentIndex;
            p++;
          }
        XDestroyImage(matte_image);
--- 8637,8644 ----
        for (y=0; y < image->rows; y++)
          for (x=0; x < image->columns; x++)
          {
!           pixel=XGetPixel(matte_image,x,y);
!           p->index=(unsigned short) !pixel;
            p++;
          }
        XDestroyImage(matte_image);
***************
*** 9638,9650 ****
      magic_number[12];
  
    Image
-     decode_image,
      *image;
  
    SetImageMagick(image_info);
-   decode_image.temporary=False;
    if (!image_info->assert)
      {
        /*
          Determine type from image magic number.
        */
--- 9453,9470 ----
      magic_number[12];
  
    Image
      *image;
  
+   unsigned int
+     temporary_file;
+ 
+   temporary_file=False;
    SetImageMagick(image_info);
    if (!image_info->assert)
      {
+       Image
+         decode_image;
+ 
        /*
          Determine type from image magic number.
        */
***************
*** 9654,9659 ****
--- 9474,9482 ----
        if (decode_image.file != (FILE *) NULL)
          if ((decode_image.file == stdin) || decode_image.pipe)
            {
+             char
+               *directory;
+ 
              FILE
                *file;
  
***************
*** 9663,9670 ****
              /*
                Copy standard input or pipe to temporary file.
              */
!             decode_image.temporary=True;
!             TemporaryFilename(image_info->filename);
              file=fopen(image_info->filename,"wb");
              if (file == (FILE *) NULL)
                {
--- 9486,9497 ----
              /*
                Copy standard input or pipe to temporary file.
              */
!             temporary_file=True;
!             directory=(char *) getenv("TMPDIR");
!             if (directory == (char *) NULL)
!               directory="/tmp";
!             (void) sprintf(image_info->filename,"%s/magickXXXXXX",directory);
!             (void) mktemp(image_info->filename);
              file=fopen(image_info->filename,"wb");
              if (file == (FILE *) NULL)
                {
***************
*** 9712,9726 ****
          (void) strcpy(image_info->magick,"PNM");
        if (strncmp(magic_number,"%!",2) == 0)
          (void) strcpy(image_info->magick,"PS");
-       if (strncmp(magic_number,"#?RADIANCE",10) == 0)
-         (void) strcpy(image_info->magick,"RAD");
-       if (strncmp(magic_number,"\122\314",2) == 0)
-         (void) strcpy(image_info->magick,"RLE");
        if (strncmp(magic_number,"\131\246\152\225",4) == 0)
          (void) strcpy(image_info->magick,"SUN");
        if ((strncmp(magic_number,"\115\115",2) == 0) ||
            (strncmp(magic_number,"\111\111",2) == 0))
          (void) strcpy(image_info->magick,"TIFF");
        if ((strncmp(magic_number,"LBLSIZE",7) == 0) ||
           (strncmp(magic_number,"NJPL1I",6) == 0))
          (void) strcpy(image_info->magick,"VICAR");
--- 9539,9551 ----
          (void) strcpy(image_info->magick,"PNM");
        if (strncmp(magic_number,"%!",2) == 0)
          (void) strcpy(image_info->magick,"PS");
        if (strncmp(magic_number,"\131\246\152\225",4) == 0)
          (void) strcpy(image_info->magick,"SUN");
        if ((strncmp(magic_number,"\115\115",2) == 0) ||
            (strncmp(magic_number,"\111\111",2) == 0))
          (void) strcpy(image_info->magick,"TIFF");
+       if (strncmp(magic_number,"\122\314",2) == 0)
+         (void) strcpy(image_info->magick,"RLE");
        if ((strncmp(magic_number,"LBLSIZE",7) == 0) ||
           (strncmp(magic_number,"NJPL1I",6) == 0))
          (void) strcpy(image_info->magick,"VICAR");
***************
*** 9832,9847 ****
      }
      case 'R':
      {
!       if (strcmp(image_info->magick,"RAD") == 0)
!         image=ReadRADIANCEImage(image_info);
        else
!         if (strcmp(image_info->magick,"RAS") == 0)
!           image=ReadSUNImage(image_info);
          else
!           if (strcmp(image_info->magick,"RGB") == 0)
!             image=ReadRGBImage(image_info);
!           else
!             image=ReadRLEImage(image_info);
        break;
      }
      case 'S':
--- 9657,9669 ----
      }
      case 'R':
      {
!       if (strcmp(image_info->magick,"RAS") == 0)
!         image=ReadSUNImage(image_info);
        else
!         if (strcmp(image_info->magick,"RGB") == 0)
!           image=ReadRGBImage(image_info);
          else
!           image=ReadRLEImage(image_info);
        break;
      }
      case 'S':
***************
*** 9903,9914 ****
        image=ReadMIFFImage(image_info);
      }
    }
!   if (decode_image.temporary)
      (void) unlink(image_info->filename);
    if (image != (Image *) NULL)
      {
        if (image->status)
!         Warning("An error has occurred reading from file",image->filename);
        if (image->comments == (char *) NULL)
          CommentImage(image,"  Imported from %m image: %f");
      }
--- 9725,9740 ----
        image=ReadMIFFImage(image_info);
      }
    }
!   if (temporary_file)
      (void) unlink(image_info->filename);
    if (image != (Image *) NULL)
      {
        if (image->status)
!         {
!           Warning("An error has occurred reading from file",image->filename);
!           DestroyImages(image);
!           return((Image *) NULL);
!         }
        if (image->comments == (char *) NULL)
          CommentImage(image,"  Imported from %m image: %f");
      }
diff -c -r ImageMagick-3.1/magick/encode.c ImageMagick/magick/encode.c
*** ImageMagick-3.1/magick/encode.c	Wed Jul 13 10:52:13 1994
--- ImageMagick/magick/encode.c	Thu Jun  2 16:39:23 1994
***************
*** 61,67 ****
    Forward declarations.
  */
  static unsigned int
!   WriteMIFFImage _Declare((ImageInfo *,Image *));
  
  /*
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--- 61,67 ----
    Forward declarations.
  */
  static unsigned int
!   WriteMIFFImage _Declare((Image *));
  
  /*
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
***************
*** 78,84 ****
  %
  %  The format of the WriteAVSImage routine is:
  %
! %      status=WriteAVSImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 78,84 ----
  %
  %  The format of the WriteAVSImage routine is:
  %
! %      status=WriteAVSImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 86,101 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteAVSImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 86,96 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteAVSImage(image)
  Image
    *image;
  {
***************
*** 179,185 ****
  %
  %  The format of the WriteBMPImage routine is:
  %
! %      status=WriteBMPImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 174,180 ----
  %
  %  The format of the WriteBMPImage routine is:
  %
! %      status=WriteBMPImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 187,202 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteBMPImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 182,192 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteBMPImage(image)
  Image
    *image;
  {
***************
*** 258,269 ****
        Warning("Unable to open file",image->filename);
        return(False);
      }
    /*
      Initialize BMP raster file header.
    */
    bmp_header.file_size=14+40;
    bmp_header.offset_bits=14+40;
!   if (!IsPseudoClass(image))
      {
        /*
          Full color BMP raster.
--- 248,268 ----
        Warning("Unable to open file",image->filename);
        return(False);
      }
+   if (image->class == DirectClass)
+     if (NumberColors(image,(FILE *) NULL) <= 256)
+       {
+         /*
+           Demote DirectClass to PseudoClass.
+         */
+         QuantizeImage(image,256,8,False,RGBColorspace,True);
+         SyncImage(image);
+       }
    /*
      Initialize BMP raster file header.
    */
    bmp_header.file_size=14+40;
    bmp_header.offset_bits=14+40;
!   if ((image->class == DirectClass) || (image->colors > 256))
      {
        /*
          Full color BMP raster.
***************
*** 504,510 ****
  %
  %  The format of the WriteCMYKImage routine is:
  %
! %      status=WriteCMYKImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 503,509 ----
  %
  %  The format of the WriteCMYKImage routine is:
  %
! %      status=WriteCMYKImage(image,interlace,undercolor_geometry)
  %
  %  A description of each parameter follows.
  %
***************
*** 512,529 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteCMYKImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
    float
      black_generation,
--- 511,536 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
+ %    o interlace:  An unsigned integer that specifies the interlacing
+ %      scheme.
+ %
+ %    o undercolor_geometry: Specifies a pointer to a undercolor geometry
+ %      string.  The specified undercolor removal and black generation of this
+ %      geometry string are relative.
  %
+ %
  */
! static unsigned int WriteCMYKImage(image,interlace,undercolor_geometry)
  Image
    *image;
+ 
+ unsigned int
+   interlace;
+ 
+ char
+   *undercolor_geometry;
  {
    float
      black_generation,
***************
*** 567,581 ****
      }
    undercolor=1.0;
    black_generation=1.0;
!   if (image_info->undercolor != (char *) NULL)
      {
!       (void) sscanf(image_info->undercolor,"%fx%f",&undercolor,
!         &black_generation);
        if (black_generation == 1.0)
          black_generation=undercolor;
      }
    q=cmyk_pixels;
!   switch (image_info->interlace)
    {
      case NoneInterlace:
      default:
--- 574,587 ----
      }
    undercolor=1.0;
    black_generation=1.0;
!   if (undercolor_geometry != (char *) NULL)
      {
!       (void) sscanf(undercolor_geometry,"%fx%f",&undercolor,&black_generation);
        if (black_generation == 1.0)
          black_generation=undercolor;
      }
    q=cmyk_pixels;
!   switch (interlace)
    {
      case NoneInterlace:
      default:
***************
*** 776,782 ****
  %
  %  The format of the WriteFAXImage routine is:
  %
! %      status=WriteFAXImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 782,788 ----
  %
  %  The format of the WriteFAXImage routine is:
  %
! %      status=WriteFAXImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 784,799 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteFAXImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 790,800 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteFAXImage(image)
  Image
    *image;
  {
***************
*** 812,818 ****
    /*
      Convert MIFF to monochrome.
    */
!   QuantizeImage(image,2,8,image_info->dither,GRAYColorspace,True);
    SyncImage(image);
    status=HuffmanEncodeImage(image);
    CloseImage(image);
--- 813,819 ----
    /*
      Convert MIFF to monochrome.
    */
!   QuantizeImage(image,2,8,False,GRAYColorspace,True);
    SyncImage(image);
    status=HuffmanEncodeImage(image);
    CloseImage(image);
***************
*** 835,841 ****
  %
  %  The format of the WriteFITSImage routine is:
  %
! %      status=WriteFITSImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 836,842 ----
  %
  %  The format of the WriteFITSImage routine is:
  %
! %      status=WriteFITSImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 843,858 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteFITSImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 844,854 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteFITSImage(image)
  Image
    *image;
  {
***************
*** 900,906 ****
    (void) strncpy(fits_header+0,buffer,strlen(buffer));
    (void) strcpy(buffer,"BITPIX  =                    8");
    (void) strncpy(fits_header+80,buffer,strlen(buffer));
!   (void) strcpy(buffer,"NAXIS   =                    2");
    (void) strncpy(fits_header+160,buffer,strlen(buffer));
    (void) sprintf(buffer,"NAXIS1  =           %10u",image->columns);
    (void) strncpy(fits_header+240,buffer,strlen(buffer));
--- 896,902 ----
    (void) strncpy(fits_header+0,buffer,strlen(buffer));
    (void) strcpy(buffer,"BITPIX  =                    8");
    (void) strncpy(fits_header+80,buffer,strlen(buffer));
!   (void) strcpy(buffer,"NAXIS  =                     2");
    (void) strncpy(fits_header+160,buffer,strlen(buffer));
    (void) sprintf(buffer,"NAXIS1  =           %10u",image->columns);
    (void) strncpy(fits_header+240,buffer,strlen(buffer));
***************
*** 953,959 ****
  %
  %  The format of the WriteGIFImage routine is:
  %
! %      status=WriteGIFImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 949,955 ----
  %
  %  The format of the WriteGIFImage routine is:
  %
! %      status=WriteGIFImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 961,982 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteGIFImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
    register int
!     i,
!     x;
  
    register RunlengthPacket
      *p;
--- 957,975 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteGIFImage(image)
  Image
    *image;
  {
+   int
+     transparency_index;
+ 
    register int
!     i;
  
    register RunlengthPacket
      *p;
***************
*** 983,993 ****
  
    unsigned char
      bits_per_pixel,
!     c,
!     *matte_image;
  
    unsigned int
-     colors,
      status;
  
    /*
--- 976,984 ----
  
    unsigned char
      bits_per_pixel,
!     c;
  
    unsigned int
      status;
  
    /*
***************
*** 999,1041 ****
        Warning("Unable to open file",image->filename);
        return(False);
      }
!   colors=256;
!   matte_image=(unsigned char *) NULL;
    if (image->matte)
      {
        /*
!         Allocate and initialize matte image.
        */
!       if (!UncompressImage(image))
!         return(False);
        p=image->pixels;
!       x=0;
!       matte_image=(unsigned char *)
!         malloc(image->columns*image->rows*sizeof(unsigned char));
!       if (matte_image == (unsigned char *) NULL)
!         Warning("Unable to set transparent pixel","Memory allocation failed");
!       else
!         for (i=0; i < (image->columns*image->rows); i++)
!         {
!           matte_image[x]=(unsigned char) (p->index & 0xff);
!           x++;
!           p++;
!         }
!       colors--;
      }
!   if ((image->class == DirectClass) || (image->colors > colors))
      {
        /*
          Demote DirectClass to PseudoClass.
        */
!       QuantizeImage(image,colors,8,image_info->dither,RGBColorspace,True);
        SyncImage(image);
      }
-   colors=image->colors;
-   if (matte_image != (unsigned char *) NULL)
-     colors++;
    for (bits_per_pixel=1; bits_per_pixel < 8; bits_per_pixel++)
!     if ((1 << bits_per_pixel) >= colors)
        break;
    /*
      Write GIF header.
--- 990,1030 ----
        Warning("Unable to open file",image->filename);
        return(False);
      }
!   transparency_index=(-1);
    if (image->matte)
      {
        /*
!         Determine transparency index.
        */
!       transparency_index=0;
        p=image->pixels;
!       image->runlength=p->length+1;
!       for (i=0; i < (image->columns*image->rows); i++)
!       {
!         if (image->runlength != 0)
!           image->runlength--;
!         else
!           {
!             p++;
!             image->runlength=p->length;
!           }
!         if (p->index == 255)
!           {
!             transparency_index=i;
!             break;
!           }
!       }
      }
!   if ((image->class == DirectClass) || (image->colors > 256))
      {
        /*
          Demote DirectClass to PseudoClass.
        */
!       QuantizeImage(image,256,8,True,RGBColorspace,True);
        SyncImage(image);
      }
    for (bits_per_pixel=1; bits_per_pixel < 8; bits_per_pixel++)
!     if ((1 << bits_per_pixel) >= image->colors)
        break;
    /*
      Write GIF header.
***************
*** 1069,1102 ****
    }
    if (strcmp(image->magick,"GIF87") != 0)
      {
!       if (matte_image != (unsigned char *) NULL)
!         if (UncompressImage(image))
!           {
!             /*
!               Write out extension for transparent color index.
!             */
!             (void) fputc(0x21,image->file);
!             (void) fputc(0xf9,image->file);
!             (void) fputc(0x4,image->file);
!             (void) fputc(0x1,image->file);
!             (void) fputc(0x0,image->file);
!             (void) fputc(0x0,image->file);
!             (void) fputc((char) image->colors,image->file);
!             (void) fputc(0x0,image->file);
!             /*
!               Set transparent pixels to the transparent color index.
!             */
!             x=0;
!             p=image->pixels;
!             for (i=0; i < (image->columns*image->rows); i++)
!             {
!               if (matte_image[x] == TransparentIndex)
!                 p->index=image->colors;
!               x++;
!               p++;
!             }
!             (void) free((char *) matte_image);
!           }
        if (image->comments != (char *) NULL)
          {
            register char
--- 1058,1087 ----
    }
    if (strcmp(image->magick,"GIF87") != 0)
      {
!       if (transparency_index >= 0)
!         {
!           /*
!             Write out extension for transparent color index.
!           */
!           p=image->pixels;
!           image->runlength=p->length+1;
!           for (i=0; i < transparency_index; i++)
!             if (image->runlength != 0)
!               image->runlength--;
!             else
!               {
!                 p++;
!                 image->runlength=p->length;
!               }
!           (void) fputc(0x21,image->file);
!           (void) fputc(0xf9,image->file);
!           (void) fputc(0x4,image->file);
!           (void) fputc(0x1,image->file);
!           (void) fputc(0x0,image->file);
!           (void) fputc(0x0,image->file);
!           (void) fputc((char) p->index,image->file);
!           (void) fputc(0x0,image->file);
!         }
        if (image->comments != (char *) NULL)
          {
            register char
***************
*** 1160,1166 ****
  %
  %  The format of the WriteGRAYImage routine is:
  %
! %      status=WriteGRAYImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 1145,1151 ----
  %
  %  The format of the WriteGRAYImage routine is:
  %
! %      status=WriteGRAYImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 1168,1183 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteGRAYImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 1153,1163 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteGRAYImage(image)
  Image
    *image;
  {
***************
*** 1245,1251 ****
  %
  %  The format of the WriteHISTOGRAMImage routine is:
  %
! %      status=WriteHISTOGRAMImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 1225,1231 ----
  %
  %  The format of the WriteHISTOGRAMImage routine is:
  %
! %      status=WriteHISTOGRAMImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 1253,1268 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteHISTOGRAMImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 1233,1243 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteHISTOGRAMImage(image)
  Image
    *image;
  {
***************
*** 1295,1301 ****
  %
  %  The format of the WriteIRISImage routine is:
  %
! %      status=WriteIRISImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 1270,1276 ----
  %
  %  The format of the WriteIRISImage routine is:
  %
! %      status=WriteIRISImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 1303,1310 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
--- 1278,1283 ----
***************
*** 1368,1377 ****
    return(q-packets);
  }
  
! static unsigned int WriteIRISImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 1341,1347 ----
    return(q-packets);
  }
  
! static unsigned int WriteIRISImage(image)
  Image
    *image;
  {
***************
*** 1432,1438 ****
    */
    iris_header.magic=0x01DA;
    if (image->compression == NoCompression)
!     iris_header.storage=0x00;
    else
      iris_header.storage=0x01;
    iris_header.bytes_per_pixel=1;  /* one byte per pixel */
--- 1402,1408 ----
    */
    iris_header.magic=0x01DA;
    if (image->compression == NoCompression)
!     iris_header.storage=0x01;
    else
      iris_header.storage=0x01;
    iris_header.bytes_per_pixel=1;  /* one byte per pixel */
***************
*** 1590,1600 ****
  }
  
  #ifdef HasJPEG
! #include "jpeglib.h"
! #include "jerror.h"
! 
  static Image
!   *image;
  /*
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %                                                                             %
--- 1560,1571 ----
  }
  
  #ifdef HasJPEG
! #undef FREAD
! #undef FWRITE
! #undef const
! #include "jinclude.h"
  static Image
!   *jpeg_image;
  /*
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %                                                                             %
***************
*** 1612,1618 ****
  %
  %  The format of the WriteJPEGImage routine is:
  %
! %      status=WriteJPEGImage(image_info,image)
  %
  %  A description of each parameter follows:
  %
--- 1583,1589 ----
  %
  %  The format of the WriteJPEGImage routine is:
  %
! %      status=WriteJPEGImage(image,quality)
  %
  %  A description of each parameter follows:
  %
***************
*** 1620,1688 ****
  %      False is returned is there is of a memory shortage or if the image
  %      file cannot be opened for writing.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o jpeg_image:  A pointer to a Image structure.
  %
  %
  */
  
! static void EmitMessage(jpeg_info,level)
! j_common_ptr
    jpeg_info;
  
! int
!   level;
  {
!   char
!     message[JMSG_LENGTH_MAX];
  
!   struct jpeg_error_mgr
!     *jpeg_error;
  
!   jpeg_error=jpeg_info->err;
!   (jpeg_error->format_message) (jpeg_info,message);
!   if (level < 0)
!     {
!       if (jpeg_error->num_warnings == 0 || jpeg_error->trace_level >= 3)
!         Warning((char *) message,image->filename);
!       jpeg_error->num_warnings++;
!     }
!   else
!     if (jpeg_error->trace_level >= level)
!       Warning((char *) message,image->filename);
  }
  
! static unsigned int WriteJPEGImage(image_info,image)
! ImageInfo
!   *image_info;
  
! Image
!   *image;
  {
-   JSAMPLE
-     *jpeg_pixels,
-     **scanlines;
- 
    register int
!     i,
!     j;
  
!   register JSAMPLE
!     *q;
  
    register RunlengthPacket
      *p;
  
!   struct jpeg_compress_struct
      jpeg_info;
  
!   struct jpeg_error_mgr
!     jpeg_error;
  
!   unsigned int
!     count,
!     packets;
  
    /*
      Open image file.
--- 1591,1733 ----
  %      False is returned is there is of a memory shortage or if the image
  %      file cannot be opened for writing.
  %
  %    o jpeg_image:  A pointer to a Image structure.
  %
+ %    o quality:  Specifies quality setting.  Quality is 0 (worst) to 100 (best).
+ %
  %
  */
  
! METHODDEF void JPEGInitializeImage(jpeg_info)
! compress_info_ptr
!   jpeg_info;
! {
!   /*
!     Initialize JPEG image.
!   */
!   jpeg_info->image_width=jpeg_image->columns;
!   jpeg_info->image_height=jpeg_image->rows;
!   jpeg_info->data_precision=8;
!   jpeg_info->input_components=3;
!   jpeg_info->in_color_space=CS_RGB;
!   if (IsGrayImage(jpeg_image))
!     {
!       jpeg_info->input_components=1;
!       jpeg_info->in_color_space=CS_GRAYSCALE;
!     }
!   jpeg_image->packet=jpeg_image->pixels;
!   jpeg_image->runlength=jpeg_image->packet->length+1;
! }
! 
! static void JPEGInputTermMethod(jpeg_info)
! compress_info_ptr
!   jpeg_info;
! {
! }
! 
! static void JPEGWriteGRAY(jpeg_info,pixel_data)
! compress_info_ptr
    jpeg_info;
  
! JSAMPARRAY
!   pixel_data;
  {
!   register int
!     column;
  
!   register JSAMPROW
!     gray;
  
!   register RunlengthPacket
!     *p;
! 
!   /*
!     Convert run-length encoded grayscale MIFF packets to JPEG pixels.
!   */
!   gray=pixel_data[0];
!   p=jpeg_image->packet;
!   for (column=jpeg_info->image_width; column > 0; column--)
!   {
!     if (jpeg_image->runlength > 0)
!       jpeg_image->runlength--;
!     else
!       {
!         p++;
!         jpeg_image->runlength=p->length;
!       }
!     *gray++=(JSAMPLE) p->red;
!   }
!   jpeg_image->packet=p;
  }
  
! static void JPEGWriteRGB(jpeg_info,pixel_data)
! compress_info_ptr
!   jpeg_info;
  
! JSAMPARRAY
!   pixel_data;
  {
    register int
!     column;
  
!   register JSAMPROW
!     blue,
!     green,
!     red;
  
    register RunlengthPacket
      *p;
  
!   /*
!     Convert run-length encoded MIFF packets to JPEG pixels.
!   */
!   red=pixel_data[0];
!   green=pixel_data[1];
!   blue=pixel_data[2];
!   p=jpeg_image->packet;
!   for (column=jpeg_info->image_width; column > 0; column--)
!   {
!     if (jpeg_image->runlength > 0)
!       jpeg_image->runlength--;
!     else
!       {
!         p++;
!         jpeg_image->runlength=p->length;
!       }
!     *red++=(JSAMPLE) p->red;
!     *green++=(JSAMPLE) p->green;
!     *blue++=(JSAMPLE) p->blue;
!   }
!   jpeg_image->packet=p;
! }
! 
! static void JPEGSelectMethod(jpeg_info)
! compress_info_ptr
!   jpeg_info;
! {
!   jpeg_info->methods->get_input_row=JPEGWriteRGB;
!   if (jpeg_info->in_color_space == CS_GRAYSCALE)
!     {
!       j_monochrome_default(jpeg_info);
!       jpeg_info->methods->get_input_row=JPEGWriteGRAY;
!     }
! }
! 
! static unsigned int WriteJPEGImage(image,quality)
! Image
!   *image;
! 
! unsigned int
!   quality;
! {
!   struct Compress_info_struct
      jpeg_info;
  
!   struct Compress_methods_struct
!     jpeg_methods;
  
!   struct External_methods_struct
!     external_methods;
  
    /*
      Open image file.
***************
*** 1693,1781 ****
        Warning("Unable to open file",image->filename);
        return(False);
      }
!   /*
!     Initialize JPEG parameters.
!   */
!   jpeg_info.err=jpeg_std_error(&jpeg_error);
!   jpeg_info.err->emit_message=EmitMessage;
!   jpeg_create_compress(&jpeg_info);
!   jpeg_stdio_dest(&jpeg_info,image->file);
!   jpeg_info.image_width=image->columns;
!   jpeg_info.image_height=image->rows;
!   jpeg_info.input_components=3;
!   jpeg_info.in_color_space=JCS_RGB;
!   if (IsGrayImage(image))
!     {
!       jpeg_info.input_components=1;
!       jpeg_info.in_color_space=JCS_GRAYSCALE;
!     }
!   jpeg_set_defaults(&jpeg_info);
!   jpeg_set_quality(&jpeg_info,image_info->quality,True);
!   jpeg_start_compress(&jpeg_info,True);
!   if (image->comments != (char *) NULL)
!     jpeg_write_marker(&jpeg_info,JPEG_COM,(unsigned char *) image->comments,
!       (unsigned int) strlen(image->comments));
!   /*
!     Convert MIFF to JPEG raster pixels.
!   */
!   packets=jpeg_info.input_components*image->columns*image->rows;
!   jpeg_pixels=(JSAMPLE *) malloc(packets*sizeof(JSAMPLE));
!   scanlines=(JSAMPLE **) malloc(image->rows*sizeof(JSAMPLE *));
!   if ((jpeg_pixels == (JSAMPLE *) NULL) || (scanlines == (JSAMPLE **) NULL))
!     {
!       Warning("Unable to write image","Memory allocation failed");
!       return(False);
!     }
!   p=image->pixels;
!   q=jpeg_pixels;
!   if (jpeg_info.in_color_space == JCS_GRAYSCALE)
!     for (i=0; i < image->packets; i++)
!     {
!       for (j=0; j <= (int) p->length; j++)
!         *q++=(JSAMPLE) Intensity(*p);
!       p++;
!     }
!   else
!     for (i=0; i < image->packets; i++)
!     {
!       for (j=0; j <= (int) p->length; j++)
        {
!         *q++=(JSAMPLE) p->red;
!         *q++=(JSAMPLE) p->green;
!         *q++=(JSAMPLE) p->blue;
        }
-       p++;
-     }
    /*
!     Write JPEG raster pixels.
    */
!   for (i=0; i < image->rows; i++)
!     scanlines[i]=jpeg_pixels+(i*image->columns*jpeg_info.input_components);
!   for (i=0; i < image->rows; i+=count)
!     count=jpeg_write_scanlines(&jpeg_info,scanlines+i,image->rows-i);
!   jpeg_finish_compress(&jpeg_info);
!   /*
!     Free memory.
!   */
!   (void) free((char *) scanlines);
!   (void) free((char *) jpeg_pixels);
!   jpeg_destroy_compress(&jpeg_info);
    CloseImage(image);
    return(True);
  }
  #else
! static unsigned int WriteJPEGImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
    unsigned int
      status;
  
    Warning("JPEG library is not available",image->filename);
!   status=WriteMIFFImage(image_info,image);
    return(status);
  }
  #endif
--- 1738,1794 ----
        Warning("Unable to open file",image->filename);
        return(False);
      }
!   if (image->class == DirectClass)
!     if (NumberColors(image,(FILE *) NULL) <= 256)
        {
!         /*
!           Demote DirectClass to PseudoClass.
!         */
!         QuantizeImage(image,256,8,False,RGBColorspace,True);
!         SyncImage(image);
        }
    /*
!     Initialize the JPEG system-dependent methods.
    */
!   jpeg_image=image;
!   jpeg_info.methods=(&jpeg_methods);
!   jpeg_info.emethods=(&external_methods);
!   jselerror(&external_methods);
!   jselmemmgr(&external_methods);
!   jpeg_info.methods->input_init=JPEGInitializeImage;
!   jpeg_info.methods->input_term=JPEGInputTermMethod;
!   jpeg_methods.c_ui_method_selection=JPEGSelectMethod;
!   j_c_defaults(&jpeg_info,quality,False);
!   jpeg_info.optimize_coding=True;
!   jpeg_info.restart_in_rows=1;
!   if ((image->class == PseudoClass) && (image->colors <= 256))
!     jpeg_info.smoothing_factor=25;
!   /*
!     Write a JFIF JPEG file.
!   */
! #ifdef HUFF_LOOKAHEAD
!   jpeg_info.comment_text=jpeg_image->comments;
! #endif
!   jpeg_info.input_file=(FILE *) NULL;
!   jpeg_info.output_file=image->file;
!   jselwjfif(&jpeg_info);
!   jpeg_compress(&jpeg_info);
    CloseImage(image);
    return(True);
  }
  #else
! static unsigned int WriteJPEGImage(image,quality)
  Image
    *image;
+ 
+ unsigned int
+   quality;
  {
    unsigned int
      status;
  
    Warning("JPEG library is not available",image->filename);
!   status=WriteMIFFImage(image);
    return(status);
  }
  #endif
***************
*** 1796,1802 ****
  %
  %  The format of the WriteMAPImage routine is:
  %
! %      status=WriteMAPImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 1809,1815 ----
  %
  %  The format of the WriteMAPImage routine is:
  %
! %      status=WriteMAPImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 1804,1819 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteMAPImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 1817,1827 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteMAPImage(image)
  Image
    *image;
  {
***************
*** 1843,1850 ****
        /*
          Demote DirectClass to PseudoClass.
        */
!       QuantizeImage(image,MaxColormapSize,8,image_info->dither,RGBColorspace,
!         True);
        SyncImage(image);
      }
    colormap=(unsigned char *) malloc(3*image->colors*sizeof(unsigned char));
--- 1851,1857 ----
        /*
          Demote DirectClass to PseudoClass.
        */
!       QuantizeImage(image,MaxColormapSize,8,False,RGBColorspace,True);
        SyncImage(image);
      }
    colormap=(unsigned char *) malloc(3*image->colors*sizeof(unsigned char));
***************
*** 1894,1900 ****
  %
  %  The format of the WriteMATTEImage routine is:
  %
! %      status=WriteMATTEImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 1901,1907 ----
  %
  %  The format of the WriteMATTEImage routine is:
  %
! %      status=WriteMATTEImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 1902,1917 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteMATTEImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 1909,1919 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteMATTEImage(image)
  Image
    *image;
  {
***************
*** 1982,1988 ****
  %
  %  The format of the WriteMIFFImage routine is:
  %
! %      status=WriteMIFFImage(image_info,image)
  %
  %  A description of each parameter follows:
  %
--- 1984,1990 ----
  %
  %  The format of the WriteMIFFImage routine is:
  %
! %      status=WriteMIFFImage(image)
  %
  %  A description of each parameter follows:
  %
***************
*** 1990,2005 ****
  %      False is returned if there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image: A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteMIFFImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 1992,2002 ----
  %      False is returned if there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image: A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteMIFFImage(image)
  Image
    *image;
  {
***************
*** 2030,2040 ****
        Warning("Unable to open file",image->filename);
        return(False);
      }
!   (void) strcpy(image->magick,"MIFF");
    /*
      Pack image pixels.
    */
!   if (IsPseudoClass(image) && (image->compression == QEncodedCompression))
      image->class=DirectClass;
    (void) RunlengthEncodeImage(image);
    packets=image->packets;
--- 2027,2046 ----
        Warning("Unable to open file",image->filename);
        return(False);
      }
!   if (image->class == DirectClass)
!     if (NumberColors(image,(FILE *) NULL) <= 256)
!       {
!         /*
!           Demote DirectClass to PseudoClass.
!         */
!         QuantizeImage(image,256,8,False,RGBColorspace,True);
!         SyncImage(image);
!       }
    /*
      Pack image pixels.
    */
!   if ((image->class == PseudoClass) &&
!       (image->compression == QEncodedCompression))
      image->class=DirectClass;
    (void) RunlengthEncodeImage(image);
    packets=image->packets;
***************
*** 2154,2160 ****
  %
  %  The format of the WriteMTVImage routine is:
  %
! %      status=WriteMTVImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 2160,2166 ----
  %
  %  The format of the WriteMTVImage routine is:
  %
! %      status=WriteMTVImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 2162,2177 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteMTVImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 2168,2178 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteMTVImage(image)
  Image
    *image;
  {
***************
*** 2243,2249 ****
  %
  %  The format of the WritePCDImage routine is:
  %
! %      status=WritePCDImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 2244,2250 ----
  %
  %  The format of the WritePCDImage routine is:
  %
! %      status=WritePCDImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 2251,2266 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WritePCDImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 2252,2262 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WritePCDImage(image)
  Image
    *image;
  {
***************
*** 2268,2274 ****
      status;
  
    Warning("Cannot write PCD images",image->filename);
!   status=WriteMIFFImage(image_info,image);
    return(status);
  }
  
--- 2264,2270 ----
      status;
  
    Warning("Cannot write PCD images",image->filename);
!   status=WriteMIFFImage(image);
    return(status);
  }
  
***************
*** 2288,2294 ****
  %
  %  The format of the WritePCXImage routine is:
  %
! %      status=WritePCXImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 2284,2290 ----
  %
  %  The format of the WritePCXImage routine is:
  %
! %      status=WritePCXImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 2296,2311 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WritePCXImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 2292,2302 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WritePCXImage(image)
  Image
    *image;
  {
***************
*** 2368,2384 ****
        Warning("Unable to open file",image->filename);
        return(False);
      }
-   /*
-     Initialize PCX raster file header.
-   */
    if ((image->class == DirectClass) || (image->colors > 256))
      {
        /*
          Demote DirectClass to PseudoClass.
        */
!       QuantizeImage(image,256,8,image_info->dither,RGBColorspace,True);
        SyncImage(image);
      }
    pcx_header.identifier=0x0a;
    pcx_header.version=5;
    pcx_header.encoding=1;
--- 2359,2375 ----
        Warning("Unable to open file",image->filename);
        return(False);
      }
    if ((image->class == DirectClass) || (image->colors > 256))
      {
        /*
          Demote DirectClass to PseudoClass.
        */
!       QuantizeImage(image,256,8,True,RGBColorspace,True);
        SyncImage(image);
      }
+   /*
+     Initialize PCX raster file header.
+   */
    pcx_header.identifier=0x0a;
    pcx_header.version=5;
    pcx_header.encoding=1;
***************
*** 2569,2575 ****
  %
  %  The format of the WritePICTImage routine is:
  %
! %      status=WritePICTImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 2560,2566 ----
  %
  %  The format of the WritePICTImage routine is:
  %
! %      status=WritePICTImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 2577,2597 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WritePICTImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
  #define MaxCount  128
! #define PictCropRegionOp  0x01
  #define PictEndOfPictureOp  0xff
  #define PictHeaderOp  0x0C00
  #define PictHeaderSize  512
--- 2568,2583 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WritePICTImage(image)
  Image
    *image;
  {
  #define MaxCount  128
! #define PictClipRegionOp  0x01
  #define PictEndOfPictureOp  0xff
  #define PictHeaderOp  0x0C00
  #define PictHeaderSize  512
***************
*** 2645,2651 ****
      pixmap;
  
    PICTRectangle
!     crop_rectangle,
      destination_rectangle,
      frame_rectangle,
      size_rectangle,
--- 2631,2637 ----
      pixmap;
  
    PICTRectangle
!     clip_rectangle,
      destination_rectangle,
      frame_rectangle,
      size_rectangle,
***************
*** 2683,2688 ****
--- 2669,2683 ----
        Warning("Unable to open file",image->filename);
        return(False);
      }
+   if (image->class == DirectClass)
+     if (NumberColors(image,(FILE *) NULL) <= 256)
+       {
+         /*
+           Demote DirectClass to PseudoClass.
+         */
+         QuantizeImage(image,256,8,False,RGBColorspace,True);
+         SyncImage(image);
+       }
    /*
      Allocate memory.
    */
***************
*** 2708,2714 ****
    size_rectangle.right=image->rows;
    size_rectangle.bottom=image->columns;
    frame_rectangle=size_rectangle;
!   crop_rectangle=size_rectangle;
    source_rectangle=size_rectangle;
    destination_rectangle=size_rectangle;
    horizontal_resolution=0x00480000;
--- 2703,2709 ----
    size_rectangle.right=image->rows;
    size_rectangle.bottom=image->columns;
    frame_rectangle=size_rectangle;
!   clip_rectangle=size_rectangle;
    source_rectangle=size_rectangle;
    destination_rectangle=size_rectangle;
    horizontal_resolution=0x00480000;
***************
*** 2759,2772 ****
    MSBFirstWriteShort(frame_rectangle.bottom,image->file);
    MSBFirstWriteLong(0L,image->file);
    /*
!     Write crop region opcode and crop bounding box.
    */
!   MSBFirstWriteShort(PictCropRegionOp,image->file);
    MSBFirstWriteShort(0xA,image->file);
!   MSBFirstWriteShort(crop_rectangle.top,image->file);
!   MSBFirstWriteShort(crop_rectangle.left,image->file);
!   MSBFirstWriteShort(crop_rectangle.right,image->file);
!   MSBFirstWriteShort(crop_rectangle.bottom,image->file);
    /*
      Write picture opcode, row bytes, and picture bounding box, and version.
    */
--- 2754,2767 ----
    MSBFirstWriteShort(frame_rectangle.bottom,image->file);
    MSBFirstWriteLong(0L,image->file);
    /*
!     Write clip region opcode and clip bounding box.
    */
!   MSBFirstWriteShort(PictClipRegionOp,image->file);
    MSBFirstWriteShort(0xA,image->file);
!   MSBFirstWriteShort(clip_rectangle.top,image->file);
!   MSBFirstWriteShort(clip_rectangle.left,image->file);
!   MSBFirstWriteShort(clip_rectangle.right,image->file);
!   MSBFirstWriteShort(clip_rectangle.bottom,image->file);
    /*
      Write picture opcode, row bytes, and picture bounding box, and version.
    */
***************
*** 2922,2928 ****
  %
  %  The format of the WritePNMImage routine is:
  %
! %      status=WritePNMImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 2917,2923 ----
  %
  %  The format of the WritePNMImage routine is:
  %
! %      status=WritePNMImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 2930,2945 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WritePNMImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 2925,2935 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WritePNMImage(image)
  Image
    *image;
  {
***************
*** 2977,2996 ****
    else
      if (strcmp(image->magick,"PGM") == 0)
        {
!         QuantizeImage(image,256,8,image_info->dither,GRAYColorspace,True);
          SyncImage(image);
        }
      else
        if (strcmp(image->magick,"PBM") == 0)
          {
!           QuantizeImage(image,2,8,image_info->dither,GRAYColorspace,True);
            SyncImage(image);
          }
    /*
      Write PNM file header.
    */
    packets=image->columns*image->rows;
!   if (!IsPseudoClass(image))
      {
        /*
          Full color PNM image.
--- 2967,2996 ----
    else
      if (strcmp(image->magick,"PGM") == 0)
        {
!         QuantizeImage(image,256,8,False,GRAYColorspace,True);
          SyncImage(image);
        }
      else
        if (strcmp(image->magick,"PBM") == 0)
          {
!           QuantizeImage(image,2,8,False,GRAYColorspace,True);
            SyncImage(image);
          }
+       else
+         if (image->class == DirectClass)
+           if (NumberColors(image,(FILE *) NULL) <= 256)
+             {
+               /*
+                 Demote DirectClass to PseudoClass.
+               */
+               QuantizeImage(image,256,8,False,RGBColorspace,True);
+               SyncImage(image);
+             }
    /*
      Write PNM file header.
    */
    packets=image->columns*image->rows;
!   if ((image->class == DirectClass) || (image->colors > 256))
      {
        /*
          Full color PNM image.
***************
*** 3012,3020 ****
              Grayscale PNM image.
            */
            format='5';
!           if (strcmp(image->magick,"PGM") != 0)
!             if (image->colors == 2)
!               format='4';
          }
      }
    (void) fprintf(image->file,"P%c\n",format);
--- 3012,3019 ----
              Grayscale PNM image.
            */
            format='5';
!           if (image->colors == 2)
!             format='4';
          }
      }
    (void) fprintf(image->file,"P%c\n",format);
***************
*** 3144,3194 ****
  %                                                                             %
  %                                                                             %
  %                                                                             %
- %   W r i t e R A D I A N C E I m a g e                                       %
- %                                                                             %
- %                                                                             %
- %                                                                             %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- %  Function WriteRADIANCEImage writes an image in the RADIANCE encoded image
- %  format.
- %
- %  The format of the WriteRADIANCEImage routine is:
- %
- %      status=WriteRADIANCEImage(image_info,image)
- %
- %  A description of each parameter follows.
- %
- %    o status: Function WriteRADIANCEImage return True if the image is written.
- %      False is returned is there is a memory shortage or if the image file
- %      fails to write.
- %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
- %    o image:  A pointer to a Image structure.
- %
- %
- */
- static unsigned int WriteRADIANCEImage(image_info,image)
- ImageInfo
-   *image_info;
- 
- Image
-   *image;
- {
-   unsigned int
-     status;
- 
-   Warning("Cannot write RADIANCE images",image->filename);
-   status=WriteMIFFImage(image_info,image);
-   return(status);
- }
- 
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %                                                                             %
- %                                                                             %
- %                                                                             %
  %   W r i t e R L E I m a g e                                                 %
  %                                                                             %
  %                                                                             %
--- 3143,3148 ----
***************
*** 3200,3206 ****
  %
  %  The format of the WriteRLEImage routine is:
  %
! %      status=WriteRLEImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 3154,3160 ----
  %
  %  The format of the WriteRLEImage routine is:
  %
! %      status=WriteRLEImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 3208,3223 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteRLEImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 3162,3172 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteRLEImage(image)
  Image
    *image;
  {
***************
*** 3225,3231 ****
      status;
  
    Warning("Cannot write RLE images",image->filename);
!   status=WriteMIFFImage(image_info,image);
    return(status);
  }
  
--- 3174,3180 ----
      status;
  
    Warning("Cannot write RLE images",image->filename);
!   status=WriteMIFFImage(image);
    return(status);
  }
  
***************
*** 3247,3253 ****
  %
  %  The format of the WritePSImage routine is:
  %
! %      status=WritePSImage(image_info,image)
  %
  %  A description of each parameter follows:
  %
--- 3196,3202 ----
  %
  %  The format of the WritePSImage routine is:
  %
! %      status=WritePSImage(image,geometry,density)
  %
  %  A description of each parameter follows:
  %
***************
*** 3254,3272 ****
  %    o status: Function WritePSImage return True if the image is printed.
  %      False is returned if the image file cannot be opened for printing.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image: The address of a structure of type Image;  returned from
  %      ReadImage.
  %
  %
  */
! static unsigned int WritePSImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
    static char
      *Postscript[]=
--- 3203,3226 ----
  %    o status: Function WritePSImage return True if the image is printed.
  %      False is returned if the image file cannot be opened for printing.
  %
  %    o image: The address of a structure of type Image;  returned from
  %      ReadImage.
  %
+ %    o geometry: A pointer to a geometry string.  Specifies the width and
+ %      height of the Postscript image.
+ %
+ %    o density: A pointer to a density string.  Specifies the dots-per-inch
+ %      of the Postscript image.
  %
+ %
  */
! static unsigned int WritePSImage(image,geometry,density)
  Image
    *image;
+ 
+ char
+   *geometry,
+   *density;
  {
    static char
      *Postscript[]=
***************
*** 3542,3547 ****
--- 3496,3510 ----
        Warning("Unable to open file",image->filename);
        return(False);
      }
+   if (image->class == DirectClass)
+     if (NumberColors(image,(FILE *) NULL) <= 256)
+       {
+         /*
+           Demote DirectClass to PseudoClass.
+         */
+         QuantizeImage(image,256,8,False,RGBColorspace,True);
+         SyncImage(image);
+       }
    /*
      Scale image to size of Postscript page.
    */
***************
*** 3559,3584 ****
          page_height,
          page_width;
  
        /*
          Center image on Postscript page.
        */
        (void) XParseGeometry(PSPageGeometry,&x,&y,&page_width,&page_height);
!       flags=XParseGeometry(image_info->page,&x,&y,&page_width,&page_height);
!       if (((page_width-(x << 1)) < width) ||
!           ((page_height-(y << 1)-text_size) < height))
!         {
!           unsigned long
!             scale_factor;
! 
!           /*
!             Scale image relative to Postscript page.
!           */
!           scale_factor=UpShift(page_width-(x << 1))/width;
!           if (scale_factor > (UpShift(page_height-(y << 1)-text_size)/height))
!             scale_factor=UpShift(page_height-(y << 1)-text_size)/height;
!           width=DownShift(width*scale_factor);
!           height=DownShift(height*scale_factor);
!         }
        if (((flags & XValue) == 0) && ((flags & YValue) == 0))
          {
            int
--- 3522,3540 ----
          page_height,
          page_width;
  
+       unsigned long
+         scale_factor;
+ 
        /*
          Center image on Postscript page.
        */
        (void) XParseGeometry(PSPageGeometry,&x,&y,&page_width,&page_height);
!       flags=XParseGeometry(geometry,&x,&y,&page_width,&page_height);
!       scale_factor=UpShift(page_width-(x << 1))/image->columns;
!       if (scale_factor > (UpShift(page_height-(y << 1)-text_size)/image->rows))
!         scale_factor=UpShift(page_height-(y << 1)-text_size)/image->rows;
!       width=DownShift(image->columns*scale_factor);
!       height=DownShift(image->rows*scale_factor);
        if (((flags & XValue) == 0) && ((flags & YValue) == 0))
          {
            int
***************
*** 3600,3607 ****
      &dx_resolution,&dy_resolution);
    x_resolution=dx_resolution;
    y_resolution=dy_resolution;
!   (void) XParseGeometry(image_info->density,&sans_offset,&sans_offset,
!     &x_resolution,&y_resolution);
    width=(width*dx_resolution)/x_resolution;
    height=(height*dy_resolution)/y_resolution;
    /*
--- 3556,3563 ----
      &dx_resolution,&dy_resolution);
    x_resolution=dx_resolution;
    y_resolution=dy_resolution;
!   (void) XParseGeometry(density,&sans_offset,&sans_offset,&x_resolution,
!     &y_resolution);
    width=(width*dx_resolution)/x_resolution;
    height=(height*dy_resolution)/y_resolution;
    /*
***************
*** 3652,3658 ****
        /*
          Convert MIFF to bitmap pixels.
        */
!       QuantizeImage(preview_image,2,8,image_info->dither,GRAYColorspace,True);
        polarity=0;
        if (image->colors == 2)
          polarity=Intensity(image->colormap[0]) > Intensity(image->colormap[1]);
--- 3608,3614 ----
        /*
          Convert MIFF to bitmap pixels.
        */
!       QuantizeImage(preview_image,2,8,False,GRAYColorspace,True);
        polarity=0;
        if (image->colors == 2)
          polarity=Intensity(image->colormap[0]) > Intensity(image->colormap[1]);
***************
*** 3876,3882 ****
  %
  %  The format of the WritePS2Image routine is:
  %
! %      status=WritePS2Image(image_info,image)
  %
  %  A description of each parameter follows:
  %
--- 3832,3838 ----
  %
  %  The format of the WritePS2Image routine is:
  %
! %      status=WritePS2Image(image,geometry,density)
  %
  %  A description of each parameter follows:
  %
***************
*** 3883,3901 ****
  %    o status: Function WritePS2Image return True if the image is printed.
  %      False is returned if the image file cannot be opened for printing.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image: The address of a structure of type Image;  returned from
  %      ReadImage.
  %
  %
  */
! static unsigned int WritePS2Image(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
    static char
      *Postscript[]=
--- 3839,3862 ----
  %    o status: Function WritePS2Image return True if the image is printed.
  %      False is returned if the image file cannot be opened for printing.
  %
  %    o image: The address of a structure of type Image;  returned from
  %      ReadImage.
  %
+ %    o geometry: A pointer to a geometry string.  Specifies the width and
+ %      height of the Postscript image.
  %
+ %    o density: A pointer to a density string.  Specifies the dots-per-inch
+ %      of the Postscript image.
+ %
+ %
  */
! static unsigned int WritePS2Image(image,geometry,density)
  Image
    *image;
+ 
+ char
+   *geometry,
+   *density;
  {
    static char
      *Postscript[]=
***************
*** 4047,4052 ****
--- 4008,4022 ----
        Warning("Unable to open file",image->filename);
        return(False);
      }
+   if (image->class == DirectClass)
+     if (NumberColors(image,(FILE *) NULL) <= 256)
+       {
+         /*
+           Demote DirectClass to PseudoClass.
+         */
+         QuantizeImage(image,256,8,False,RGBColorspace,True);
+         SyncImage(image);
+       }
    /*
      Scale image to size of Postscript page.
    */
***************
*** 4064,4089 ****
          page_height,
          page_width;
  
        /*
          Center image on Postscript page.
        */
        (void) XParseGeometry(PSPageGeometry,&x,&y,&page_width,&page_height);
!       flags=XParseGeometry(image_info->page,&x,&y,&page_width,&page_height);
!       if (((page_width-(x << 1)) < width) ||
!           ((page_height-(y << 1)-text_size) < height))
!         {
!           unsigned long
!             scale_factor;
! 
!           /*
!             Scale image relative to Postscript page.
!           */
!           scale_factor=UpShift(page_width-(x << 1))/width;
!           if (scale_factor > (UpShift(page_height-(y << 1)-text_size)/height))
!             scale_factor=UpShift(page_height-(y << 1)-text_size)/height;
!           width=DownShift(width*scale_factor);
!           height=DownShift(height*scale_factor);
!         }
        if (((flags & XValue) == 0) && ((flags & YValue) == 0))
          {
            int
--- 4034,4052 ----
          page_height,
          page_width;
  
+       unsigned long
+         scale_factor;
+ 
        /*
          Center image on Postscript page.
        */
        (void) XParseGeometry(PSPageGeometry,&x,&y,&page_width,&page_height);
!       flags=XParseGeometry(geometry,&x,&y,&page_width,&page_height);
!       scale_factor=UpShift(page_width-(x << 1))/image->columns;
!       if (scale_factor > (UpShift(page_height-(y << 1)-text_size)/image->rows))
!         scale_factor=UpShift(page_height-(y << 1)-text_size)/image->rows;
!       width=DownShift(image->columns*scale_factor);
!       height=DownShift(image->rows*scale_factor);
        if (((flags & XValue) == 0) && ((flags & YValue) == 0))
          {
            int
***************
*** 4105,4112 ****
      &dx_resolution,&dy_resolution);
    x_resolution=dx_resolution;
    y_resolution=dy_resolution;
!   (void) XParseGeometry(image_info->density,&sans_offset,&sans_offset,
!     &x_resolution,&y_resolution);
    width=(width*dx_resolution)/x_resolution;
    height=(height*dy_resolution)/y_resolution;
    /*
--- 4068,4075 ----
      &dx_resolution,&dy_resolution);
    x_resolution=dx_resolution;
    y_resolution=dy_resolution;
!   (void) XParseGeometry(density,&sans_offset,&sans_offset,&x_resolution,
!     &y_resolution);
    width=(width*dx_resolution)/x_resolution;
    height=(height*dy_resolution)/y_resolution;
    /*
***************
*** 4146,4152 ****
    if (label == (char *) NULL)
      label=" ";
    p=image->pixels;
!   if (!IsPseudoClass(image))
      {
        (void) fprintf(image->file,"%d %d\n%u %u\n%s           \n%u %u\n%d\n%d\n",
          x,y,width,height,label,image->columns,image->rows,
--- 4109,4115 ----
    if (label == (char *) NULL)
      label=" ";
    p=image->pixels;
!   if ((image->class == DirectClass) || (image->colors > 256))
      {
        (void) fprintf(image->file,"%d %d\n%u %u\n%s           \n%u %u\n%d\n%d\n",
          x,y,width,height,label,image->columns,image->rows,
***************
*** 4309,4315 ****
  %
  %  The format of the WriteRGBImage routine is:
  %
! %      status=WriteRGBImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 4272,4278 ----
  %
  %  The format of the WriteRGBImage routine is:
  %
! %      status=WriteRGBImage(image,interlace)
  %
  %  A description of each parameter follows.
  %
***************
*** 4317,4334 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteRGBImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
    register int
      i,
--- 4280,4298 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
+ %    o interlace:  An unsigned integer that specifies the interlacing
+ %      scheme.
+ %
  %
  */
! static unsigned int WriteRGBImage(image,interlace)
  Image
    *image;
+ 
+ unsigned int
+   interlace;
  {
    register int
      i,
***************
*** 4363,4369 ****
        return(False);
      }
    q=rgb_pixels;
!   switch (image_info->interlace)
    {
      case NoneInterlace:
      default:
--- 4327,4333 ----
        return(False);
      }
    q=rgb_pixels;
!   switch (interlace)
    {
      case NoneInterlace:
      default:
***************
*** 4469,4475 ****
  %
  %  The format of the WriteSUNImage routine is:
  %
! %      status=WriteSUNImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 4433,4439 ----
  %
  %  The format of the WriteSUNImage routine is:
  %
! %      status=WriteSUNImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 4477,4492 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteSUNImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 4441,4451 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteSUNImage(image)
  Image
    *image;
  {
***************
*** 4535,4540 ****
--- 4494,4508 ----
        Warning("Unable to open file",image->filename);
        return(False);
      }
+   if (image->class == DirectClass)
+     if (NumberColors(image,(FILE *) NULL) <= 256)
+       {
+         /*
+           Demote DirectClass to PseudoClass.
+         */
+         QuantizeImage(image,256,8,False,RGBColorspace,True);
+         SyncImage(image);
+       }
    /*
      Initialize SUN raster file header.
    */
***************
*** 4544,4550 ****
    sun_header.type=(image->class == DirectClass ? RT_FORMAT_RGB : RT_STANDARD);
    sun_header.maptype=RMT_NONE;
    sun_header.maplength=0;
!   if (!IsPseudoClass(image))
      {
        /*
          Full color SUN raster.
--- 4512,4518 ----
    sun_header.type=(image->class == DirectClass ? RT_FORMAT_RGB : RT_STANDARD);
    sun_header.maptype=RMT_NONE;
    sun_header.maplength=0;
!   if ((image->class == DirectClass) || (image->colors > 256))
      {
        /*
          Full color SUN raster.
***************
*** 4598,4604 ****
    p=image->pixels;
    q=sun_pixels;
    x=0;
!   if (!IsPseudoClass(image))
      {
        /*
          Convert DirectClass packet to SUN RGB pixel.
--- 4566,4572 ----
    p=image->pixels;
    q=sun_pixels;
    x=0;
!   if ((image->class == DirectClass) || (image->colors > 256))
      {
        /*
          Convert DirectClass packet to SUN RGB pixel.
***************
*** 4737,4743 ****
  %
  %  The format of the WriteTARGAImage routine is:
  %
! %      status=WriteTARGAImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 4705,4711 ----
  %
  %  The format of the WriteTARGAImage routine is:
  %
! %      status=WriteTARGAImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 4745,4760 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteTARGAImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 4713,4723 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteTARGAImage(image)
  Image
    *image;
  {
***************
*** 4820,4825 ****
--- 4783,4797 ----
        Warning("Unable to open file",image->filename);
        return(False);
      }
+   if (image->class == DirectClass)
+     if (NumberColors(image,(FILE *) NULL) <= 256)
+       {
+         /*
+           Demote DirectClass to PseudoClass.
+         */
+         QuantizeImage(image,256,8,False,RGBColorspace,True);
+         SyncImage(image);
+       }
    /*
      Reflect image.
    */
***************
*** 4847,4853 ****
    targa_header.height=image->rows;
    targa_header.pixel_size=8;
    targa_header.attributes=0;
!   if (!IsPseudoClass(image))
      {
        /*
          Full color TARGA raster.
--- 4819,4825 ----
    targa_header.height=image->rows;
    targa_header.pixel_size=8;
    targa_header.attributes=0;
!   if ((image->class == DirectClass) || (image->colors > 256))
      {
        /*
          Full color TARGA raster.
***************
*** 4915,4921 ****
      }
    p=image->pixels+(image->packets-1);
    q=targa_pixels;
!   if (!IsPseudoClass(image))
      {
        /*
          Convert DirectClass packet to TARGA RGB pixel.
--- 4887,4893 ----
      }
    p=image->pixels+(image->packets-1);
    q=targa_pixels;
!   if ((image->class == DirectClass) || (image->colors > 256))
      {
        /*
          Convert DirectClass packet to TARGA RGB pixel.
***************
*** 5109,5115 ****
  %
  %  The format of the WriteTEXTImage routine is:
  %
! %      status=WriteTEXTImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 5081,5087 ----
  %
  %  The format of the WriteTEXTImage routine is:
  %
! %      status=WriteTEXTImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 5117,5132 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteTEXTImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 5089,5099 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteTEXTImage(image)
  Image
    *image;
  {
***************
*** 5134,5140 ****
      status;
  
    Warning("Cannot write TEXT images",image->filename);
!   status=WriteMIFFImage(image_info,image);
    return(status);
  }
  
--- 5101,5107 ----
      status;
  
    Warning("Cannot write TEXT images",image->filename);
!   status=WriteMIFFImage(image);
    return(status);
  }
  
***************
*** 5156,5162 ****
  %
  %  The format of the WriteTIFFImage routine is:
  %
! %      status=WriteTIFFImage(image_info,image)
  %
  %  A description of each parameter follows:
  %
--- 5123,5129 ----
  %
  %  The format of the WriteTIFFImage routine is:
  %
! %      status=WriteTIFFImage(image,verbose)
  %
  %  A description of each parameter follows:
  %
***************
*** 5164,5185 ****
  %      False is returned is there is of a memory shortage or if the image
  %      file cannot be opened for writing.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteTIFFImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
- {
-   Image
-     encode_image;
  
    register RunlengthPacket
      *p;
  
--- 5131,5150 ----
  %      False is returned is there is of a memory shortage or if the image
  %      file cannot be opened for writing.
  %
  %    o image:  A pointer to a Image structure.
  %
+ %    o verbose:  A value greater than zero prints detailed information about
+ %      the image.
  %
+ %
  */
! static unsigned int WriteTIFFImage(image,verbose)
  Image
    *image;
  
+ unsigned int
+   verbose;
+ {
    register RunlengthPacket
      *p;
  
***************
*** 5205,5230 ****
    /*
      Open TIFF file.
    */
!   OpenImage(image,"wb");
!   if (image->file != (FILE *) NULL)
!     if ((image->file == stdout) || image->pipe)
        {
          /*
!           Write standard output or pipe to temporary file.
          */
!         encode_image=(*image);
!         TemporaryFilename(image->filename);
!         OpenImage(image,"wb");
!         image->temporary=True;
        }
-   if (image->file == (FILE *) NULL)
-     {
-       Warning("Unable to open file",image->filename);
-       return(False);
-     }
-   tiff=TIFFFdOpen(fileno(image->file),image->filename,"wb");
-   if (tiff == (TIFF *) NULL)
-     return(False);
    /*
      Initialize TIFF fields.
    */
--- 5170,5187 ----
    /*
      Open TIFF file.
    */
!   tiff=TIFFOpen(image->filename,"wb");
!   if (tiff == (TIFF *) NULL)
!     return(False);
!   if (image->class == DirectClass)
!     if (NumberColors(image,(FILE *) NULL) <= 256)
        {
          /*
!           Demote DirectClass to PseudoClass.
          */
!         QuantizeImage(image,256,8,False,RGBColorspace,True);
!         SyncImage(image);
        }
    /*
      Initialize TIFF fields.
    */
***************
*** 5232,5238 ****
    TIFFSetField(tiff,TIFFTAG_SOFTWARE,"ImageMagick");
    if (image->comments != (char *) NULL)
      TIFFSetField(tiff,TIFFTAG_IMAGEDESCRIPTION,image->comments);
!   if (!IsPseudoClass(image))
      {
        /*
          Full color TIFF raster.
--- 5189,5195 ----
    TIFFSetField(tiff,TIFFTAG_SOFTWARE,"ImageMagick");
    if (image->comments != (char *) NULL)
      TIFFSetField(tiff,TIFFTAG_IMAGEDESCRIPTION,image->comments);
!   if ((image->class == DirectClass) || (image->colors > 256))
      {
        /*
          Full color TIFF raster.
***************
*** 5424,5474 ****
          }
    (void) free((char *) scanline);
    (void) TIFFFlushData(tiff);
!   if (image_info->verbose == True)
      TIFFPrintDirectory(tiff,stderr,False);
    (void) TIFFClose(tiff);
-   if (image->temporary)
-     {
-       FILE
-         *file;
- 
-       int
-         c;
- 
-       /*
-         Copy temporary file to standard output or pipe.
-       */
-       file=fopen(image->filename,"rb");
-       if (file == (FILE *) NULL)
-         {
-           Warning("Unable to read file",image->filename);
-           return(False);
-         }
-       c=fgetc(file);
-       while (c != EOF)
-       {
-         (void) putc(c,encode_image.file);
-         c=fgetc(file);
-       }
-       (void) fclose(file);
-       (void) unlink(image->filename);
-       (void) CloseImage(&encode_image);
-     }
    return(True);
  }
  #else
! static unsigned int WriteTIFFImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
    unsigned int
      status;
  
    Warning("TIFF library is not available",image->filename);
!   status=WriteMIFFImage(image_info,image);
    return(status);
  }
  #endif
--- 5381,5404 ----
          }
    (void) free((char *) scanline);
    (void) TIFFFlushData(tiff);
!   if (verbose == True)
      TIFFPrintDirectory(tiff,stderr,False);
    (void) TIFFClose(tiff);
    return(True);
  }
  #else
! static unsigned int WriteTIFFImage(image,verbose)
  Image
    *image;
+ 
+ unsigned int
+   verbose;
  {
    unsigned int
      status;
  
    Warning("TIFF library is not available",image->filename);
!   status=WriteMIFFImage(image);
    return(status);
  }
  #endif
***************
*** 5488,5494 ****
  %
  %  The format of the WriteVICARImage routine is:
  %
! %      status=WriteVICARImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 5418,5424 ----
  %
  %  The format of the WriteVICARImage routine is:
  %
! %      status=WriteVICARImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 5496,5511 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteVICARImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 5426,5436 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteVICARImage(image)
  Image
    *image;
  {
***************
*** 5513,5519 ****
      status;
  
    Warning("Cannot write VICAR images",image->filename);
!   status=WriteMIFFImage(image_info,image);
    return(status);
  }
  
--- 5438,5444 ----
      status;
  
    Warning("Cannot write VICAR images",image->filename);
!   status=WriteMIFFImage(image);
    return(status);
  }
  
***************
*** 5532,5538 ****
  %
  %  The format of the WriteVIFFImage routine is:
  %
! %      status=WriteVIFFImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 5457,5463 ----
  %
  %  The format of the WriteVIFFImage routine is:
  %
! %      status=WriteVIFFImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 5540,5555 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteVIFFImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 5465,5475 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteVIFFImage(image)
  Image
    *image;
  {
***************
*** 5635,5640 ****
--- 5555,5569 ----
        Warning("Unable to open file",image->filename);
        return(False);
      }
+   if (image->class == DirectClass)
+     if (NumberColors(image,(FILE *) NULL) <= 256)
+       {
+         /*
+           Demote DirectClass to PseudoClass.
+         */
+         QuantizeImage(image,256,8,False,RGBColorspace,True);
+         SyncImage(image);
+       }
    /*
      Initialize VIFF image structure.
    */
***************
*** 5668,5674 ****
    viff_header.map_subrows=0;
    viff_header.map_enable=1;  /* no colormap */
    viff_header.maps_per_cycle=0;
!   if (!IsPseudoClass(image))
      {
        /*
          Full color VIFF raster.
--- 5597,5603 ----
    viff_header.map_subrows=0;
    viff_header.map_enable=1;  /* no colormap */
    viff_header.maps_per_cycle=0;
!   if ((image->class == DirectClass) || (image->colors > 256))
      {
        /*
          Full color VIFF raster.
***************
*** 5751,5757 ****
      }
    p=image->pixels;
    q=viff_pixels;
!   if (!IsPseudoClass(image))
      {
        unsigned long
          offset;
--- 5680,5686 ----
      }
    p=image->pixels;
    q=viff_pixels;
!   if ((image->class == DirectClass) || (image->colors > 256))
      {
        unsigned long
          offset;
***************
*** 5893,5899 ****
  %
  %  The format of the WriteXImage routine is:
  %
! %      status=WriteXImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 5822,5828 ----
  %
  %  The format of the WriteXImage routine is:
  %
! %      status=WriteXImage(image,server_name)
  %
  %  A description of each parameter follows.
  %
***************
*** 5901,5918 ****
  %      the X server.  False is returned is there is a memory shortage or if
  %      the image file fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteXImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
    Atom
      wm_delete_window,
--- 5830,5848 ----
  %      the X server.  False is returned is there is a memory shortage or if
  %      the image file fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
+ %    o server_name:  A pointer to a character string representing the
+ %      X server to display the image.
  %
+ %
  */
! static unsigned int WriteXImage(image,server_name)
  Image
    *image;
+ 
+ char
+   *server_name;
  {
    Atom
      wm_delete_window,
***************
*** 5955,5965 ****
    /*
      Open X server connection.
    */
!   display=XOpenDisplay(image_info->server_name);
    if (display == (Display *) NULL)
      {
!       Warning("Unable to connect to X server",
!         XDisplayName(image_info->server_name));
        return(False);
      }
    /*
--- 5885,5894 ----
    /*
      Open X server connection.
    */
!   display=XOpenDisplay(server_name);
    if (display == (Display *) NULL)
      {
!       Warning("Unable to connect to X server",XDisplayName(server_name));
        return(False);
      }
    /*
***************
*** 6095,6101 ****
  %
  %  The format of the WriteXBMImage routine is:
  %
! %      status=WriteXBMImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 6024,6030 ----
  %
  %  The format of the WriteXBMImage routine is:
  %
! %      status=WriteXBMImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 6103,6118 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteXBMImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 6032,6042 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteXBMImage(image)
  Image
    *image;
  {
***************
*** 6163,6169 ****
    /*
      Convert MIFF to X bitmap pixels.
    */
!   QuantizeImage(image,2,8,image_info->dither,GRAYColorspace,True);
    SyncImage(image);
    polarity=0;
    if (image->colors == 2)
--- 6087,6093 ----
    /*
      Convert MIFF to X bitmap pixels.
    */
!   QuantizeImage(image,2,8,False,GRAYColorspace,True);
    SyncImage(image);
    polarity=0;
    if (image->colors == 2)
***************
*** 6241,6247 ****
  %
  %  The format of the WriteXCImage routine is:
  %
! %      status=WriteXCImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 6165,6171 ----
  %
  %  The format of the WriteXCImage routine is:
  %
! %      status=WriteXCImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 6249,6264 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteXCImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 6173,6183 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteXCImage(image)
  Image
    *image;
  {
***************
*** 6266,6272 ****
      status;
  
    Warning("Cannot write XC images",image->filename);
!   status=WriteMIFFImage(image_info,image);
    return(status);
  }
  
--- 6185,6191 ----
      status;
  
    Warning("Cannot write XC images",image->filename);
!   status=WriteMIFFImage(image);
    return(status);
  }
  
***************
*** 6285,6291 ****
  %
  %  The format of the WriteXPMImage routine is:
  %
! %      status=WriteXPMImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 6204,6210 ----
  %
  %  The format of the WriteXPMImage routine is:
  %
! %      status=WriteXPMImage(image,server_name)
  %
  %  A description of each parameter follows.
  %
***************
*** 6293,6312 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
  #ifdef HasXPM
  #include "xpm.h"
! static unsigned int WriteXPMImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
    char
      *resource_value,
--- 6212,6232 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
+ %    o server_name:  A pointer to a character string representing the
+ %      X server to display the image.
+ %
  %
  */
  #ifdef HasXPM
  #include "xpm.h"
! static unsigned int WriteXPMImage(image,server_name)
  Image
    *image;
+ 
+ char
+   *server_name;
  {
    char
      *resource_value,
***************
*** 6358,6368 ****
    /*
      Open X server connection.
    */
!   display=XOpenDisplay(image_info->server_name);
    if (display == (Display *) NULL)
      {
!       Warning("Unable to connect to X server",
!         XDisplayName(image_info->server_name));
        return(False);
      }
    /*
--- 6278,6287 ----
    /*
      Open X server connection.
    */
!   display=XOpenDisplay(server_name);
    if (display == (Display *) NULL)
      {
!       Warning("Unable to connect to X server",XDisplayName(server_name));
        return(False);
      }
    /*
***************
*** 6470,6476 ****
        /*
          Demote DirectClass to PseudoClass.
        */
!       QuantizeImage(image,256,8,image_info->dither,RGBColorspace,True);
        SyncImage(image);
      }
    XMakeStandardColormap(display,visual_info,&resource_info,image,map_info,
--- 6389,6395 ----
        /*
          Demote DirectClass to PseudoClass.
        */
!       QuantizeImage(image,256,8,True,RGBColorspace,True);
        SyncImage(image);
      }
    XMakeStandardColormap(display,visual_info,&resource_info,image,map_info,
***************
*** 6521,6527 ****
      Free X resources.
    */
    if (matte_image != (XImage *) NULL)
!     XDestroyImage(matte_image);
    XpmFreeAttributes(&xpm_attributes);
    XFreeResources(display,visual_info,map_info,&pixel_info,(XFontStruct *) NULL,
      &resource_info,&window_info);
--- 6440,6446 ----
      Free X resources.
    */
    if (matte_image != (XImage *) NULL)
!     XDestroyImage(matte_image); 
    XpmFreeAttributes(&xpm_attributes);
    XFreeResources(display,visual_info,map_info,&pixel_info,(XFontStruct *) NULL,
      &resource_info,&window_info);
***************
*** 6539,6556 ****
    return(status != EOF);
  }
  #else
! static unsigned int WriteXPMImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
    unsigned int
      status;
  
    Warning("XPM library is not available",image->filename);
!   status=WriteMIFFImage(image_info,image);
    return(status);
  }
  #endif
--- 6458,6475 ----
    return(status != EOF);
  }
  #else
! static unsigned int WriteXPMImage(image,server_name)
  Image
    *image;
+ 
+ char
+   *server_name;
  {
    unsigned int
      status;
  
    Warning("XPM library is not available",image->filename);
!   status=WriteMIFFImage(image);
    return(status);
  }
  #endif
***************
*** 6571,6577 ****
  %
  %  The format of the WriteYUVImage routine is:
  %
! %      status=WriteYUVImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 6490,6496 ----
  %
  %  The format of the WriteYUVImage routine is:
  %
! %      status=WriteYUVImage(image,interlace)
  %
  %  A description of each parameter follows.
  %
***************
*** 6579,6596 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteYUVImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
    register int
      i,
--- 6498,6516 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
+ %    o interlace:  An unsigned integer that specifies the interlacing
+ %      scheme.
+ %
  %
  */
! static unsigned int WriteYUVImage(image,interlace)
  Image
    *image;
+ 
+ unsigned int
+   interlace;
  {
    register int
      i,
***************
*** 6626,6632 ****
      }
    RGBTransformImage(image,YCbCrColorspace);
    q=yuv_pixels;
!   switch (image_info->interlace)
    {
      case NoneInterlace:
      default:
--- 6546,6552 ----
      }
    RGBTransformImage(image,YCbCrColorspace);
    q=yuv_pixels;
!   switch (interlace)
    {
      case NoneInterlace:
      default:
***************
*** 6734,6740 ****
  %
  %  The format of the WriteYUV3Image routine is:
  %
! %      status=WriteYUV3Image(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 6654,6660 ----
  %
  %  The format of the WriteYUV3Image routine is:
  %
! %      status=WriteYUV3Image(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 6742,6757 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteYUV3Image(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 6662,6672 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteYUV3Image(image)
  Image
    *image;
  {
***************
*** 6891,6897 ****
  %
  %  The format of the WriteXWDImage routine is:
  %
! %      status=WriteXWDImage(image_info,image)
  %
  %  A description of each parameter follows.
  %
--- 6806,6812 ----
  %
  %  The format of the WriteXWDImage routine is:
  %
! %      status=WriteXWDImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 6899,6914 ****
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
- %    o image_info: Specifies a pointer to an ImageInfo structure.
- %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteXWDImage(image_info,image)
! ImageInfo
!   *image_info;
! 
  Image
    *image;
  {
--- 6814,6824 ----
  %      False is returned is there is a memory shortage or if the image file
  %      fails to write.
  %
  %    o image:  A pointer to a Image structure.
  %
  %
  */
! static unsigned int WriteXWDImage(image)
  Image
    *image;
  {
***************
*** 6949,6954 ****
--- 6859,6873 ----
        Warning("Unable to open file",image->filename);
        return(False);
      }
+   if (image->class == DirectClass)
+     if (NumberColors(image,(FILE *) NULL) <= 256)
+       {
+         /*
+           Demote DirectClass to PseudoClass.
+         */
+         QuantizeImage(image,256,8,False,RGBColorspace,True);
+         SyncImage(image);
+       }
    /*
      Initialize XWD file header.
    */
***************
*** 7138,7305 ****
    {
      case 'A':
      {
!       status=WriteAVSImage(image_info,image);
        break;
      }
      case 'B':
      {
!       status=WriteBMPImage(image_info,image);
        break;
      }
      case 'C':
      {
!       status=WriteCMYKImage(image_info,image);
        break;
      }
      case 'E':
      {
!       status=WritePSImage(image_info,image);
        break;
      }
      case 'F':
      {
        if (strcmp(image_info->magick,"FAX") == 0)
!         status=WriteFAXImage(image_info,image);
        else
!         status=WriteFITSImage(image_info,image);
        break;
      }
      case 'G':
      {
        if (strcmp(image_info->magick,"GIF") == 0)
!         status=WriteGIFImage(image_info,image);
        else
          if (strcmp(image_info->magick,"GIF87") == 0)
!           status=WriteGIFImage(image_info,image);
          else
            if (strcmp(image_info->magick,"GRAY") == 0)
!             status=WriteGRAYImage(image_info,image);
            else
!             status=WriteFAXImage(image_info,image);
        break;
      }
      case 'H':
      {
!       status=WriteHISTOGRAMImage(image_info,image);
        break;
      }
      case 'I':
      {
!       status=WriteIRISImage(image_info,image);
        break;
      }
      case 'J':
      {
!       status=WriteJPEGImage(image_info,image);
        break;
      }
      case 'M':
      {
        if (strcmp(image_info->magick,"MAP") == 0)
!         status=WriteMAPImage(image_info,image);
        else
          if (strcmp(image_info->magick,"MATTE") == 0)
!           status=WriteMATTEImage(image_info,image);
          else
            if (strcmp(image_info->magick,"MIFF") == 0)
!             status=WriteMIFFImage(image_info,image);
            else
!             status=WriteMTVImage(image_info,image);
        break;
      }
      case 'P':
      {
        if (strcmp(image_info->magick,"PCD") == 0)
!         status=WritePCDImage(image_info,image);
        else
          if (strcmp(image_info->magick,"PCX") == 0)
!           status=WritePCXImage(image_info,image);
          else
            if (strcmp(image_info->magick,"PICT") == 0)
!             status=WritePICTImage(image_info,image);
            else
              if (strcmp(image_info->magick,"PM") == 0)
!               status=WriteXPMImage(image_info,image);
              else
                if (strcmp(image_info->magick,"PS") == 0)
!                 status=WritePSImage(image_info,image);
                else
                  if (strcmp(image_info->magick,"PS2") == 0)
                    status=
!                     WritePS2Image(image_info,image);
                  else
!                   status=WritePNMImage(image_info,image);
        break;
      }
      case 'R':
      {
!       if (strcmp(image_info->magick,"RAD") == 0)
!         status=WriteRADIANCEImage(image_info,image);
        else
!         if (strcmp(image_info->magick,"RAS") == 0)
!           status=WriteSUNImage(image_info,image);
          else
!           if (strcmp(image_info->magick,"RGB") == 0)
!             status=WriteRGBImage(image_info,image);
!           else
!             status=WriteRLEImage(image_info,image);
        break;
      }
      case 'S':
      {
!       status=WriteSUNImage(image_info,image);
        break;
      }
      case 'T':
      {
        if (strcmp(image_info->magick,"TGA") == 0)
!         status=WriteTARGAImage(image_info,image);
        else
          if ((strcmp(image_info->magick,"TIF") == 0) ||
              (strcmp(image_info->magick,"TIFF") == 0))
!           status=WriteTIFFImage(image_info,image);
          else
!           status=WriteTEXTImage(image_info,image);
        break;
      }
      case 'V':
      {
        if (strcmp(image_info->magick,"VICAR") == 0)
!         status=WriteVICARImage(image_info,image);
        else
!         status=WriteVIFFImage(image_info,image);
        break;
      }
      case 'X':
      {
        if (strcmp(image_info->magick,"X") == 0)
!         status=WriteXImage(image_info,image);
        else
          if (strcmp(image_info->magick,"XBM") == 0)
!           status=WriteXBMImage(image_info,image);
          else
            if (strcmp(image_info->magick,"XC") == 0)
!             status=WriteXCImage(image_info,image);
            else
              if (strcmp(image_info->magick,"XPM") == 0)
!               status=WriteXPMImage(image_info,image);
              else
                if (strcmp(image_info->magick,"XV") == 0)
!                 status=WriteVIFFImage(image_info,image);
                else
!                 status=WriteXWDImage(image_info,image);
        break;
      }
      case 'Y':
      {
        if (strcmp(image_info->magick,"YUV") == 0)
!         status=WriteYUVImage(image_info,image);
        else
!         status=WriteYUV3Image(image_info,image);
        break;
      }
      default:
!       status=WriteMIFFImage(image_info,image);
    }
    if (image->status)
      {
--- 7057,7221 ----
    {
      case 'A':
      {
!       status=WriteAVSImage(image);
        break;
      }
      case 'B':
      {
!       status=WriteBMPImage(image);
        break;
      }
      case 'C':
      {
!       status=WriteCMYKImage(image,image_info->interlace,image_info->undercolor);
        break;
      }
      case 'E':
      {
!       status=WritePSImage(image,image_info->page,image_info->density);
        break;
      }
      case 'F':
      {
        if (strcmp(image_info->magick,"FAX") == 0)
!         status=WriteFAXImage(image);
        else
!         status=WriteFITSImage(image);
        break;
      }
      case 'G':
      {
        if (strcmp(image_info->magick,"GIF") == 0)
!         status=WriteGIFImage(image);
        else
          if (strcmp(image_info->magick,"GIF87") == 0)
!           status=WriteGIFImage(image);
          else
            if (strcmp(image_info->magick,"GRAY") == 0)
!             status=WriteGRAYImage(image);
            else
!             status=WriteFAXImage(image);
        break;
      }
      case 'H':
      {
!       status=WriteHISTOGRAMImage(image);
        break;
      }
      case 'I':
      {
!       status=WriteIRISImage(image);
        break;
      }
      case 'J':
      {
!       status=WriteJPEGImage(image,image_info->quality);
        break;
      }
      case 'M':
      {
        if (strcmp(image_info->magick,"MAP") == 0)
!         status=WriteMAPImage(image);
        else
          if (strcmp(image_info->magick,"MATTE") == 0)
!           status=WriteMATTEImage(image);
          else
            if (strcmp(image_info->magick,"MIFF") == 0)
!             status=WriteMIFFImage(image);
            else
!             status=WriteMTVImage(image);
        break;
      }
      case 'P':
      {
        if (strcmp(image_info->magick,"PCD") == 0)
!         status=WritePCDImage(image);
        else
          if (strcmp(image_info->magick,"PCX") == 0)
!           status=WritePCXImage(image);
          else
            if (strcmp(image_info->magick,"PICT") == 0)
!             status=WritePICTImage(image);
            else
              if (strcmp(image_info->magick,"PM") == 0)
!               status=WriteXPMImage(image,image_info->server_name);
              else
                if (strcmp(image_info->magick,"PS") == 0)
!                 status=WritePSImage(image,image_info->page,image_info->density);
                else
                  if (strcmp(image_info->magick,"PS2") == 0)
                    status=
!                     WritePS2Image(image,image_info->page,image_info->density);
                  else
!                   status=WritePNMImage(image);
        break;
      }
      case 'R':
      {
!       if (strcmp(image_info->magick,"RAS") == 0)
!         status=WriteSUNImage(image);
        else
!         if (strcmp(image_info->magick,"RGB") == 0)
!           status=WriteRGBImage(image,image_info->interlace);
          else
!           status=WriteRLEImage(image);
        break;
      }
      case 'S':
      {
!       status=WriteSUNImage(image);
        break;
      }
      case 'T':
      {
        if (strcmp(image_info->magick,"TGA") == 0)
!         status=WriteTARGAImage(image);
        else
          if ((strcmp(image_info->magick,"TIF") == 0) ||
              (strcmp(image_info->magick,"TIFF") == 0))
!           status=WriteTIFFImage(image,image_info->verbose);
          else
!           status=WriteTEXTImage(image);
        break;
      }
      case 'V':
      {
        if (strcmp(image_info->magick,"VICAR") == 0)
!         status=WriteVICARImage(image);
        else
!         status=WriteVIFFImage(image);
        break;
      }
      case 'X':
      {
        if (strcmp(image_info->magick,"X") == 0)
!         status=WriteXImage(image,image_info->server_name);
        else
          if (strcmp(image_info->magick,"XBM") == 0)
!           status=WriteXBMImage(image);
          else
            if (strcmp(image_info->magick,"XC") == 0)
!             status=WriteXCImage(image);
            else
              if (strcmp(image_info->magick,"XPM") == 0)
!               status=WriteXPMImage(image,image_info->server_name);
              else
                if (strcmp(image_info->magick,"XV") == 0)
!                 status=WriteVIFFImage(image);
                else
!                 status=WriteXWDImage(image);
        break;
      }
      case 'Y':
      {
        if (strcmp(image_info->magick,"YUV") == 0)
!         status=WriteYUVImage(image,image_info->interlace);
        else
!         status=WriteYUV3Image(image);
        break;
      }
      default:
!       status=WriteMIFFImage(image);
    }
    if (image->status)
      {
diff -c -r ImageMagick-3.1/magick/error.c ImageMagick/magick/error.c
*** ImageMagick-3.1/magick/error.c	Wed Jul 13 10:52:14 1994
--- ImageMagick/magick/error.c	Mon May 23 17:35:20 1994
***************
*** 100,107 ****
    *message,
    *qualifier;
  {
-   if (message == (char *) NULL)
-     exit(1);
    (void) fprintf(stderr,"%s: %s",client_name,message);
    if (qualifier != (char *) NULL)
      (void) fprintf(stderr," (%s)",qualifier);
--- 100,105 ----
***************
*** 120,126 ****
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Function DefaultWarningHandler displays a warning message.
  %
  %  The format of the DefaultWarningHandler routine is:
  %
--- 118,124 ----
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Function DefaultWarningHandler displays an warning message.
  %
  %  The format of the DefaultWarningHandler routine is:
  %
***************
*** 140,147 ****
    *message,
    *qualifier;
  {
-   if (message == (char *) NULL)
-     return;
    (void) fprintf(stderr,"%s: %s",client_name,message);
    if (qualifier != (char *) NULL)
      (void) fprintf(stderr," (%s)",qualifier);
--- 138,143 ----
diff -c -r ImageMagick-3.1/magick/image.c ImageMagick/magick/image.c
*** ImageMagick-3.1/magick/image.c	Wed Jul 13 10:52:12 1994
--- ImageMagick/magick/image.c	Fri Jun  3 15:36:14 1994
***************
*** 110,116 ****
    */
    allocated_image->file=(FILE *) NULL;
    allocated_image->status=False;
-   allocated_image->temporary=False;
    *allocated_image->filename='\0';
    allocated_image->pipe=False;
    (void) strcpy(allocated_image->magick,"MIFF");
--- 110,115 ----
***************
*** 477,482 ****
--- 476,714 ----
  %                                                                             %
  %                                                                             %
  %                                                                             %
+ %   C l i p I m a g e                                                         %
+ %                                                                             %
+ %                                                                             %
+ %                                                                             %
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %
+ %  Function ClipImage creates a new image that is a subregion of an existing
+ %  one.  It allocates the memory necessary for the new Image structure and
+ %  returns a pointer to the new image.
+ %
+ %  The format of the ClipImage routine is:
+ %
+ %      clipped_image=ClipImage(image,clip_info)
+ %
+ %  A description of each parameter follows:
+ %
+ %    o clipped_image: Function ClipImage returns a pointer to the clipped
+ %      image.  A null image is returned if there is a a memory shortage or
+ %      if the image width or height is zero.
+ %
+ %    o image: The address of a structure of type Image.
+ %
+ %    o clip_info: Specifies a pointer to a RectangleInfo which defines the
+ %      region of the image to crop.
+ %
+ %
+ */
+ Image *ClipImage(image,clip_info)
+ Image
+   *image;
+ 
+ RectangleInfo
+   *clip_info;
+ {
+   Image
+     *clipped_image;
+ 
+   register int
+     x,
+     y;
+ 
+   register RunlengthPacket
+     *p,
+     *q;
+ 
+   RunlengthPacket
+     background;
+ 
+   /*
+     Check clip geometry.
+   */
+   if (((clip_info->x+(int) clip_info->width) < 0) ||
+       ((clip_info->y+(int) clip_info->height) < 0) ||
+       (clip_info->x > (int) image->columns) ||
+       (clip_info->y > (int) image->rows))
+     {
+       Warning("Unable to clip image","geometry does not contain image");
+       return((Image *) NULL);
+     }
+   if ((clip_info->x+(int) clip_info->width) > (int) image->columns)
+     clip_info->width=(unsigned int) ((int) image->columns-clip_info->x);
+   if ((clip_info->y+(int) clip_info->height) > (int) image->rows)
+     clip_info->height=(unsigned int) ((int) image->rows-clip_info->y);
+   if (clip_info->x < 0)
+     {
+       clip_info->width-=(unsigned int) (-clip_info->x);
+       clip_info->x=0;
+     }
+   if (clip_info->y < 0)
+     {
+       clip_info->height-=(unsigned int) (-clip_info->y);
+       clip_info->y=0;
+     }
+   if ((clip_info->width == 0) && (clip_info->height == 0))
+     {
+       /*
+         Remove vertical edges that are the background color.
+       */
+       if (!UncompressImage(image))
+         return((Image *) NULL);
+       background=image->pixels[0];
+       clip_info->width=image->columns;
+       for (x=0; x < image->columns; x++)
+       {
+         p=image->pixels+x;
+         for (y=0; y < image->rows; y++)
+         {
+           if ((p->red != background.red) || (p->green != background.green) ||
+               (p->blue != background.blue))
+             break;
+           p+=image->columns;
+         }
+         if (y < image->rows)
+           break;
+       }
+       clip_info->x=x;
+       if (clip_info->x == (int) image->columns)
+         {
+           Warning("Unable to clip image","geometry does not contain image");
+           return((Image *) NULL);
+         }
+       for (x=image->columns-1; x > 0; x--)
+       {
+         p=image->pixels+x;
+         for (y=0; y < image->rows; y++)
+         {
+           if ((p->red != background.red) || (p->green != background.green) ||
+               (p->blue != background.blue))
+             break;
+           p+=image->columns;
+         }
+         if (y < image->rows)
+           break;
+       }
+       clip_info->width=x-clip_info->x+1;
+       /*
+         Remove horizontal edges that are the background color.
+       */
+       clip_info->height=image->rows;
+       p=image->pixels;
+       for (y=0; y < image->rows; y++)
+       {
+         for (x=0; x < image->columns; x++)
+         {
+           if ((p->red != background.red) || (p->green != background.green) ||
+               (p->blue != background.blue))
+             break;
+           p++;
+         }
+         if (x < image->columns)
+           break;
+       }
+       clip_info->y=y;
+       p=image->pixels+(image->columns*image->rows)-1;
+       for (y=image->rows-1; y > 0; y--)
+       {
+         for (x=0; x < image->columns; x++)
+         {
+           if ((p->red != background.red) || (p->green != background.green) ||
+               (p->blue != background.blue))
+             break;
+           p--;
+         }
+         if (x < image->columns)
+           break;
+       }
+       clip_info->height=y-clip_info->y+1;
+     }
+   if ((clip_info->width == 0) || (clip_info->height == 0))
+     {
+       Warning("Unable to clip image","geometry dimensions are zero");
+       return((Image *) NULL);
+     }
+   /*
+     Initialize clipped image attributes.
+   */
+   clipped_image=CopyImage(image,clip_info->width,clip_info->height,False);
+   if (clipped_image == (Image *) NULL)
+     {
+       Warning("Unable to clip image","Memory allocation failed");
+       return((Image *) NULL);
+     }
+   /*
+     Skip pixels up to the clipped image.
+   */
+   p=image->pixels;
+   image->runlength=p->length+1;
+   for (x=0; x < (clip_info->y*image->columns+clip_info->x); x++)
+     if (image->runlength != 0)
+       image->runlength--;
+     else
+       {
+         p++;
+         image->runlength=p->length;
+       }
+   /*
+     Extract clipped image.
+   */
+   q=clipped_image->pixels;
+   for (y=0; y < (clipped_image->rows-1); y++)
+   {
+     /*
+       Transfer scanline.
+     */
+     for (x=0; x < clipped_image->columns; x++)
+     {
+       if (image->runlength != 0)
+         image->runlength--;
+       else
+         {
+           p++;
+           image->runlength=p->length;
+         }
+       *q=(*p);
+       q->length=0;
+       q++;
+     }
+     /*
+       Skip to next scanline.
+     */
+     for (x=0; x < (image->columns-clipped_image->columns); x++)
+       if (image->runlength != 0)
+         image->runlength--;
+       else
+         {
+           p++;
+           image->runlength=p->length;
+         }
+   }
+   /*
+     Transfer last scanline.
+   */
+   for (x=0; x < clipped_image->columns; x++)
+   {
+     if (image->runlength != 0)
+       image->runlength--;
+     else
+       {
+         p++;
+         image->runlength=p->length;
+       }
+     *q=(*p);
+     q->length=0;
+     q++;
+   }
+   return(clipped_image);
+ }
+ 
+ /*
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ %                                                                             %
+ %                                                                             %
+ %                                                                             %
  %   C l o s e I m a g e                                                       %
  %                                                                             %
  %                                                                             %
***************
*** 507,522 ****
      return;
    image->status=ferror(image->file);
    if (image->pipe)
!     {
!       image->filesize=0;
!       (void) pclose(image->file);
!     }
    else
!     {
!       image->filesize=ftell(image->file);
!       if ((image->file != stdin) && (image->file != stdout))
!         (void) fclose(image->file);
!     }
    image->file=(FILE *) NULL;
  }
  
--- 739,748 ----
      return;
    image->status=ferror(image->file);
    if (image->pipe)
!     (void) pclose(image->file);
    else
!     if ((image->file != stdin) && (image->file != stdout))
!       (void) fclose(image->file);
    image->file=(FILE *) NULL;
  }
  
***************
*** 1237,1352 ****
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %                                                                             %
  %                                                                             %
- %     C o n t r a s t I m a g e                                               %
- %                                                                             %
- %                                                                             %
- %                                                                             %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- %  Function ContrastImage enhances the intensity differences between the
- %  lighter and darker elements of the image.
- %
- %  The format of the ContrastImage routine is:
- %
- %      ContrastImage(image,sharpen)
- %
- %  A description of each parameter follows:
- %
- %    o image: The address of a structure of type Image;  returned from
- %      ReadImage.
- %
- %    o sharpen: If True, the intensity is increased otherwise it is
- %      decreased.
- %
- %
- */
- void ContrastImage(image,sharpen)
- Image
-   *image;
- 
- unsigned int
-   sharpen;
- {
-   double
-     theta;
- 
-   int
-     contrast,
-     sign;
- 
-   register int
-     i;
- 
-   register RunlengthPacket
-     *p;
- 
-   unsigned char
-     *contrast_map;
- 
-   /*
-     Allocate and initialize contrast maps.
-   */
-   contrast_map=(unsigned char *) malloc((MaxRGB+1)*sizeof(unsigned char));
-   if (contrast_map == (unsigned char *) NULL)
-     {
-       Warning("Unable to contrast image","Memory allocation failed");
-       return;
-     }
-   /*
-     Initialize contrast table.
-   */
-   sign=sharpen ? 1 : -1;
-   for (i=0; i <= MaxRGB; i++)
-   {
-     theta=(((double) i-(MaxRGB/2.0))*3.14159265358979323846)/MaxRGB;
-     contrast=i+
-       (int) (((((sin(theta)+1.0))*MaxRGB/2.0)-i)*sign)/2;
-     if (contrast > MaxRGB)
-       contrast=MaxRGB;
-     else
-       if (contrast < 0)
-         contrast=0;
-     contrast_map[i]=contrast;
-   }
-   switch (image->class)
-   {
-     case DirectClass:
-     {
-       /*
-         Contrast enhance DirectClass image.
-       */
-       p=image->pixels;
-       for (i=0; i < image->packets; i++)
-       {
-         p->red=contrast_map[p->red];
-         p->green=contrast_map[p->green];
-         p->blue=contrast_map[p->blue];
-         p++;
-       }
-       break;
-     }
-     case PseudoClass:
-     {
-       /*
-         Contrast enhance PseudoClass image.
-       */
-       for (i=0; i < image->colors; i++)
-       {
-         image->colormap[i].red=contrast_map[image->colormap[i].red];
-         image->colormap[i].green=contrast_map[image->colormap[i].green];
-         image->colormap[i].blue=contrast_map[image->colormap[i].blue];
-       }
-       SyncImage(image);
-       break;
-     }
-   }
-   (void) free((char *) contrast_map);
- }
- 
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %                                                                             %
- %                                                                             %
  %                                                                             %
  %   C o p y I m a g e                                                         %
  %                                                                             %
--- 1463,1468 ----
***************
*** 1491,1497 ****
        if (copy_image->next != (Image *) NULL)
          copy_image->next->previous=copy_image;
      }
-   copy_image->orphan=False;
    return(copy_image);
  }
  
--- 1607,1612 ----
***************
*** 1500,1738 ****
  %                                                                             %
  %                                                                             %
  %                                                                             %
- %   C r o p I m a g e                                                         %
- %                                                                             %
- %                                                                             %
- %                                                                             %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- %  Function CropImage creates a new image that is a subregion of an existing
- %  one.  It allocates the memory necessary for the new Image structure and
- %  returns a pointer to the new image.
- %
- %  The format of the CropImage routine is:
- %
- %      cropped_image=CropImage(image,crop_info)
- %
- %  A description of each parameter follows:
- %
- %    o cropped_image: Function CropImage returns a pointer to the cropped
- %      image.  A null image is returned if there is a a memory shortage or
- %      if the image width or height is zero.
- %
- %    o image: The address of a structure of type Image.
- %
- %    o crop_info: Specifies a pointer to a RectangleInfo which defines the
- %      region of the image to crop.
- %
- %
- */
- Image *CropImage(image,crop_info)
- Image
-   *image;
- 
- RectangleInfo
-   *crop_info;
- {
-   Image
-     *cropped_image;
- 
-   register int
-     x,
-     y;
- 
-   register RunlengthPacket
-     *p,
-     *q;
- 
-   RunlengthPacket
-     background;
- 
-   /*
-     Check crop geometry.
-   */
-   if (((crop_info->x+(int) crop_info->width) < 0) ||
-       ((crop_info->y+(int) crop_info->height) < 0) ||
-       (crop_info->x > (int) image->columns) ||
-       (crop_info->y > (int) image->rows))
-     {
-       Warning("Unable to crop image","geometry does not contain image");
-       return((Image *) NULL);
-     }
-   if ((crop_info->x+(int) crop_info->width) > (int) image->columns)
-     crop_info->width=(unsigned int) ((int) image->columns-crop_info->x);
-   if ((crop_info->y+(int) crop_info->height) > (int) image->rows)
-     crop_info->height=(unsigned int) ((int) image->rows-crop_info->y);
-   if (crop_info->x < 0)
-     {
-       crop_info->width-=(unsigned int) (-crop_info->x);
-       crop_info->x=0;
-     }
-   if (crop_info->y < 0)
-     {
-       crop_info->height-=(unsigned int) (-crop_info->y);
-       crop_info->y=0;
-     }
-   if ((crop_info->width == 0) && (crop_info->height == 0))
-     {
-       /*
-         Remove vertical edges that are the background color.
-       */
-       if (!UncompressImage(image))
-         return((Image *) NULL);
-       background=image->pixels[0];
-       crop_info->width=image->columns;
-       for (x=0; x < image->columns; x++)
-       {
-         p=image->pixels+x;
-         for (y=0; y < image->rows; y++)
-         {
-           if ((p->red != background.red) || (p->green != background.green) ||
-               (p->blue != background.blue))
-             break;
-           p+=image->columns;
-         }
-         if (y < image->rows)
-           break;
-       }
-       crop_info->x=x;
-       if (crop_info->x == (int) image->columns)
-         {
-           Warning("Unable to crop image","geometry does not contain image");
-           return((Image *) NULL);
-         }
-       for (x=image->columns-1; x > 0; x--)
-       {
-         p=image->pixels+x;
-         for (y=0; y < image->rows; y++)
-         {
-           if ((p->red != background.red) || (p->green != background.green) ||
-               (p->blue != background.blue))
-             break;
-           p+=image->columns;
-         }
-         if (y < image->rows)
-           break;
-       }
-       crop_info->width=x-crop_info->x+1;
-       /*
-         Remove horizontal edges that are the background color.
-       */
-       crop_info->height=image->rows;
-       p=image->pixels;
-       for (y=0; y < image->rows; y++)
-       {
-         for (x=0; x < image->columns; x++)
-         {
-           if ((p->red != background.red) || (p->green != background.green) ||
-               (p->blue != background.blue))
-             break;
-           p++;
-         }
-         if (x < image->columns)
-           break;
-       }
-       crop_info->y=y;
-       p=image->pixels+(image->columns*image->rows)-1;
-       for (y=image->rows-1; y > 0; y--)
-       {
-         for (x=0; x < image->columns; x++)
-         {
-           if ((p->red != background.red) || (p->green != background.green) ||
-               (p->blue != background.blue))
-             break;
-           p--;
-         }
-         if (x < image->columns)
-           break;
-       }
-       crop_info->height=y-crop_info->y+1;
-     }
-   if ((crop_info->width == 0) || (crop_info->height == 0))
-     {
-       Warning("Unable to crop image","geometry dimensions are zero");
-       return((Image *) NULL);
-     }
-   /*
-     Initialize cropped image attributes.
-   */
-   cropped_image=CopyImage(image,crop_info->width,crop_info->height,False);
-   if (cropped_image == (Image *) NULL)
-     {
-       Warning("Unable to crop image","Memory allocation failed");
-       return((Image *) NULL);
-     }
-   /*
-     Skip pixels up to the cropped image.
-   */
-   p=image->pixels;
-   image->runlength=p->length+1;
-   for (x=0; x < (crop_info->y*image->columns+crop_info->x); x++)
-     if (image->runlength != 0)
-       image->runlength--;
-     else
-       {
-         p++;
-         image->runlength=p->length;
-       }
-   /*
-     Extract cropped image.
-   */
-   q=cropped_image->pixels;
-   for (y=0; y < (cropped_image->rows-1); y++)
-   {
-     /*
-       Transfer scanline.
-     */
-     for (x=0; x < cropped_image->columns; x++)
-     {
-       if (image->runlength != 0)
-         image->runlength--;
-       else
-         {
-           p++;
-           image->runlength=p->length;
-         }
-       *q=(*p);
-       q->length=0;
-       q++;
-     }
-     /*
-       Skip to next scanline.
-     */
-     for (x=0; x < (image->columns-cropped_image->columns); x++)
-       if (image->runlength != 0)
-         image->runlength--;
-       else
-         {
-           p++;
-           image->runlength=p->length;
-         }
-   }
-   /*
-     Transfer last scanline.
-   */
-   for (x=0; x < cropped_image->columns; x++)
-   {
-     if (image->runlength != 0)
-       image->runlength--;
-     else
-       {
-         p++;
-         image->runlength=p->length;
-       }
-     *q=(*p);
-     q->length=0;
-     q++;
-   }
-   return(cropped_image);
- }
- 
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %                                                                             %
- %                                                                             %
- %                                                                             %
  %   C u t I m a g e                                                           %
  %                                                                             %
  %                                                                             %
--- 1615,1620 ----
***************
*** 2280,2515 ****
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %                                                                             %
  %                                                                             %
- %     E m b o s s I m a g e                                                   %
- %                                                                             %
- %                                                                             %
- %                                                                             %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- %  Function EmbossImage creates a new image that is a copy of an existing
- %  one with the edge highlighted.  It allocates the memory necessary for the
- %  new Image structure and returns a pointer to the new image.
- %
- %  EmbossImage convolves the pixel neighborhood with this edge detection mask:
- %
- %    -1 -2  0
- %    -2  0  2
- %     0  2  1
- %
- %  The scan only processes pixels that have a full set of neighbors.  Pixels
- %  in the top, bottom, left, and right pairs of rows and columns are omitted
- %  from the scan.
- %
- %  The format of the EmbossImage routine is:
- %
- %      embossed_image=EmbossImage(image)
- %
- %  A description of each parameter follows:
- %
- %    o embossed_image: Function EmbossImage returns a pointer to the image
- %      after it is embossed.  A null image is returned if there is a memory
- %      shortage.
- %
- %    o image: The address of a structure of type Image;  returned from
- %      ReadImage.
- %
- %
- */
- Image *EmbossImage(image)
- Image
-   *image;
- {
- #define Emboss(weight) \
-   total_red+=(weight)*(int) (s->red); \
-   total_green+=(weight)*(int) (s->green); \
-   total_blue+=(weight)*(int) (s->blue); \
-   s++;
- 
-   Image
-     *embossed_image;
- 
-   long int
-     total_blue,
-     total_green,
-     total_red;
- 
-   register RunlengthPacket
-     *p,
-     *q,
-     *s,
-     *s0,
-     *s1,
-     *s2;
- 
-   register unsigned int
-     x;
- 
-   RunlengthPacket
-     background_pixel,
-     *scanline;
- 
-   unsigned int
-     y;
- 
-   if ((image->columns < 3) || (image->rows < 3))
-     {
-       Warning("Unable to detect edges","image size must exceed 3x3");
-       return((Image *) NULL);
-     }
-   /*
-     Initialize embossed image attributes.
-   */
-   embossed_image=CopyImage(image,image->columns,image->rows,False);
-   if (embossed_image == (Image *) NULL)
-     {
-       Warning("Unable to enhance image","Memory allocation failed");
-       return((Image *) NULL);
-     }
-   embossed_image->class=DirectClass;
-   /*
-     Allocate scan line buffer for 3 rows of the image.
-   */
-   scanline=(RunlengthPacket *) malloc(3*image->columns*sizeof(RunlengthPacket));
-   if (scanline == (RunlengthPacket *) NULL)
-     {
-       Warning("Unable to enhance image","Memory allocation failed");
-       DestroyImage(embossed_image);
-       return((Image *) NULL);
-     }
-   /*
-     Read the first two rows of the image.
-   */
-   p=image->pixels;
-   image->runlength=p->length+1;
-   s=scanline;
-   for (x=0; x < (image->columns << 1); x++)
-   {
-     if (image->runlength != 0)
-       image->runlength--;
-     else
-       {
-         p++;
-         image->runlength=p->length;
-       }
-     *s=(*p);
-     s++;
-   }
-   /*
-     Dump first scanlines of image.
-   */
-   background_pixel.red=0;
-   background_pixel.green=0;
-   background_pixel.blue=0;
-   background_pixel.index=0;
-   background_pixel.length=0;
-   q=embossed_image->pixels;
-   for (x=0; x < image->columns; x++)
-   {
-     *q=background_pixel;
-     q++;
-   }
-   /*
-     Convolve each row.
-   */
-   for (y=1; y < (image->rows-1); y++)
-   {
-     /*
-       Initialize sliding window pointers.
-     */
-     s0=scanline+image->columns*((y-1) % 3);
-     s1=scanline+image->columns*(y % 3);
-     s2=scanline+image->columns*((y+1) % 3);
-     /*
-       Read another scan line.
-     */
-     s=s2;
-     for (x=0; x < image->columns; x++)
-     {
-       if (image->runlength != 0)
-         image->runlength--;
-       else
-         {
-           p++;
-           image->runlength=p->length;
-         }
-       *s=(*p);
-       s++;
-     }
-     /*
-       Transfer first pixel of the scanline.
-     */
-     *q=background_pixel;
-     q++;
-     for (x=1; x < (image->columns-1); x++)
-     {
-       /*
-         Compute weighted average of target pixel color components.
-       */
-       total_red=0;
-       total_green=0;
-       total_blue=0;
-       s=s1+1;
-       s=s0;
-       Emboss(-1); Emboss(-2); Emboss( 0);
-       s=s1;
-       Emboss(-2); Emboss( 0); Emboss( 2);
-       s=s2;
-       Emboss( 0); Emboss( 2); Emboss( 1);
-       total_red+=(MaxRGB+1) >> 1;
-       if (total_red < 0)
-         total_red=0;
-       else
-         if (total_red > MaxRGB)
-           total_red=MaxRGB;
-       total_green+=(MaxRGB+1) >> 1;
-       if (total_green < 0)
-         total_green=0;
-       else
-         if (total_green > MaxRGB)
-           total_green=MaxRGB;
-       total_blue+=(MaxRGB+1) >> 1;
-       if (total_blue < 0)
-         total_blue=0;
-       else
-         if (total_blue > MaxRGB)
-           total_blue=MaxRGB;
-       q->red=(unsigned char) total_red;
-       q->green=(unsigned char) total_green;
-       q->blue=(unsigned char) total_blue;
-       q->index=0;
-       q->length=0;
-       q++;
-       s0++;
-       s1++;
-       s2++;
-     }
-     /*
-       Transfer last pixel of the scanline.
-     */
-     *q=background_pixel;
-     q++;
-   }
-   /*
-     Dump last scanline of pixels.
-   */
-   for (x=0; x < image->columns; x++)
-   {
-     *q=background_pixel;
-     q++;
-   }
-   (void) free((char *) scanline);
-   /*
-     Convert image to Grayscale and normalize.
-   */
-   (void) IsGrayImage(embossed_image);
-   NormalizeImage(embossed_image);
-   return(embossed_image);
- }
- 
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %                                                                             %
- %                                                                             %
  %     E d g e I m a g e                                                       %
  %                                                                             %
  %                                                                             %
--- 2162,2167 ----
***************
*** 2517,2523 ****
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
  %  Function EdgeImage creates a new image that is a copy of an existing
! %  one with the edges highlighted.  It allocates the memory necessary for the
  %  new Image structure and returns a pointer to the new image.
  %
  %  EdgeImage convolves the pixel neighborhood with this edge detection mask:
--- 2169,2175 ----
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
  %  Function EdgeImage creates a new image that is a copy of an existing
! %  one with the edge highlighted.  It allocates the memory necessary for the
  %  new Image structure and returns a pointer to the new image.
  %
  %  EdgeImage convolves the pixel neighborhood with this edge detection mask:
***************
*** 2722,2731 ****
      q++;
    }
    (void) free((char *) scanline);
-   /*
-     Normalize image.
-   */
-   NormalizeImage(edged_image);
    return(edged_image);
  }
  
--- 2374,2379 ----
***************
*** 2996,3002 ****
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Function EqualizeImage performs histogram equalization on the reference
  %  image.
  %
  %  The format of the EqualizeImage routine is:
--- 2644,2650 ----
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Procedure EqualizeImage performs histogram equalization on the reference
  %  image.
  %
  %  The format of the EqualizeImage routine is:
***************
*** 3627,3633 ****
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Function GammaImage converts the reference image to gamma corrected colors.
  %
  %  The format of the GammaImage routine is:
  %
--- 3275,3281 ----
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Procedure GammaImage converts the reference image to gamma corrected colors.
  %
  %  The format of the GammaImage routine is:
  %
***************
*** 3755,3773 ****
  %
  %  The format of the GetImageInfo routine is:
  %
! %      GetImageInfo(image_info)
  %
  %  A description of each parameter follows:
  %
  %    o image_info: Specifies a pointer to a ImageInfo structure.
  %
  %
  */
! void GetImageInfo(image_info)
  ImageInfo
    *image_info;
  {
    *image_info->filename='\0';
    image_info->assert=False;
    image_info->server_name=(char *) NULL;
    image_info->font=(char *) NULL;
--- 3403,3429 ----
  %
  %  The format of the GetImageInfo routine is:
  %
! %      GetImageInfo(filename,image_info)
  %
  %  A description of each parameter follows:
  %
+ %    o filename: A character string containing a name of the file to
+ %      associate with the ImageInfo structure.
+ %
  %    o image_info: Specifies a pointer to a ImageInfo structure.
  %
  %
  */
! void GetImageInfo(filename,image_info)
! char
!   *filename;
! 
  ImageInfo
    *image_info;
  {
    *image_info->filename='\0';
+   if (filename != (char *) NULL)
+     (void) strcpy(image_info->filename,filename);
    image_info->assert=False;
    image_info->server_name=(char *) NULL;
    image_info->font=(char *) NULL;
***************
*** 3774,3780 ****
    image_info->geometry=(char *) NULL;
    image_info->density=(char *) NULL;
    image_info->page=(char *) NULL;
-   image_info->dither=True;
    image_info->interlace=NoneInterlace;
    image_info->monochrome=False;
    image_info->quality=85;
--- 3430,3435 ----
***************
*** 3793,3800 ****
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
  %  Function IsGrayImage returns True if the image is grayscale otherwise
! %  False is returned.  If the image is DirectClass and grayscale, it is demoted
! %  to PseudoClass.
  %
  %  The format of the IsGrayImage routine is:
  %
--- 3448,3454 ----
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
  %  Function IsGrayImage returns True if the image is grayscale otherwise
! %  False is returned.
  %
  %  The format of the IsGrayImage routine is:
  %
***************
*** 3820,3855 ****
    unsigned int
      grayscale;
  
!   /*
!     Determine if image is grayscale.
!   */
!   grayscale=True;
!   switch (image->class)
!   {
!     case DirectClass:
!     {
!       register RunlengthPacket
!         *p;
! 
!       p=image->pixels;
!       for (i=0; i < image->packets; i++)
!       {
!         if ((p->red != p->green) || (p->green != p->blue))
!           {
!             grayscale=False;
!             break;
!           }
!         p++;
!       }
!       if (grayscale)
!         {
!           QuantizeImage(image,256,8,False,GRAYColorspace,True);
!           SyncImage(image);
!         }
!       break;
!     }
!     case PseudoClass:
      {
        for (i=0; i < image->colors; i++)
          if ((image->colormap[i].red != image->colormap[i].green) ||
              (image->colormap[i].green != image->colormap[i].blue))
--- 3474,3487 ----
    unsigned int
      grayscale;
  
!   if ((image->class == DirectClass) || (image->colors > 256))
!     return(False);
!   else
      {
+       /*
+         Determine if image is grayscale.
+       */
+       grayscale=True;
        for (i=0; i < image->colors; i++)
          if ((image->colormap[i].red != image->colormap[i].green) ||
              (image->colormap[i].green != image->colormap[i].blue))
***************
*** 3857,3866 ****
              grayscale=False;
              break;
            }
!       break;
      }
-   }
-   return(grayscale);
  }
  
  /*
--- 3489,3496 ----
              grayscale=False;
              break;
            }
!       return(grayscale);
      }
  }
  
  /*
***************
*** 4062,4068 ****
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Function NegateImage negates the colors in the reference image.
  %
  %  The format of the NegateImage routine is:
  %
--- 3692,3698 ----
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Procedure NegateImage negates the colors in the reference image.
  %
  %  The format of the NegateImage routine is:
  %
***************
*** 4368,4374 ****
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Function NormalizeImage normalizes the pixel values to span the full
  %  range of color values.  This is a contrast enhancement technique.
  %
  %  The format of the NormalizeImage routine is:
--- 3998,4004 ----
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Procedure NormalizeImage normalizes the pixel values to span the full
  %  range of color values.  This is a contrast enhancement technique.
  %
  %  The format of the NormalizeImage routine is:
***************
*** 4952,4958 ****
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Function RGBTransformImage converts the reference image from RGB to
  %  an alternate colorspace.  The transformation matrices are not the standard
  %  ones: the weights are rescaled to normalized the range of the transformed
  %  values to be [0..255].
--- 4582,4588 ----
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Procedure RGBTransformImage converts the reference image from RGB to
  %  an alternate colorspace.  The transformation matrices are not the standard
  %  ones: the weights are rescaled to normalized the range of the transformed
  %  values to be [0..255].
***************
*** 5538,5731 ****
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %                                                                             %
  %                                                                             %
- %     S a t u r a t e I m a g e                                               %
- %                                                                             %
- %                                                                             %
- %                                                                             %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- %  Function SaturateImage increases or decreases the color saturation.
- %
- %  The format of the SaturateImage routine is:
- %
- %      SaturateImage(image,saturate)
- %
- %  A description of each parameter follows:
- %
- %    o image: The address of a structure of type Image;  returned from
- %      ReadImage.
- %
- %    o saturate: An integer representing the percent change in color
- %      saturation [-100..100].
- %
- %
- */
- 
- static void Saturate(percent,red,green,blue)
- int
-   percent;
- 
- unsigned char
-   *red,
-   *green,
-   *blue;
- {
-   double
-     b,
-     hue,
-     g,
-     minimum,
-     r,
-     saturation,
-     value;
- 
-   /*
-     Convert RGB to HSV colorspace.
-   */
-   hue=(-1.0);
-   saturation=0.0;
-   r=(double) (*red)/(double) MaxRGB;
-   g=(double) (*green)/(double) MaxRGB;
-   b=(double) (*blue)/(double) MaxRGB;
-   if (r >= g)
-     {
-       if (r >= b)
-         value=r;
-       else
-         value=b;
-     }
-   else
-     if (g >= b)
-       value=g;
-     else
-       value=b;
-   if (r <= g)
-     {
-       if (r <= b)
-         minimum=r;
-       else
-         minimum=b;
-     }
-   else
-     if (g <= b)
-       minimum=g;
-     else
-       minimum=b;
-   if (value != 0.0)
-     saturation=(value-minimum)/value;
-   if (saturation != 0.0)
-     {
-       if (r == value)
-         hue=(g-b)/(value-minimum);
-       else
-         if (g == value)
-           hue=2.0+(b-r)/(value-minimum);
-         else
-           if (b == value)
-             hue=4.0+(r-g)/(value-minimum);
-       hue=hue*60.0;
-       if (hue < 0)
-         hue+=360.0;
-     }
-   /*
-     Increase or decrease color saturation.
-   */
-   saturation+=((double) percent)/100.0;
-   if (saturation < 0.0)
-     saturation=0.0;
-   else
-     if (saturation > 1.0)
-       saturation=1.0;
-   /*
-     Convert HSV to RGB
-   */
-   r=value;
-   g=value;
-   b=value;
-   if ((hue != -1.0) && (saturation != 0.0))
-     {
-       double
-         f,
-         j,
-         k,
-         l,
-         v;
- 
-       int
-         i;
- 
-       if (hue == 360.0)
-         hue=0.0;
-       hue=hue/60.0;
-       i=floor(hue);
-       if (i < 0)
-         i=0;
-       f=hue-i;
-       j=value*(1.0-saturation);
-       k=value*(1.0-(saturation*f));
-       l=value*(1.0-(saturation*(1.0-f)));
-       v=value;
-       switch (i)
-       {
-         case 0:  r=v;  g=l;  b=j;  break;
-         case 1:  r=k;  g=v;  b=j;  break;
-         case 2:  r=j;  g=v;  b=l;  break;
-         case 3:  r=j;  g=k;  b=v;  break;
-         case 4:  r=l;  g=j;  b=v;  break;
-         case 5:  r=v;  g=j;  b=k;  break;
-       }
-     }
-   *red=(unsigned char) floor((r*(double) MaxRGB)+0.5);
-   *green=(unsigned char) floor((g*(double) MaxRGB)+0.5);
-   *blue=(unsigned char) floor((b*(double) MaxRGB)+0.5);
- }
- 
- void SaturateImage(image,saturate)
- Image
-   *image;
- 
- int
-   saturate;
- {
-   register int
-     i;
- 
-   register RunlengthPacket
-     *p;
- 
-   switch (image->class)
-   {
-     case DirectClass:
-     {
-       /*
-         Increase or decrease the color saturation for DirectClass image.
-       */
-       p=image->pixels;
-       for (i=0; i < image->packets; i++)
-       {
-         Saturate(saturate,&p->red,&p->green,&p->blue);
-         p++;
-       }
-       break;
-     }
-     case PseudoClass:
-     {
-       /*
-         Increase or decrease the color saturation for PseudoClass image.
-       */
-       for (i=0; i < image->colors; i++)
-         Saturate(saturate,&image->colormap[i].red,&image->colormap[i].green,
-           &image->colormap[i].blue);
-       SyncImage(image);
-       break;
-     }
-   }
- }
- 
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %                                                                             %
- %                                                                             %
  %                                                                             %
  %   S c a l e I m a g e                                                       %
  %                                                                             %
--- 5168,5173 ----
***************
*** 5781,5788 ****
    } ScaledPacket;
  
    Image
!     *scaled_image,
!     *sharpened_image;
  
    int
      next_row,
--- 5223,5229 ----
    } ScaledPacket;
  
    Image
!     *scaled_image;
  
    int
      next_row,
***************
*** 6103,6117 ****
    if (scanline != x_vector)
      (void) free((char *) scanline);
    (void) free((char *) x_vector);
-   /*
-     Sharpen image.
-   */
-   sharpened_image=SharpenImage(scaled_image);
-   if (sharpened_image != (Image *) NULL)
-     {
-       DestroyImage(scaled_image);
-       scaled_image=sharpened_image;
-     }
    return(scaled_image);
  }
  
--- 5544,5549 ----
***************
*** 6179,6185 ****
        "PNM",
        "PS",
        "PS2",
-       "RAD",
        "RAS",
        "RGB",
        "RLE",
--- 5611,5616 ----
***************
*** 6763,6773 ****
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
  %  Function TransformImage creates a new image that is a transformed size of
! %  of existing one as specified by the crop and image geometries.  It
  %  allocates the memory necessary for the new Image structure and returns a
  %  pointer to the new image.
  %
! %  If a crop geometry is specified a subregion of the image is obtained.
  %  If the specified image size, as defined by the image and scale geometries,
  %  is smaller than the actual image size, the image is first reduced to an
  %  integral of the specified image size with an antialias digital filter.  The
--- 6194,6204 ----
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
  %  Function TransformImage creates a new image that is a transformed size of
! %  of existing one as specified by the clip and image geometries.  It
  %  allocates the memory necessary for the new Image structure and returns a
  %  pointer to the new image.
  %
! %  If a clip geometry is specified a subregion of the image is obtained.
  %  If the specified image size, as defined by the image and scale geometries,
  %  is smaller than the actual image size, the image is first reduced to an
  %  integral of the specified image size with an antialias digital filter.  The
***************
*** 6779,6785 ****
  %
  %  The format of the TransformImage routine is:
  %
! %      TransformImage(image,crop_geometry,image_geometry)
  %
  %  A description of each parameter follows:
  %
--- 6210,6216 ----
  %
  %  The format of the TransformImage routine is:
  %
! %      TransformImage(image,clip_geometry,image_geometry)
  %
  %  A description of each parameter follows:
  %
***************
*** 6786,6792 ****
  %    o image: The address of an address of a structure of type Image.  The
  %      transformed image is returned as this parameter.
  %
! %    o crop_geometry: Specifies a pointer to a crop geometry string.
  %      This geometry defines a subregion of the image.
  %
  %    o image_geometry: Specifies a pointer to a image geometry string.
--- 6217,6223 ----
  %    o image: The address of an address of a structure of type Image.  The
  %      transformed image is returned as this parameter.
  %
! %    o clip_geometry: Specifies a pointer to a clip geometry string.
  %      This geometry defines a subregion of the image.
  %
  %    o image_geometry: Specifies a pointer to a image geometry string.
***************
*** 6794,6805 ****
  %
  %
  */
! void TransformImage(image,crop_geometry,image_geometry)
  Image
    **image;
  
  char
!   *crop_geometry,
    *image_geometry;
  {
    Image
--- 6225,6236 ----
  %
  %
  */
! void TransformImage(image,clip_geometry,image_geometry)
  Image
    **image;
  
  char
!   *clip_geometry,
    *image_geometry;
  {
    Image
***************
*** 6813,6848 ****
      width;
  
    transformed_image=(*image);
!   if (crop_geometry != (char *) NULL)
      {
        Image
!         *cropped_image;
  
        RectangleInfo
!         crop_info;
  
        /*
!         Crop image to a user specified size.
        */
!       crop_info.x=0;
!       crop_info.y=0;
!       flags=XParseGeometry(crop_geometry,&crop_info.x,&crop_info.y,
!         &crop_info.width,&crop_info.height);
        if ((flags & WidthValue) == 0)
!         crop_info.width=(unsigned int)
!           ((int) transformed_image->columns-crop_info.x);
        if ((flags & HeightValue) == 0)
!         crop_info.height=(unsigned int)
!           ((int) transformed_image->rows-crop_info.y);
        if ((flags & XNegative) != 0)
!         crop_info.x+=transformed_image->columns-crop_info.width;
        if ((flags & YNegative) != 0)
!         crop_info.y+=transformed_image->rows-crop_info.height;
!       cropped_image=CropImage(transformed_image,&crop_info);
!       if (cropped_image != (Image *) NULL)
          {
            DestroyImage(transformed_image);
!           transformed_image=cropped_image;
          }
      }
    /*
--- 6244,6279 ----
      width;
  
    transformed_image=(*image);
!   if (clip_geometry != (char *) NULL)
      {
        Image
!         *clipped_image;
  
        RectangleInfo
!         clip_info;
  
        /*
!         Clip image to a user specified size.
        */
!       clip_info.x=0;
!       clip_info.y=0;
!       flags=XParseGeometry(clip_geometry,&clip_info.x,&clip_info.y,
!         &clip_info.width,&clip_info.height);
        if ((flags & WidthValue) == 0)
!         clip_info.width=(unsigned int)
!           ((int) transformed_image->columns-clip_info.x);
        if ((flags & HeightValue) == 0)
!         clip_info.height=(unsigned int)
!           ((int) transformed_image->rows-clip_info.y);
        if ((flags & XNegative) != 0)
!         clip_info.x+=transformed_image->columns-clip_info.width;
        if ((flags & YNegative) != 0)
!         clip_info.y+=transformed_image->rows-clip_info.height;
!       clipped_image=ClipImage(transformed_image,&clip_info);
!       if (clipped_image != (Image *) NULL)
          {
            DestroyImage(transformed_image);
!           transformed_image=clipped_image;
          }
      }
    /*
***************
*** 6910,6916 ****
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Function TransformRGBImage converts the reference image from an alternate
  %  colorspace.  The transformation matrices are not the standard ones:  the
  %  weights are rescaled to normalized the range of the transformed values to
  %  be [0..255].
--- 6341,6347 ----
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Procedure TransformRGBImage converts the reference image from an alternate
  %  colorspace.  The transformation matrices are not the standard ones:  the
  %  weights are rescaled to normalized the range of the transformed values to
  %  be [0..255].
diff -c -r ImageMagick-3.1/magick/image.h ImageMagick/magick/image.h
*** ImageMagick-3.1/magick/image.h	Wed Jul 13 10:52:14 1994
--- ImageMagick/magick/image.h	Mon May 23 16:44:32 1994
***************
*** 3,15 ****
  */
  #define AbsoluteValue(x)  ((x) < 0 ? -(x) : (x))
  #define DegreesToRadians(x) ((x)*3.14159265358979323846/180.0)
- #define FuzzyColorMatch(pixel,target,delta) \
-   (((int) pixel->red >= ((int) target.red-delta)) && \
-    ((int) pixel->red <= ((int) target.red+delta)) && \
-    ((int) pixel->green >= ((int) target.green-delta)) && \
-    ((int) pixel->green <= ((int) target.green+delta)) && \
-    ((int) pixel->blue >= ((int) target.blue-delta)) && \
-    ((int) pixel->blue <= ((int) target.blue+delta)))
  #define Intensity(color)  (unsigned int)  \
    ((unsigned int) ((color).red*77+(color).green*150+(color).blue*29) >> 8)
  #define MaxColormapSize  65535
--- 3,8 ----
***************
*** 18,24 ****
  #define MaxRunlength  255
  #define MaxTextLength  2048
  #define RadiansToDegrees(x) ((x)*180/3.14159265358979323846)
- #define TransparentIndex  255
  
  /*
    Image Id's
--- 11,16 ----
***************
*** 110,116 ****
      *page;
  
    unsigned int
-     dither,
      interlace,
      monochrome,
      quality,
--- 102,107 ----
***************
*** 149,163 ****
      *file;
  
    int
!     status,
!     temporary;
  
    char
      filename[MaxTextLength];
  
-   long int
-     filesize;
- 
    int
      pipe;
  
--- 140,150 ----
      *file;
  
    int
!     status;
  
    char
      filename[MaxTextLength];
  
    int
      pipe;
  
***************
*** 222,232 ****
    *AllocateImage _Declare((ImageInfo *)),
    *BorderImage _Declare((Image *,RectangleInfo *,ColorPacket *)),
    *BlurImage _Declare((Image *)),
    *CopyImage _Declare((Image *,unsigned int,unsigned int,unsigned int)),
-   *CropImage _Declare((Image *,RectangleInfo *)),
    *CutImage _Declare((Image *,RectangleInfo *)),
    *DespeckleImage _Declare((Image *)),
-   *EmbossImage _Declare((Image *)),
    *EdgeImage _Declare((Image *)),
    *EnhanceImage _Declare((Image *)),
    *FlipImage _Declare((Image *)),
--- 209,218 ----
    *AllocateImage _Declare((ImageInfo *)),
    *BorderImage _Declare((Image *,RectangleInfo *,ColorPacket *)),
    *BlurImage _Declare((Image *)),
+   *ClipImage _Declare((Image *,RectangleInfo *)),
    *CopyImage _Declare((Image *,unsigned int,unsigned int,unsigned int)),
    *CutImage _Declare((Image *,RectangleInfo *)),
    *DespeckleImage _Declare((Image *)),
    *EdgeImage _Declare((Image *)),
    *EnhanceImage _Declare((Image *)),
    *FlipImage _Declare((Image *)),
***************
*** 248,254 ****
  
  extern unsigned int
    IsGrayImage _Declare((Image *)),
-   IsPseudoClass _Declare((Image *)),
    NumberColors _Declare((Image *,FILE *)),
    ReadData _Declare((char *,int,int,FILE *)),
    UncompressImage _Declare((Image *)),
--- 234,239 ----
***************
*** 260,271 ****
    CompositeImage _Declare((Image *,unsigned int,Image *,int,int)),
    CompressColormap _Declare((Image *)),
    CompressImage _Declare((Image *)),
-   ContrastImage _Declare((Image *,unsigned int)),
    DestroyImage _Declare((Image *)),
    DestroyImages _Declare((Image *)),
    EqualizeImage _Declare((Image *)),
    GammaImage _Declare((Image *,char *)),
!   GetImageInfo _Declare((ImageInfo *)),
    NegateImage _Declare((Image *)),
    NormalizeImage _Declare((Image *)),
    OpenImage _Declare((Image *,char *)),
--- 245,255 ----
    CompositeImage _Declare((Image *,unsigned int,Image *,int,int)),
    CompressColormap _Declare((Image *)),
    CompressImage _Declare((Image *)),
    DestroyImage _Declare((Image *)),
    DestroyImages _Declare((Image *)),
    EqualizeImage _Declare((Image *)),
    GammaImage _Declare((Image *,char *)),
!   GetImageInfo _Declare((char *,ImageInfo *)),
    NegateImage _Declare((Image *)),
    NormalizeImage _Declare((Image *)),
    OpenImage _Declare((Image *,char *)),
***************
*** 276,282 ****
    QuantizeImages _Declare((Image **,unsigned int,Image *,unsigned int,
      unsigned int,unsigned int,unsigned int,unsigned int)),
    RGBTransformImage _Declare((Image *,unsigned int)),
-   SaturateImage _Declare((Image *,int)),
    SetErrorHandler _Declare((ErrorHandler)),
    SetImageMagick _Declare((ImageInfo *)),
    SetWarningHandler _Declare((ErrorHandler)),
--- 260,265 ----
diff -c -r ImageMagick-3.1/magick/magick.h ImageMagick/magick/magick.h
*** ImageMagick-3.1/magick/magick.h	Wed Jul 13 10:52:15 1994
--- ImageMagick/magick/magick.h	Fri Jun  3 18:23:47 1994
***************
*** 22,28 ****
  #include <sys/types.h>
  #include <sys/stat.h>
  #undef index
- #undef assert
  
  /*
    Define declarations for the Display program.
--- 22,27 ----
***************
*** 56,59 ****
    Variable declarations.
  */
  static char 
!   Version[]="@(#)ImageMagick 3.1 94/07/01 cristy@dupont.com";
--- 55,58 ----
    Variable declarations.
  */
  static char 
!   Version[]="@(#)ImageMagick 3.0 94/06/01 cristy@dupont.com";
diff -c -r ImageMagick-3.1/magick/quantize.c ImageMagick/magick/quantize.c
*** ImageMagick-3.1/magick/quantize.c	Wed Jul 13 10:52:12 1994
--- ImageMagick/magick/quantize.c	Fri Jun  3 15:35:35 1994
***************
*** 275,281 ****
      unsigned int,unsigned int));
  
  static unsigned int
!   DitherImage _Declare((Image *,unsigned int));
  
  static void
    ClosestColor _Declare((Node *)),
--- 275,281 ----
      unsigned int,unsigned int));
  
  static unsigned int
!   DitherImage _Declare((Image *));
  
  static void
    ClosestColor _Declare((Node *)),
***************
*** 312,318 ****
  %
  %  The format of the Assignment routine is:
  %
! %      Assignment(image,number_colors,dither,colorspace,optimal)
  %
  %  A description of each parameter follows.
  %
--- 312,318 ----
  %
  %  The format of the Assignment routine is:
  %
! %      Assignment(image,dither,colorspace,optimal)
  %
  %  A description of each parameter follows.
  %
***************
*** 319,328 ****
  %    o image: Specifies a pointer to an Image structure;  returned from
  %      ReadImage.
  %
- %    o number_colors: This integer value indicates the maximum number of
- %      colors in the quantized image or colormap.  Here we use this value
- %      to determine the depth of the color description tree.
- %
  %    o dither: Set this integer value to something other than zero to
  %      dither the quantized image.  The basic strategy of dithering is to
  %      trade intensity resolution for spatial resolution by averaging the
--- 319,324 ----
***************
*** 340,351 ****
  %
  %
  */
! static void Assignment(image,number_colors,dither,colorspace,optimal)
  Image
    *image;
  
  unsigned int
-   number_colors,
    dither,
    colorspace,
    optimal;
--- 336,346 ----
  %
  %
  */
! static void Assignment(image,dither,colorspace,optimal)
  Image
    *image;
  
  unsigned int
    dither,
    colorspace,
    optimal;
***************
*** 380,386 ****
    cube.colormap=image->colormap;
    cube.colors=0;
    Colormap(cube.root);
!   if ((number_colors == 2)  && (colorspace == GRAYColorspace))
      {
        unsigned int
          polarity;
--- 375,381 ----
    cube.colormap=image->colormap;
    cube.colors=0;
    Colormap(cube.root);
!   if ((cube.colors == 2)  && (colorspace == GRAYColorspace))
      {
        unsigned int
          polarity;
***************
*** 395,400 ****
--- 390,396 ----
        image->colormap[!polarity].red=MaxRGB;
        image->colormap[!polarity].green=MaxRGB;
        image->colormap[!polarity].blue=MaxRGB;
+       dither|=((image->class == DirectClass) || (image->colors > 2));
      }
    image->matte=False;
    image->class=PseudoClass;
***************
*** 404,410 ****
      accuracy for speed improvements.
    */
    if (dither || !optimal)
!     dither=!DitherImage(image,optimal);
    p=image->pixels;
    if (!dither)
      if (!optimal)
--- 400,406 ----
      accuracy for speed improvements.
    */
    if (dither || !optimal)
!     dither=!DitherImage(image);
    p=image->pixels;
    if (!dither)
      if (!optimal)
***************
*** 742,748 ****
  %
  %  The format of the DitherImage routine is:
  %
! %      DitherImage(image,optimal)
  %
  %  A description of each parameter follows.
  %
--- 738,744 ----
  %
  %  The format of the DitherImage routine is:
  %
! %      DitherImage(image)
  %
  %  A description of each parameter follows.
  %
***************
*** 749,765 ****
  %    o image: Specifies a pointer to an Image structure;  returned from
  %      ReadImage.
  %
- %    o optimal: An unsigned integer value greater than zero indicates that
- %      the optimal representation of the reference image should be returned.
- %
  %
  */
! static unsigned int DitherImage(image,optimal)
  Image
    *image;
- 
- unsigned int
-   optimal;
  {
  #define MaxError  32
  
--- 745,755 ----
  %    o image: Specifies a pointer to an Image structure;  returned from
  %      ReadImage.
  %
  %
  */
! static unsigned int DitherImage(image)
  Image
    *image;
  {
  #define MaxError  32
  
***************
*** 775,791 ****
      *error;
  
    int
!     *cache,
!     step;
! 
!   Node
!     *node;
  
    register int
-     i,
      blue_error,
      green_error,
!     red_error;
  
    register RunlengthPacket
      *q;
--- 765,780 ----
      *error;
  
    int
!     *cache;
  
    register int
      blue_error,
      green_error,
!     red_error,
!     step;
! 
!   register Node
!     *node;
  
    register RunlengthPacket
      *q;
***************
*** 797,802 ****
--- 786,794 ----
    register unsigned char
      *range_limit;
  
+   register unsigned int
+     id;
+ 
    unsigned char
      blue,
      green,
***************
*** 804,810 ****
      red;
  
    unsigned int
!     id,
      x,
      y;
  
--- 796,802 ----
      red;
  
    unsigned int
!     i,
      x,
      y;
  
***************
*** 829,841 ****
        return(True);
      }
    /*
!     Initialize color cache.
    */
    for (i=0; i < (1 << 18); i++)
      cache[i]=(-1);
-   /*
-     Initialize error tables.
-   */
    for (i=0; i < ((image->columns+2) << 1); i++)
    {
      error[i].red=0;
--- 821,830 ----
        return(True);
      }
    /*
!     Initialize tables.
    */
    for (i=0; i < (1 << 18); i++)
      cache[i]=(-1);
    for (i=0; i < ((image->columns+2) << 1); i++)
    {
      error[i].red=0;
***************
*** 842,850 ****
      error[i].green=0;
      error[i].blue=0;
    }
-   /*
-     Initialize range tables.
-   */
    for (i=0; i <= MaxRGB; i++)
    {
      range_table[i]=0;
--- 831,836 ----
***************
*** 859,880 ****
    {
      q=image->pixels+image->columns*y;
      cs=error+1;
!     ns=cs+(image->columns+2);
!     step=y & 0x01 ? 1 : -1;
!     if (step < 0)
        {
          /*
            Distribute error right-to-left for odd scanlines.
          */
          q+=(image->columns-1);
          ns=error+(image->columns-1)+1;
!         cs=ns+(image->columns+2);
        }
      for (x=0; x < image->columns; x++)
      {
        red_error=(cs->red+8)/16;
        green_error=(cs->green+8)/16;
        blue_error=(cs->blue+8)/16;
        red=range_limit[(int) q->red+red_error];
        green=range_limit[(int) q->green+green_error];
        blue=range_limit[(int) q->blue+blue_error];
--- 845,885 ----
    {
      q=image->pixels+image->columns*y;
      cs=error+1;
!     ns=error+(image->columns+2)+1;
!     step=1;
!     if (y & 0x01)
        {
          /*
            Distribute error right-to-left for odd scanlines.
          */
          q+=(image->columns-1);
+         cs=error+(image->columns+2)+(image->columns-1)+1;
          ns=error+(image->columns-1)+1;
!         step=(-1);
        }
      for (x=0; x < image->columns; x++)
      {
        red_error=(cs->red+8)/16;
+       if (image->colors > 2)
+         if (red_error > MaxError)
+           red_error=MaxError;
+         else
+           if (red_error < -MaxError)
+             red_error=(-MaxError);
        green_error=(cs->green+8)/16;
+       if (image->colors > 2)
+         if (green_error > MaxError)
+           green_error=MaxError;
+         else
+           if (green_error < -MaxError)
+             green_error=(-MaxError);
        blue_error=(cs->blue+8)/16;
+       if (image->colors > 2)
+         if (blue_error > MaxError)
+           blue_error=MaxError;
+         else
+           if (blue_error < -MaxError)
+             blue_error=(-MaxError);
        red=range_limit[(int) q->red+red_error];
        green=range_limit[(int) q->green+green_error];
        blue=range_limit[(int) q->blue+blue_error];
***************
*** 1548,1554 ****
      RGBTransformImage(image,colorspace);
    Classification(image);
    Reduction(number_colors);
!   Assignment(image,number_colors,dither,colorspace,optimal);
    if (colorspace != RGBColorspace)
      TransformRGBImage(image,colorspace);
    /*
--- 1553,1559 ----
      RGBTransformImage(image,colorspace);
    Classification(image);
    Reduction(number_colors);
!   Assignment(image,dither,colorspace,optimal);
    if (colorspace != RGBColorspace)
      TransformRGBImage(image,colorspace);
    /*
***************
*** 1685,1691 ****
    Reduction(number_colors);
    for (i=0; i < number_images; i++)
    {
!     Assignment(images[i],number_colors,dither,colorspace,optimal);
      if (colorspace != RGBColorspace)
        TransformRGBImage(images[i],colorspace);
    }
--- 1690,1696 ----
    Reduction(number_colors);
    for (i=0; i < number_images; i++)
    {
!     Assignment(images[i],dither,colorspace,optimal);
      if (colorspace != RGBColorspace)
        TransformRGBImage(images[i],colorspace);
    }
diff -c -r ImageMagick-3.1/magick/shear.c ImageMagick/magick/shear.c
*** ImageMagick-3.1/magick/shear.c	Wed Jul 13 10:52:12 1994
--- ImageMagick/magick/shear.c	Wed Jun  1 11:28:52 1994
***************
*** 68,92 ****
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Function CropShearImage crops the sheared image as determined by the
  %  bounding box as defined by width and height and shearing angles.
  %
! %  The format of the CropShearImage routine is:
  %
! %      CropShearImage(image,x_shear,y_shear,width,height,crop)
  %
  %  A description of each parameter follows.
  %
  %    o image: The address of a structure of type Image.
  %
! %    o x_shear, y_shear, width, height: Defines a region of the image to crop.
  %
! %    o crop: A value other than zero crops the corners of the rotated
  %      image and retains the original image size.
  %
  %
  */
! static Image *CropShearImage(image,x_shear,y_shear,width,height,crop)
  Image
    *image;
  
--- 68,92 ----
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
! %  Function ClipShearImage clips the sheared image as determined by the
  %  bounding box as defined by width and height and shearing angles.
  %
! %  The format of the ClipShearImage routine is:
  %
! %      ClipShearImage(image,x_shear,y_shear,width,height,clip)
  %
  %  A description of each parameter follows.
  %
  %    o image: The address of a structure of type Image.
  %
! %    o x_shear, y_shear, width, height: Defines a region of the image to clip.
  %
! %    o clip: A value other than zero clips the corners of the rotated
  %      image and retains the original image size.
  %
  %
  */
! static Image *ClipShearImage(image,x_shear,y_shear,width,height,clip)
  Image
    *image;
  
***************
*** 97,103 ****
  unsigned int
    width,
    height,
!   crop;
  {
    typedef struct Point
    {
--- 97,103 ----
  unsigned int
    width,
    height,
!   clip;
  {
    typedef struct Point
    {
***************
*** 113,125 ****
      y_min;
  
    Image
!     *cropped_image;
  
    Point
      corners[4];
  
    RectangleInfo
!     crop_info;
  
    register int
      i;
--- 113,125 ----
      y_min;
  
    Image
!     *clipped_image;
  
    Point
      corners[4];
  
    RectangleInfo
!     clip_info;
  
    register int
      i;
***************
*** 127,142 ****
    /*
      Calculate the rotated image size.
    */
!   crop_info.width=width;
!   crop_info.height=height;
!   corners[0].x=(-((int) crop_info.width)/2.0);
!   corners[0].y=(-((int) crop_info.height)/2.0);
!   corners[1].x=((int) crop_info.width)/2.0;
!   corners[1].y=(-((int) crop_info.height)/2.0);
!   corners[2].x=(-((int) crop_info.width)/2.0);
!   corners[2].y=((int) crop_info.height)/2.0;
!   corners[3].x=((int) crop_info.width)/2.0;
!   corners[3].y=((int) crop_info.height)/2.0;
    for (i=0; i < 4; i++)
    {
      corners[i].x+=x_shear*corners[i].y;
--- 127,142 ----
    /*
      Calculate the rotated image size.
    */
!   clip_info.width=width;
!   clip_info.height=height;
!   corners[0].x=(-((int) clip_info.width)/2.0);
!   corners[0].y=(-((int) clip_info.height)/2.0);
!   corners[1].x=((int) clip_info.width)/2.0;
!   corners[1].y=(-((int) clip_info.height)/2.0);
!   corners[2].x=(-((int) clip_info.width)/2.0);
!   corners[2].y=((int) clip_info.height)/2.0;
!   corners[3].x=((int) clip_info.width)/2.0;
!   corners[3].y=((int) clip_info.height)/2.0;
    for (i=0; i < 4; i++)
    {
      corners[i].x+=x_shear*corners[i].y;
***************
*** 164,184 ****
    x_max=ceil((double) x_max);
    y_min=floor((double) y_min);
    y_max=ceil((double) y_max);
!   if (!crop)
      {
        /*
!         Do not crop sheared image.
        */
!       crop_info.width=(unsigned int) (x_max-x_min)-1;
!       crop_info.height=(unsigned int) (y_max-y_min)-1;
      }
!   crop_info.x=(int) x_min+(((int) (x_max-x_min)-crop_info.width) >> 1)+1;
!   crop_info.y=(int) y_min+(((int) (y_max-y_min)-crop_info.height) >> 1)+2;
    /*
!     Crop image and return.
    */
!   cropped_image=CropImage(image,&crop_info);
!   return(cropped_image);
  }
  
  /*
--- 164,184 ----
    x_max=ceil((double) x_max);
    y_min=floor((double) y_min);
    y_max=ceil((double) y_max);
!   if (!clip)
      {
        /*
!         Do not clip sheared image.
        */
!       clip_info.width=(unsigned int) (x_max-x_min)-1;
!       clip_info.height=(unsigned int) (y_max-y_min)-1;
      }
!   clip_info.x=(int) x_min+(((int) (x_max-x_min)-clip_info.width) >> 1)+1;
!   clip_info.y=(int) y_min+(((int) (y_max-y_min)-clip_info.height) >> 1)+2;
    /*
!     Clip image and return.
    */
!   clipped_image=ClipImage(image,&clip_info);
!   return(clipped_image);
  }
  
  /*
***************
*** 983,989 ****
  %
  %  The format of the RotateImage routine is:
  %
! %      RotateImage(image,degrees,background,crop)
  %
  %  A description of each parameter follows.
  %
--- 983,989 ----
  %
  %  The format of the RotateImage routine is:
  %
! %      RotateImage(image,degrees,background,clip)
  %
  %  A description of each parameter follows.
  %
***************
*** 998,1009 ****
  %    o background: The address of a ColorPacket structure;  contains the
  %      color of the empty triangles.
  %
! %    o crop: A value other than zero crops the corners of the rotated
  %      image and retains the original image size.
  %
  %
  */
! Image *RotateImage(image,degrees,background,crop)
  Image
    *image;
  
--- 998,1009 ----
  %    o background: The address of a ColorPacket structure;  contains the
  %      color of the empty triangles.
  %
! %    o clip: A value other than zero clips the corners of the rotated
  %      image and retains the original image size.
  %
  %
  */
! Image *RotateImage(image,degrees,background,clip)
  Image
    *image;
  
***************
*** 1014,1020 ****
    *background;
  
  unsigned int
!   crop;
  {
    double
      x_shear,
--- 1014,1020 ----
    *background;
  
  unsigned int
!   clip;
  {
    double
      x_shear,
***************
*** 1021,1027 ****
      y_shear;
  
    Image
!     *cropped_image,
      *integral_image,
      *rotated_image,
      *sharpened_image;
--- 1021,1027 ----
      y_shear;
  
    Image
!     *clipped_image,
      *integral_image,
      *rotated_image,
      *sharpened_image;
***************
*** 1124,1136 ****
      ((int) (rotated_image->columns-y_width) >> 1),1,background,range_limit);
    (void) free((char *) range_table);
    /*
!     Crop image.
    */
!   cropped_image=CropShearImage(rotated_image,x_shear,y_shear,width,height,crop);
!   if (cropped_image != (Image *) NULL)
      {
        DestroyImage(rotated_image);
!       rotated_image=cropped_image;
      }
    /*
      Sharpen image.
--- 1124,1136 ----
      ((int) (rotated_image->columns-y_width) >> 1),1,background,range_limit);
    (void) free((char *) range_table);
    /*
!     Clip image.
    */
!   clipped_image=ClipShearImage(rotated_image,x_shear,y_shear,width,height,clip);
!   if (clipped_image != (Image *) NULL)
      {
        DestroyImage(rotated_image);
!       rotated_image=clipped_image;
      }
    /*
      Sharpen image.
***************
*** 1172,1178 ****
  %
  %  The format of the ShearImage routine is:
  %
! %      ShearImage(image,x_shear,y_shear,crop)
  %
  %  A description of each parameter follows.
  %
--- 1172,1178 ----
  %
  %  The format of the ShearImage routine is:
  %
! %      ShearImage(image,x_shear,y_shear,clip)
  %
  %  A description of each parameter follows.
  %
***************
*** 1187,1198 ****
  %    o background: The address of a ColorPacket structure;  contains the
  %      color of the empty triangles.
  %
! %    o crop: A value other than zero crops the corners of the rotated
  %      image and retains the original image size.
  %
  %
  */
! Image *ShearImage(image,x_shear,y_shear,background,crop)
  Image
    *image;
  
--- 1187,1198 ----
  %    o background: The address of a ColorPacket structure;  contains the
  %      color of the empty triangles.
  %
! %    o clip: A value other than zero clips the corners of the rotated
  %      image and retains the original image size.
  %
  %
  */
! Image *ShearImage(image,x_shear,y_shear,background,clip)
  Image
    *image;
  
***************
*** 1204,1213 ****
    *background;
  
  unsigned int
!   crop;
  {
    Image
!     *cropped_image,
      *sharpened_image,
      *sheared_image;
  
--- 1204,1213 ----
    *background;
  
  unsigned int
!   clip;
  {
    Image
!     *clipped_image,
      *sharpened_image,
      *sheared_image;
  
***************
*** 1290,1303 ****
      range_limit);
    (void) free((char *) range_table);
    /*
!     Crop image.
    */
!   cropped_image=CropShearImage(sheared_image,x_shear,y_shear,image->columns,
!     image->rows,crop);
!   if (cropped_image != (Image *) NULL)
      {
        DestroyImage(sheared_image);
!       sheared_image=cropped_image;
      }
    /*
      Sharpen image.
--- 1290,1303 ----
      range_limit);
    (void) free((char *) range_table);
    /*
!     Clip image.
    */
!   clipped_image=ClipShearImage(sheared_image,x_shear,y_shear,image->columns,
!     image->rows,clip);
!   if (clipped_image != (Image *) NULL)
      {
        DestroyImage(sheared_image);
!       sheared_image=clipped_image;
      }
    /*
      Sharpen image.
diff -c -r ImageMagick-3.1/magick/utility.c ImageMagick/magick/utility.c
*** ImageMagick-3.1/magick/utility.c	Wed Jul 13 10:52:14 1994
--- ImageMagick/magick/utility.c	Fri Jun  3 15:25:23 1994
***************
*** 296,302 ****
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
  %  Function ListFiles reads the directory specified and returns a list
! %  of filenames contained in the directory sorted in ascending alphabetic
  %  order.
  %
  %  The format of the ListFiles function is:
--- 296,302 ----
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
  %  Function ListFiles reads the directory specified and returns a list
! %  of filenames contained in the directory sorted in ascending mattebetic
  %  order.
  %
  %  The format of the ListFiles function is:
***************
*** 1157,1200 ****
      }
    textlist[i]=(char *) NULL;
    return(textlist);
- }
- 
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %                                                                             %
- %                                                                             %
- %                                                                             %
- %  T e m p o r a r y F i l e n a m e                                          %
- %                                                                             %
- %                                                                             %
- %                                                                             %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- %  Function TemporaryFilename replaces the contents of the string pointed to
- %  by filename by a unique file name.
- %
- %  The format of the TemporaryFilename routine is:
- %
- %       TemporaryFilename(filename)
- %
- %  A description of each parameter follows.
- %
- %   o  filename:  Specifies a pointer to an array of characters.  The unique
- %      file name is returned in this array.
- %
- %
- */
- void TemporaryFilename(filename)
- char
-   *filename;
- {
-   char
-     *directory;
- 
-   directory=(char *) getenv("TMPDIR");
-   if (directory == (char *) NULL)
-     directory=TemporaryDirectory;
-   (void) sprintf(filename,TemporaryTemplate,directory);
-   (void) mktemp(filename);
-   return;
  }
--- 1157,1160 ----
diff -c -r ImageMagick-3.1/magick/utility.h ImageMagick/magick/utility.h
*** ImageMagick-3.1/magick/utility.h	Wed Jul 13 10:52:14 1994
--- ImageMagick/magick/utility.h	Mon May 23 16:44:32 1994
***************
*** 7,13 ****
  #define dirent direct
  #endif
  #endif
- #else
  #endif
  #ifndef S_ISDIR
  #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
--- 7,12 ----
***************
*** 15,29 ****
  /*
    Utility define declarations.
  */
- #ifndef vms
  #define DirectorySeparator  "/"
- #define TemporaryDirectory  "/tmp"
- #define TemporaryTemplate  "%s/magickXXXXXX"
- #else
- #define DirectorySeparator  "."
- #define TemporaryDirectory  "SYS$Disk:[]"
- #define TemporaryTemplate  "%smagickXXXXXX"
- #endif
  
  /*
    Utilities routines.
--- 14,20 ----
***************
*** 53,57 ****
    MSBFirstOrderLong _Declare((char *,unsigned int)),
    MSBFirstOrderShort _Declare((char *,unsigned int)),
    MSBFirstWriteLong _Declare((unsigned long,FILE *)),
!   MSBFirstWriteShort _Declare((unsigned int,FILE *)),
!   TemporaryFilename _Declare((char *));
--- 44,47 ----
    MSBFirstOrderLong _Declare((char *,unsigned int)),
    MSBFirstOrderShort _Declare((char *,unsigned int)),
    MSBFirstWriteLong _Declare((unsigned long,FILE *)),
!   MSBFirstWriteShort _Declare((unsigned int,FILE *));
diff -c -r ImageMagick-3.1/magick/widget.c ImageMagick/magick/widget.c
*** ImageMagick-3.1/magick/widget.c	Wed Jul 13 10:52:11 1994
--- ImageMagick/magick/widget.c	Sat Jun  4 00:32:07 1994
***************
*** 233,239 ****
      *font_info;
  
    XRectangle
!     crop_info;
  
    /*
      Draw matte.
--- 233,239 ----
      *font_info;
  
    XRectangle
!     clip_info;
  
    /*
      Draw matte.
***************
*** 253,264 ****
    if (button_info->text == (char *) NULL)
      return;
    /*
!     Set cropping region.
    */
!   crop_info.width=button_info->width;
!   crop_info.height=button_info->height;
!   crop_info.x=button_info->x;
!   crop_info.y=button_info->y;
    /*
      Draw text.
    */
--- 253,264 ----
    if (button_info->text == (char *) NULL)
      return;
    /*
!     Set clipping region.
    */
!   clip_info.width=button_info->width;
!   clip_info.height=button_info->height;
!   clip_info.x=button_info->x;
!   clip_info.y=button_info->y;
    /*
      Draw text.
    */
***************
*** 272,278 ****
    if (y < button_info->y)
      y=button_info->y;
    y+=window_info->font_info->ascent;
!   XSetClipRectangles(display,window_info->widget_context,0,0,&crop_info,1,
      Unsorted);
    XSetTextColor(display,window_info,button_info->raised);
    XDrawString(display,window_info->id,window_info->widget_context,x,y,
--- 272,278 ----
    if (y < button_info->y)
      y=button_info->y;
    y+=window_info->font_info->ascent;
!   XSetClipRectangles(display,window_info->widget_context,0,0,&clip_info,1,
      Unsorted);
    XSetTextColor(display,window_info,button_info->raised);
    XDrawString(display,window_info->id,window_info->widget_context,x,y,
***************
*** 443,449 ****
      *font_info;
  
    XRectangle
!     crop_info;
  
    /*
      Clear the text area.
--- 443,449 ----
      *font_info;
  
    XRectangle
!     clip_info;
  
    /*
      Clear the text area.
***************
*** 456,467 ****
    if (*text_info->text == '\0')
      return;
    /*
!     Set cropping region.
    */
!   crop_info.width=text_info->width;
!   crop_info.height=text_info->height;
!   crop_info.x=text_info->x;
!   crop_info.y=text_info->y;
    /*
      Determine beginning of the visible text.
    */
--- 456,467 ----
    if (*text_info->text == '\0')
      return;
    /*
!     Set clipping region.
    */
!   clip_info.width=text_info->width;
!   clip_info.height=text_info->height;
!   clip_info.x=text_info->x;
!   clip_info.y=text_info->y;
    /*
      Determine beginning of the visible text.
    */
***************
*** 490,496 ****
    y=text_info->y+font_info->ascent+(text_info->height >> 2);
    if (!text_info->highlight)
      {
!       XSetClipRectangles(display,window_info->widget_context,0,0,&crop_info,1,
          Unsorted);
        XDrawString(display,window_info->id,window_info->widget_context,x,y,
          text_info->marker,strlen(text_info->marker));
--- 490,496 ----
    y=text_info->y+font_info->ascent+(text_info->height >> 2);
    if (!text_info->highlight)
      {
!       XSetClipRectangles(display,window_info->widget_context,0,0,&clip_info,1,
          Unsorted);
        XDrawString(display,window_info->id,window_info->widget_context,x,y,
          text_info->marker,strlen(text_info->marker));
***************
*** 498,509 ****
      }
    else
      {
!       XSetClipRectangles(display,window_info->annotate_context,0,0,&crop_info,
          1,Unsorted);
        XFillRectangle(display,window_info->id,window_info->annotate_context,x,
          y-font_info->ascent,text_info->width,height);
        XSetClipMask(display,window_info->annotate_context,None);
!       XSetClipRectangles(display,window_info->highlight_context,0,0,&crop_info,
          1,Unsorted);
        XDrawString(display,window_info->id,window_info->highlight_context,x,y,
          text_info->marker,strlen(text_info->marker));
--- 498,509 ----
      }
    else
      {
!       XSetClipRectangles(display,window_info->annotate_context,0,0,&clip_info,
          1,Unsorted);
        XFillRectangle(display,window_info->id,window_info->annotate_context,x,
          y-font_info->ascent,text_info->width,height);
        XSetClipMask(display,window_info->annotate_context,None);
!       XSetClipRectangles(display,window_info->highlight_context,0,0,&clip_info,
          1,Unsorted);
        XDrawString(display,window_info->id,window_info->highlight_context,x,y,
          text_info->marker,strlen(text_info->marker));
***************
*** 806,812 ****
      *font_info;
  
    XRectangle
!     crop_info;
  
    /*
      Clear the text area.
--- 806,812 ----
      *font_info;
  
    XRectangle
!     clip_info;
  
    /*
      Clear the text area.
***************
*** 826,838 ****
    if (*text_info->text == '\0')
      return;
    /*
!     Set cropping region.
    */
    font_info=window_info->font_info;
!   crop_info.width=text_info->width;
!   crop_info.height=text_info->height;
!   crop_info.x=text_info->x;
!   crop_info.y=text_info->y;
    /*
      Draw text.
    */
--- 826,838 ----
    if (*text_info->text == '\0')
      return;
    /*
!     Set clipping region.
    */
    font_info=window_info->font_info;
!   clip_info.width=text_info->width;
!   clip_info.height=text_info->height;
!   clip_info.x=text_info->x;
!   clip_info.y=text_info->y;
    /*
      Draw text.
    */
***************
*** 842,848 ****
      x+=(text_info->width-font_info->max_bounds.width-width);
    height=font_info->ascent+font_info->descent;
    y=text_info->y+((text_info->height-height) >> 1)+font_info->ascent;
!   XSetClipRectangles(display,widget_context,0,0,&crop_info,1,Unsorted);
    XDrawString(display,window_info->id,widget_context,x,y,
      text_info->text,strlen(text_info->text));
    XSetClipMask(display,widget_context,None);
--- 842,848 ----
      x+=(text_info->width-font_info->max_bounds.width-width);
    height=font_info->ascent+font_info->descent;
    y=text_info->y+((text_info->height-height) >> 1)+font_info->ascent;
!   XSetClipRectangles(display,widget_context,0,0,&clip_info,1,Unsorted);
    XDrawString(display,window_info->id,widget_context,x,y,
      text_info->text,strlen(text_info->text));
    XSetClipMask(display,widget_context,None);
***************
*** 2263,2268 ****
--- 2263,2270 ----
              state|=UpdateListState;
              break;
            }
+         if (!MatteIsActive(reply_info,event.xkey))
+           break;
          if (key_symbol == XK_Control_L)
            {
              state|=ControlState;
***************
*** 2462,2468 ****
    } while (!(state & ExitState));
    XDefineCursor(display,windows->image.id,windows->image.cursor);
    XWithdrawWindow(display,windows->popup.id,windows->popup.screen);
-   XCheckRefreshWindow(display,&windows->image);
    /*
      Free color list.
    */
--- 2464,2469 ----
***************
*** 2530,2538 ****
      {
        "File",
        "Edit",
!       "Size",
!       "Pixel Transform",
!       "Color Enhance",
        "Effects",
        "Image Edit",
        "Help",
--- 2531,2539 ----
      {
        "File",
        "Edit",
!       "View",
!       "Transform",
!       "Enhance",
        "Effects",
        "Image Edit",
        "Help",
***************
*** 2548,2554 ****
        "Load...",
        "Next",
        "Former",
-       "Quicken",
        (char *) NULL
      },
      *EditMenu[]=
--- 2549,2554 ----
***************
*** 2556,2565 ****
        "Undo",
        "Restore",
        "Refresh",
-       "Toggle Colormap",
        (char *) NULL
      },
!     *SizeMenu[]=
      {
        "Half Size",
        "Original Size",
--- 2556,2564 ----
        "Undo",
        "Restore",
        "Refresh",
        (char *) NULL
      },
!     *ViewMenu[]=
      {
        "Half Size",
        "Original Size",
***************
*** 2567,2576 ****
        "Resize...",
        (char *) NULL
      },
!     *PixelTransformMenu[]=
      {
        "Trim Edges",
!       "Crop",
        "Cut",
        "Flop",
        "Flip",
--- 2566,2575 ----
        "Resize...",
        (char *) NULL
      },
!     *TransformMenu[]=
      {
        "Trim Edges",
!       "Clip",
        "Cut",
        "Flop",
        "Flip",
***************
*** 2580,2596 ****
        "Shear...",
        (char *) NULL
      },
!     *ColorEnhanceMenu[]=
      {
!       "Brighten",
!       "Darken",
!       "Gamma...",
!       "Spiff",
!       "Dull",
!       "Saturate...",
        "Equalize",
        "Normalize",
!       "Negate",
        (char *) NULL
      },
      *EffectsMenu[]=
--- 2579,2590 ----
        "Shear...",
        (char *) NULL
      },
!     *EnhanceMenu[]=
      {
!       "Negate",
        "Equalize",
        "Normalize",
!       "Gamma...",
        (char *) NULL
      },
      *EffectsMenu[]=
***************
*** 2600,2606 ****
        "Sharpen",
        "Blur",
        "Edge Detect",
-       "Emboss",
        "Grayscale",
        "Quantize...",
        (char *) NULL
--- 2594,2599 ----
***************
*** 2627,2635 ****
      {
        FileMenu,
        EditMenu,
!       SizeMenu,
!       PixelTransformMenu,
!       ColorEnhanceMenu,
        EffectsMenu,
        ImageEditMenu,
        HelpMenu
--- 2620,2628 ----
      {
        FileMenu,
        EditMenu,
!       ViewMenu,
!       TransformMenu,
!       EnhanceMenu,
        EffectsMenu,
        ImageEditMenu,
        HelpMenu
***************
*** 2656,2672 ****
        XK_d,
        XK_l,
        XK_n,
!       XK_f,
!       XK_Q
      },
      EditKeys[]=
      {
        XK_u,
        XK_r,
!       XK_at,
!       XK_F7
      },
!     SizeKeys[]=
      {
        XK_less,
        XK_o,
--- 2649,2663 ----
        XK_d,
        XK_l,
        XK_n,
!       XK_f
      },
      EditKeys[]=
      {
        XK_u,
        XK_r,
!       XK_at
      },
!     ViewKeys[]=
      {
        XK_less,
        XK_o,
***************
*** 2673,2679 ****
        XK_greater,
        XK_percent,
      },
!     PixelTransformKeys[]=
      {
        XK_t,
        XK_bracketleft,
--- 2664,2670 ----
        XK_greater,
        XK_percent,
      },
!     TransformKeys[]=
      {
        XK_t,
        XK_bracketleft,
***************
*** 2685,2701 ****
        XK_asterisk,
        XK_s
      },
!     ColorEnhanceKeys[]=
      {
!       XK_F8,
!       XK_F9,
!       XK_g,
!       XK_F10,
!       XK_F11,
!       XK_F12,
        XK_equal,
        XK_N,
!       XK_asciitilde
      },
      EffectsKeys[]=
      {
--- 2676,2687 ----
        XK_asterisk,
        XK_s
      },
!     EnhanceKeys[]=
      {
!       XK_asciitilde,
        XK_equal,
        XK_N,
!       XK_g
      },
      EffectsKeys[]=
      {
***************
*** 2704,2712 ****
        XK_S,
        XK_B,
        XK_E,
-       XK_M,
        XK_G,
!       XK_numbersign
      },
      ImageEditKeys[]=
      {
--- 2690,2697 ----
        XK_S,
        XK_B,
        XK_E,
        XK_G,
!       XK_Q
      },
      ImageEditKeys[]=
      {
***************
*** 2715,2721 ****
        XK_x,
        XK_c,
        XK_m,
!       XK_exclam
      },
      HelpKeys[]=
      {
--- 2700,2706 ----
        XK_x,
        XK_c,
        XK_m,
!       XK_numbersign
      },
      HelpKeys[]=
      {
***************
*** 2728,2736 ****
      {
        FileKeys,
        EditKeys,
!       SizeKeys,
!       PixelTransformKeys,
!       ColorEnhanceKeys,
        EffectsKeys,
        ImageEditKeys,
        HelpKeys,
--- 2713,2721 ----
      {
        FileKeys,
        EditKeys,
!       ViewKeys,
!       TransformKeys,
!       EnhanceKeys,
        EffectsKeys,
        ImageEditKeys,
        HelpKeys,
***************
*** 3071,3077 ****
    } while (!(state & ExitState));
    XDefineCursor(display,windows->image.id,windows->image.cursor);
    XWithdrawWindow(display,windows->command.id,windows->command.screen);
-   XCheckRefreshWindow(display,&windows->image);
    return(key_symbol);
  }
  
--- 3056,3061 ----
***************
*** 3343,3349 ****
            {
              if (event.xbutton.window == windows->popup.id)
                if (MatteIsActive(action_info,event.xbutton))
!                 state|=ExitState;
              action_info.raised=True;
              XDrawBeveledButton(display,&windows->popup,&action_info);
            }
--- 3327,3336 ----
            {
              if (event.xbutton.window == windows->popup.id)
                if (MatteIsActive(action_info,event.xbutton))
!                 if (*reply_info.text == '\0')
!                   XBell(display,0);
!                 else
!                   state|=ExitState;
              action_info.raised=True;
              XDrawBeveledButton(display,&windows->popup,&action_info);
            }
***************
*** 3437,3447 ****
          *(command+length)='\0';
          if ((key_symbol == XK_Return) || (key_symbol == XK_KP_Enter))
            {
!             action_info.raised=False;
!             XDrawBeveledButton(display,&windows->popup,&action_info);
!             state|=ExitState;
              break;
            }
          if (key_symbol == XK_Control_L)
            {
              state|=ControlState;
--- 3424,3439 ----
          *(command+length)='\0';
          if ((key_symbol == XK_Return) || (key_symbol == XK_KP_Enter))
            {
!             if (*reply_info.text != '\0')
!               {
!                 action_info.raised=False;
!                 XDrawBeveledButton(display,&windows->popup,&action_info);
!                 state|=ExitState;
!               }
              break;
            }
+         if (!MatteIsActive(reply_info,event.xkey))
+           break;
          if (key_symbol == XK_Control_L)
            {
              state|=ControlState;
***************
*** 3601,3607 ****
    } while (!(state & ExitState));
    XDefineCursor(display,windows->image.id,windows->image.cursor);
    XWithdrawWindow(display,windows->popup.id,windows->popup.screen);
-   XCheckRefreshWindow(display,&windows->image);
  }
  
  /*
--- 3593,3598 ----
***************
*** 4439,4444 ****
--- 4430,4437 ----
              state|=UpdateListState;
              break;
            }
+         if (!MatteIsActive(reply_info,event.xkey))
+           break;
          if (key_symbol == XK_Control_L)
            {
              state|=ControlState;
***************
*** 4632,4638 ****
    } while (!(state & ExitState));
    XDefineCursor(display,windows->image.id,windows->image.cursor);
    XWithdrawWindow(display,windows->popup.id,windows->popup.screen);
-   XCheckRefreshWindow(display,&windows->image);
    /*
      Free file list.
    */
--- 4625,4630 ----
***************
*** 5577,5582 ****
--- 5569,5576 ----
              state|=UpdateListState;
              break;
            }
+         if (!MatteIsActive(reply_info,event.xkey))
+           break;
          if (key_symbol == XK_Control_L)
            {
              state|=ControlState;
***************
*** 5769,5775 ****
    } while (!(state & ExitState));
    XDefineCursor(display,windows->image.id,windows->image.cursor);
    XWithdrawWindow(display,windows->popup.id,windows->popup.screen);
-   XCheckRefreshWindow(display,&windows->image);
    /*
      Free font list.
    */
--- 5763,5768 ----
***************
*** 5782,6656 ****
  %                                                                             %
  %                                                                             %
  %                                                                             %
- %   X L i s t B r o w s e r W i d g e t                                       %
- %                                                                             %
- %                                                                             %
- %                                                                             %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- %  Function XListBrowserWidget displays a popup window with a query to the
- %  user.  The user keys a reply or select a reply from the list.  Finally,
- %  the user presses the Action or Cancel button to exit.  The typed text is
- %  returned as the reply function parameter.
- %
- %  The format of the XListBrowserWidget routine is:
- %
- %    XListBrowserWidget(display,windows,list,action,query,reply)
- %
- %  A description of each parameter follows:
- %
- %    o display: Specifies a connection to an X server;  returned from
- %      XOpenDisplay.
- %
- %    o window: Specifies a pointer to a XWindows structure.
- %
- %    o list: Specifies a pointer to an array of strings.  The user can
- %      select from these strings as a possible reply value.
- %
- %    o action: Specifies a pointer to the action of this widget.
- %
- %    o query: Specifies a pointer to the query to present to the user.
- %
- %    o reply: The response from the user is returned in this parameter.
- %
- %
- */
- void XListBrowserWidget(display,windows,list,action,query,reply)
- Display
-   *display;
- 
- XWindows
-   *windows;
- 
- char
-   **list,
-   *action,
-   *query,
-   *reply;
- {
- #define CancelButtonText  "Cancel"
- 
-   char
-     primary_selection[MaxTextLength];
- 
-   int
-     entries,
-     x,
-     y;
- 
-   register int
-     i;
- 
-   unsigned int
-     height,
-     limit,
-     mask,
-     text_width,
-     visible_entries,
-     width;
- 
-   unsigned long
-     delay,
-     state;
- 
-   Window
-     root_window;
- 
-   XEvent
-     event;
- 
-   XFontStruct
-     *font_info;
- 
-   XTextProperty
-     window_name;
- 
-   XWidgetInfo
-     action_info,
-     cancel_info,
-     expose_info,
-     list_info,
-     north_info,
-     reply_info,
-     scroll_info,
-     selection_info,
-     slider_info,
-     south_info,
-     text_info;
- 
-   XWindowChanges
-     window_changes;
- 
-   /*
-     Count the number of entries in the list.
-   */
-   XDefineCursor(display,windows->image.id,windows->image.busy_cursor);
-   XFlush(display);
-   for (entries=0; ; entries++)
-     if (list[entries] == (char *) NULL)
-       break;
-   /*
-     Determine popup window attributes.
-   */
-   font_info=windows->popup.font_info;
-   text_width=XTextWidth(font_info,query,strlen(query));
-   for (i=0; i < entries; i++)
-     if (XTextWidth(font_info,list[i],strlen(list[i])) > text_width)
-       text_width=XTextWidth(font_info,list[i],strlen(list[i]));
-   width=XTextWidth(font_info,action,strlen(action));
-   if (XTextWidth(font_info,CancelButtonText,strlen(CancelButtonText)) > width)
-     width=XTextWidth(font_info,CancelButtonText,strlen(CancelButtonText));
-   width+=font_info->max_bounds.width;
-   height=font_info->ascent+font_info->descent;
-   windows->popup.width=text_width+4*font_info->max_bounds.width;
-   windows->popup.height=
-     ((81*height) >> 2)+((13*font_info->max_bounds.width) >> 1)+4;
-   windows->popup.min_width=25*XTextWidth(font_info,"#",1)+
-     4*font_info->max_bounds.width;
-   windows->popup.min_height=
-     ((23*height) >> 1)+((13*font_info->max_bounds.width) >> 1)+4;
-   /*
-     Position popup window.
-   */
-   XQueryPointer(display,XRootWindow(display,windows->popup.screen),&root_window,
-     &root_window,&x,&y,&windows->popup.x,&windows->popup.y,&mask);
-   if (windows->popup.width < windows->popup.min_width)
-     windows->popup.width=windows->popup.min_width;
-   windows->popup.x-=((3*windows->popup.width) >> 2);
-   limit=XDisplayWidth(display,windows->popup.screen)-windows->popup.width;
-   if (windows->popup.x < 0)
-     windows->popup.x=0;
-   else
-     if (windows->popup.x > limit)
-       windows->popup.x=limit;
-   if (windows->popup.height < windows->popup.min_height)
-     windows->popup.height=windows->popup.min_height;
-   windows->popup.y-=(windows->popup.height >> 1);
-   limit=XDisplayHeight(display,windows->popup.screen)-windows->popup.height;
-   if (windows->popup.y < 0)
-     windows->popup.y=0;
-   else
-     if (windows->popup.y > limit)
-       windows->popup.y=limit;
-   /*
-     Map popup window.
-   */
-   (void) sprintf(windows->popup.name,"Browse");
-   (void) XStringListToTextProperty(&windows->popup.name,1,&window_name);
-   XSetWMName(display,windows->popup.id,&window_name);
-   window_changes.width=windows->popup.width;
-   window_changes.height=windows->popup.height;
-   window_changes.x=windows->popup.x;
-   window_changes.y=windows->popup.y;
-   XReconfigureWMWindow(display,windows->popup.id,windows->popup.screen,CWWidth |
-     CWHeight | CWX | CWY,&window_changes);
-   XMapRaised(display,windows->popup.id);
-   /*
-     Respond to X events.
-   */
-   XGetWidgetInfo((char *) NULL,&slider_info);
-   XGetWidgetInfo((char *) NULL,&north_info);
-   XGetWidgetInfo((char *) NULL,&south_info);
-   visible_entries=0;
-   delay=SuspendTime << 2;
-   state=RedrawWidgetState | UpdateConfigurationState;
-   do
-   {
-     if (state & UpdateConfigurationState)
-       {
-         int
-           id;
- 
-         /*
-           Initialize button information.
-         */
-         XGetWidgetInfo(CancelButtonText,&cancel_info);
-         cancel_info.width=width;
-         cancel_info.height=(3*height) >> 1;
-         cancel_info.x=windows->popup.width-cancel_info.width-
-           font_info->max_bounds.width-2;
-         cancel_info.y=windows->popup.height-cancel_info.height-
-           font_info->max_bounds.width;
-         XGetWidgetInfo(action,&action_info);
-         action_info.width=width;
-         action_info.height=(3*height) >> 1;
-         action_info.x=cancel_info.x-(cancel_info.width+
-           (font_info->max_bounds.width >> 1)+(action_info.bevel_width << 1));
-         action_info.y=cancel_info.y;
-         /*
-           Initialize reply information.
-         */
-         XGetWidgetInfo(reply,&reply_info);
-         reply_info.raised=False;
-         reply_info.bevel_width--;
-         reply_info.width=
-           windows->popup.width-((4*font_info->max_bounds.width) >> 1);
-         reply_info.height=height << 1;
-         reply_info.x=font_info->max_bounds.width;
-         reply_info.y=
-           action_info.y-reply_info.height-font_info->max_bounds.width;
-         /*
-           Initialize scroll information.
-         */
-         XGetWidgetInfo((char *) NULL,&scroll_info);
-         scroll_info.bevel_width--;
-         scroll_info.width=height;
-         scroll_info.height=
-           reply_info.y-((6*font_info->max_bounds.width) >> 1)-height;
-         scroll_info.x=reply_info.x+(reply_info.width-scroll_info.width);
-         scroll_info.y=
-           ((5*font_info->max_bounds.width) >> 1)+height-reply_info.bevel_width;
-         scroll_info.raised=False;
-         scroll_info.trough=True;
-         north_info=scroll_info;
-         north_info.raised=True;
-         north_info.width-=(north_info.bevel_width << 1);
-         north_info.height=north_info.width-1;
-         north_info.x+=north_info.bevel_width;
-         north_info.y+=north_info.bevel_width;
-         south_info=north_info;
-         south_info.y=scroll_info.y+scroll_info.height-scroll_info.bevel_width-
-           south_info.height;
-         id=slider_info.id;
-         slider_info=north_info;
-         slider_info.id=id;
-         slider_info.width-=2;
-         slider_info.min_y=north_info.y+north_info.height+north_info.bevel_width+
-           slider_info.bevel_width+2;
-         slider_info.height=
-           scroll_info.height-((slider_info.min_y-scroll_info.y+1) << 1)+2;
-         visible_entries=
-           (scroll_info.height-(height >> 3)-4)/((9*height) >> 3);
-         if (entries > visible_entries)
-           slider_info.height=(visible_entries*slider_info.height)/entries;
-         slider_info.max_y=south_info.y-south_info.bevel_width-
-           slider_info.bevel_width-2;
-         slider_info.x=scroll_info.x+slider_info.bevel_width+1;
-         slider_info.y=slider_info.min_y;
-         expose_info=scroll_info;
-         expose_info.y=slider_info.y;
-         /*
-           Initialize list information.
-         */
-         XGetWidgetInfo((char *) NULL,&list_info);
-         list_info.raised=False;
-         list_info.bevel_width--;
-         list_info.width=
-           scroll_info.x-reply_info.x-(font_info->max_bounds.width >> 1);
-         list_info.height=scroll_info.height;
-         list_info.x=reply_info.x;
-         list_info.y=scroll_info.y;
-         /*
-           Initialize text information.
-         */
-         XGetWidgetInfo(query,&text_info);
-         text_info.width=reply_info.width;
-         text_info.height=height;
-         text_info.x=list_info.x-(font_info->max_bounds.width >> 1);
-         text_info.y=font_info->max_bounds.width;
-         /*
-           Initialize selection information.
-         */
-         XGetWidgetInfo((char *) NULL,&selection_info);
-         selection_info.width=list_info.width;
-         selection_info.height=(9*height) >> 3;
-         selection_info.x=list_info.x;
-         state&=(~UpdateConfigurationState);
-       }
-     if (state & RedrawWidgetState)
-       {
-         /*
-           Redraw list browser window.
-         */
-         XClearWindow(display,windows->popup.id);
-         x=font_info->max_bounds.width;
-         y=text_info.y+((text_info.height-height) >> 1)+font_info->ascent;
-         XDrawWidgetText(display,&windows->popup,&text_info);
-         XDrawBeveledMatte(display,&windows->popup,&list_info);
-         XDrawBeveledMatte(display,&windows->popup,&scroll_info);
-         XDrawTriangleNorth(display,&windows->popup,&north_info);
-         XDrawBeveledButton(display,&windows->popup,&slider_info);
-         XDrawTriangleSouth(display,&windows->popup,&south_info);
-         x=font_info->max_bounds.width;
-         y=reply_info.y+((reply_info.height-height) >> 1)+font_info->ascent;
-         XDrawBeveledMatte(display,&windows->popup,&reply_info);
-         XDrawMatteText(display,&windows->popup,&reply_info);
-         XDrawBeveledButton(display,&windows->popup,&action_info);
-         XDrawBeveledButton(display,&windows->popup,&cancel_info);
-         XHighlightWidget(display,&windows->popup,4,4);
-         selection_info.id=(~0);
-         state|=RedrawActionState;
-         state|=RedrawListState;
-         state&=(~RedrawWidgetState);
-       }
-     if (state & RedrawListState)
-       {
-         /*
-           Determine slider id and position.
-         */
-         if (slider_info.id >= (int) (entries-visible_entries))
-           slider_info.id=entries-visible_entries;
-         if ((slider_info.id < 0) || (entries <= visible_entries))
-           slider_info.id=0;
-         slider_info.y=slider_info.min_y;
-         if (entries > 0)
-           slider_info.y+=
-             slider_info.id*(slider_info.max_y-slider_info.min_y+1)/entries;
-         if (slider_info.id != selection_info.id)
-           {
-             /*
-               Redraw scroll bar and file names.
-             */
-             selection_info.id=slider_info.id;
-             selection_info.y=list_info.y+(height >> 3)+2;
-             for (i=0; i < visible_entries; i++)
-             {
-               selection_info.raised=(slider_info.id+i) != list_info.id;
-               selection_info.text=(char *) NULL;
-               if ((slider_info.id+i) < entries)
-                 selection_info.text=list[slider_info.id+i];
-               XDrawWidgetText(display,&windows->popup,&selection_info);
-               selection_info.y+=(int) selection_info.height;
-             }
-             /*
-               Update slider.
-             */
-             if (slider_info.y > expose_info.y)
-               {
-                 expose_info.height=slider_info.y-expose_info.y;
-                 expose_info.y=slider_info.y-expose_info.height-
-                   slider_info.bevel_width-1;
-               }
-             else
-               {
-                 expose_info.height=expose_info.y-slider_info.y;
-                 expose_info.y=slider_info.y+slider_info.height+
-                   slider_info.bevel_width+1;
-               }
-             XDrawTriangleNorth(display,&windows->popup,&north_info);
-             XDrawMatte(display,&windows->popup,&expose_info);
-             XDrawBeveledButton(display,&windows->popup,&slider_info);
-             XDrawTriangleSouth(display,&windows->popup,&south_info);
-             expose_info.y=slider_info.y;
-           }
-         state&=(~RedrawListState);
-       }
-     /*
-       Wait for next event.
-     */
-     if (north_info.raised && south_info.raised)
-       XIfEvent(display,&event,XScreenEvent,(char *) windows);
-     else
-       {
-         /*
-           Brief delay before advancing scroll bar.
-         */
-         XDelay(display,delay);
-         XCheckMaskEvent(display,ButtonReleaseMask,&event);
-         delay=SuspendTime;
-       }
-     switch (event.type)
-     {
-       case ButtonPress:
-       {
-         if (MatteIsActive(slider_info,event.xbutton))
-           {
-             /*
-               Track slider.
-             */
-             slider_info.active=True;
-             break;
-           }
-         if (MatteIsActive(north_info,event.xbutton))
-           if (slider_info.id > 0)
-             {
-               /*
-                 Move slider up.
-               */
-               north_info.raised=False;
-               slider_info.id--;
-               state|=RedrawListState;
-               break;
-             }
-         if (MatteIsActive(south_info,event.xbutton))
-           if (slider_info.id < entries)
-             {
-               /*
-                 Move slider down.
-               */
-               south_info.raised=False;
-               slider_info.id++;
-               state|=RedrawListState;
-               break;
-             }
-         if (MatteIsActive(scroll_info,event.xbutton))
-           {
-             /*
-               Move slider.
-             */
-             if (event.xbutton.y < slider_info.y)
-               slider_info.id-=(visible_entries-1);
-             else
-               slider_info.id+=(visible_entries-1);
-             state|=RedrawListState;
-             break;
-           }
-         if (MatteIsActive(list_info,event.xbutton))
-           {
-             unsigned int
-               id;
- 
-             /*
-               User pressed list matte.
-             */
-             id=slider_info.id+(event.xbutton.y-(list_info.y+(height >> 1))+1)/
-               selection_info.height;
-             if (id >= entries)
-               break;
-             (void) strcpy(reply_info.text,list[id]);
-             reply_info.highlight=False;
-             reply_info.marker=reply_info.text;
-             reply_info.cursor=reply_info.text+strlen(reply_info.text);
-             XDrawMatteText(display,&windows->popup,&reply_info);
-             selection_info.id=(~0);
-             if (id == list_info.id)
-               {
-                 action_info.raised=False;
-                 XDrawBeveledButton(display,&windows->popup,&action_info);
-                 state|=ExitState;
-               }
-             list_info.id=id;
-             state|=RedrawListState;
-             break;
-           }
-         if (MatteIsActive(action_info,event.xbutton))
-           {
-             /*
-               User pressed action button.
-             */
-             action_info.raised=False;
-             XDrawBeveledButton(display,&windows->popup,&action_info);
-             break;
-           }
-         if (MatteIsActive(cancel_info,event.xbutton))
-           {
-             /*
-               User pressed Cancel button.
-             */
-             cancel_info.raised=False;
-             XDrawBeveledButton(display,&windows->popup,&cancel_info);
-             break;
-           }
-         if (!MatteIsActive(reply_info,event.xbutton))
-           break;
-         if (event.xbutton.button != Button2)
-           {
-             static Time
-               click_time;
- 
-             /*
-               Move text cursor to position of button press.
-             */
-             x=event.xbutton.x-reply_info.x-(font_info->max_bounds.width >> 2);
-             for (i=1; i <= (int) strlen(reply_info.marker); i++)
-               if (XTextWidth(font_info,reply_info.marker,i) > x)
-                 break;
-             reply_info.cursor=reply_info.marker+i-1;
-             if (event.xbutton.time < (click_time+DoubleClick))
-               {
-                 /*
-                   Become the XA_PRIMARY selection owner.
-                 */
-                 (void) strcpy(primary_selection,reply_info.text);
-                 XSetSelectionOwner(display,XA_PRIMARY,windows->popup.id,
-                   event.xbutton.time);
-                 reply_info.highlight=XGetSelectionOwner(display,XA_PRIMARY) ==
-                   windows->popup.id;
-               }
-             XDrawMatteText(display,&windows->popup,&reply_info);
-             click_time=event.xbutton.time;
-             break;
-           }
-         /*
-           Request primary selection.
-         */
-         XConvertSelection(display,XA_PRIMARY,XA_STRING,XA_STRING,
-           windows->popup.id,event.xbutton.time);
-         break;
-       }
-       case ButtonRelease:
-       {
-         if (!north_info.raised)
-           {
-             /*
-               User released up button.
-             */
-             delay=SuspendTime << 2;
-             north_info.raised=True;
-             XDrawTriangleNorth(display,&windows->popup,&north_info);
-           }
-         if (!south_info.raised)
-           {
-             /*
-               User released down button.
-             */
-             delay=SuspendTime << 2;
-             south_info.raised=True;
-             XDrawTriangleSouth(display,&windows->popup,&south_info);
-           }
-         if (slider_info.active)
-           {
-             /*
-               Stop tracking slider.
-             */
-             slider_info.active=False;
-             break;
-           }
-         if (!action_info.raised)
-           {
-             if (event.xbutton.window == windows->popup.id)
-               if (MatteIsActive(action_info,event.xbutton))
-                 if (*reply_info.text == '\0')
-                   XBell(display,0);
-                 else
-                   state|=ExitState;
-             action_info.raised=True;
-             XDrawBeveledButton(display,&windows->popup,&action_info);
-           }
-         if (!cancel_info.raised)
-           {
-             if (event.xbutton.window == windows->popup.id)
-               if (MatteIsActive(cancel_info,event.xbutton))
-                 {
-                   *reply_info.text='\0';
-                   state|=ExitState;
-                 }
-             cancel_info.raised=True;
-             XDrawBeveledButton(display,&windows->popup,&cancel_info);
-           }
-         if (!MatteIsActive(reply_info,event.xbutton))
-           break;
-         break;
-       }
-       case ClientMessage:
-       {
-         /*
-           If client window delete message, exit.
-         */
-         if (event.xclient.message_type != windows->wm_protocols)
-           break;
-         if (*event.xclient.data.l == windows->wm_take_focus)
-           {
-             XSetInputFocus(display,event.xclient.window,RevertToParent,
-               event.xclient.data.l[1]);
-             break;
-           }
-         if (*event.xclient.data.l != windows->wm_delete_window)
-           break;
-         if (event.xclient.window == windows->popup.id)
-           {
-             *reply_info.text='\0';
-             state|=ExitState;
-             break;
-           }
-         break;
-       }
-       case ConfigureNotify:
-       {
-         /*
-           Update widget configuration.
-         */
-         if (event.xconfigure.window != windows->popup.id)
-           break;
-         if ((event.xconfigure.width == windows->popup.width) &&
-             (event.xconfigure.height == windows->popup.height))
-           break;
-         windows->popup.width=
-           Max(event.xconfigure.width,windows->popup.min_width);
-         windows->popup.height=
-           Max(event.xconfigure.height,windows->popup.min_height);
-         state|=UpdateConfigurationState;
-         break;
-       }
-       case EnterNotify:
-       {
-         if (event.xcrossing.window != windows->popup.id)
-           break;
-         state&=(~InactiveWidgetState);
-         break;
-       }
-       case Expose:
-       {
-         if (event.xexpose.window != windows->popup.id)
-           break;
-         if (event.xexpose.count != 0)
-           break;
-         state|=RedrawWidgetState;
-         break;
-       }
-       case KeyPress:
-       {
-         static char
-           command[MaxTextLength];
- 
-         static int
-           length;
- 
-         static KeySym
-           key_symbol;
- 
-         if (event.xkey.window != windows->popup.id)
-           break;
-         /*
-           Respond to a user key press.
-         */
-         length=XLookupString((XKeyEvent *) &event.xkey,command,sizeof(command),
-           &key_symbol,(XComposeStatus *) NULL);
-         *(command+length)='\0';
-         if (MatteIsActive(scroll_info,event.xkey))
-           {
-             /*
-               Move slider.
-             */
-             switch (key_symbol)
-             {
-               case XK_Home:
-               case XK_KP_Home:
-               {
-                 slider_info.id=0;
-                 break;
-               }
-               case XK_Up:
-               case XK_KP_Up:
-               {
-                 slider_info.id--;
-                 break;
-               }
-               case XK_Down:
-               case XK_KP_Down:
-               {
-                 slider_info.id++;
-                 break;
-               }
-               case XK_Prior:
-               case XK_KP_Prior:
-               {
-                 slider_info.id-=visible_entries;
-                 break;
-               }
-               case XK_Next:
-               case XK_KP_Next:
-               {
-                 slider_info.id+=visible_entries;
-                 break;
-               }
-               case XK_End:
-               case XK_KP_End:
-               {
-                 slider_info.id=entries;
-                 break;
-               }
-             }
-             state|=RedrawListState;
-             break;
-           }
-         if ((key_symbol == XK_Return) || (key_symbol == XK_KP_Enter))
-           {
-             /*
-               Read new entry.
-             */
-             if (*reply_info.text == '\0')
-               break;
-             action_info.raised=False;
-             XDrawBeveledButton(display,&windows->popup,&action_info);
-             state|=ExitState;
-             break;
-           }
-         if (key_symbol == XK_Control_L)
-           {
-             state|=ControlState;
-             break;
-           }
-         if (state & ControlState)
-           switch (key_symbol)
-           {
-             case XK_u:
-             case XK_U:
-             {
-               key_symbol=XK_Delete;
-               break;
-             }
-             default:
-               break;
-           }
-         XEditText(display,&reply_info,key_symbol,command,state);
-         XDrawMatteText(display,&windows->popup,&reply_info);
-         break;
-       }
-       case KeyRelease:
-       {
-         static char
-           command[MaxTextLength];
- 
-         static KeySym
-           key_symbol;
- 
-         if (event.xkey.window != windows->popup.id)
-           break;
-         /*
-           Respond to a user key release.
-         */
-         (void) XLookupString((XKeyEvent *) &event.xkey,command,sizeof(command),
-           &key_symbol,(XComposeStatus *) NULL);
-         if (key_symbol == XK_Control_L)
-           state&=(~ControlState);
-         break;
-       }
-       case LeaveNotify:
-       {
-         if (event.xcrossing.window != windows->popup.id)
-           break;
-         state|=InactiveWidgetState;
-         break;
-       }
-       case MotionNotify:
-       {
-         /*
-           Discard pending button motion events.
-         */
-         while (XCheckMaskEvent(display,ButtonMotionMask,&event));
-         if (slider_info.active)
-           {
-             /*
-               Move slider matte.
-             */
-             slider_info.y=event.xmotion.y-
-               ((slider_info.height+slider_info.bevel_width) >> 1)+1;
-             if (slider_info.y < slider_info.min_y)
-               slider_info.y=slider_info.min_y;
-             if (slider_info.y > slider_info.max_y)
-               slider_info.y=slider_info.max_y;
-             slider_info.id=(entries*(slider_info.y-slider_info.min_y+1))/
-               (slider_info.max_y-slider_info.min_y+1);
-             state|=RedrawListState;
-             break;
-           }
-         if (state & InactiveWidgetState)
-           break;
-         if (action_info.raised == MatteIsActive(action_info,event.xmotion))
-           {
-             /*
-               Action button status changed.
-             */
-             action_info.raised=!action_info.raised;
-             XDrawBeveledButton(display,&windows->popup,&action_info);
-             break;
-           }
-         if (cancel_info.raised == MatteIsActive(cancel_info,event.xmotion))
-           {
-             /*
-               Cancel button status changed.
-             */
-             cancel_info.raised=!cancel_info.raised;
-             XDrawBeveledButton(display,&windows->popup,&cancel_info);
-             break;
-           }
-         break;
-       }
-       case SelectionClear:
-       {
-         reply_info.highlight=False;
-         XDrawMatteText(display,&windows->popup,&reply_info);
-         break;
-       }
-       case SelectionNotify:
-       {
-         Atom
-           type;
- 
-         int
-           format,
-           status;
- 
-         unsigned char
-           *data;
- 
-         unsigned long
-           after,
-           length;
- 
-         /*
-           Obtain response from primary selection.
-         */
-         if (event.xselection.property == (Atom) None)
-           break;
-         status=XGetWindowProperty(display,event.xselection.requestor,
-           event.xselection.property,0L,2047L,True,XA_STRING,&type,&format,
-           &length,&after,&data);
-         if ((status != Success) || (type != XA_STRING) || (format == 32) ||
-             (length == 0))
-           break;
-         if ((strlen(reply_info.text)+length) >= MaxTextLength)
-           XBell(display,0);
-         else
-           {
-             /*
-               Insert primary selection in reply text.
-             */
-             *(data+length)='\0';
-             XEditText(display,&reply_info,(KeySym) XK_Insert,(char *) data,
-               state);
-             XDrawMatteText(display,&windows->popup,&reply_info);
-             state|=RedrawActionState;
-           }
-         XFree((void *) data);
-         break;
-       }
-       case SelectionRequest:
-       {
-         XSelectionEvent
-           notify;
- 
-         XSelectionRequestEvent
-           *request;
- 
-         if (!reply_info.highlight)
-           break;
-         /*
-           Set primary selection.
-         */
-         request=(&(event.xselectionrequest));
-         XChangeProperty(request->display,request->requestor,request->property,
-           request->target,8,PropModeReplace,(unsigned char *) primary_selection,
-           strlen(primary_selection));
-         notify.type=SelectionNotify;
-         notify.send_event=True;
-         notify.display=request->display;
-         notify.requestor=request->requestor;
-         notify.selection=request->selection;
-         notify.target=request->target;
-         notify.time=request->time;
-         if (request->property == None)
-           notify.property=request->target;
-         else
-           notify.property=request->property;
-         (void) XSendEvent(request->display,request->requestor,False,NoEventMask,
-           (XEvent *) &notify);
-       }
-       default:
-         break;
-     }
-   } while (!(state & ExitState));
-   XDefineCursor(display,windows->image.id,windows->image.cursor);
-   XWithdrawWindow(display,windows->popup.id,windows->popup.screen);
-   XCheckRefreshWindow(display,&windows->image);
- }
- 
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %                                                                             %
- %                                                                             %
- %                                                                             %
  %   X M e n u W i d g e t                                                     %
  %                                                                             %
  %                                                                             %
--- 5775,5780 ----
***************
*** 7002,7008 ****
    XChangeWindowAttributes(display,windows->popup.id,CWOverrideRedirect,
      &window_attributes);
    XWithdrawWindow(display,windows->popup.id,windows->popup.screen);
-   XCheckRefreshWindow(display,&windows->image);
    if ((selection_info.id < 0) || (selection_info.id >= number_selections))
      return(~0);
    (void) strcpy(item,selections[selection_info.id]);
--- 6126,6131 ----
***************
*** 7323,7329 ****
    } while (!(state & ExitState));
    XDefineCursor(display,windows->image.id,windows->image.cursor);
    XWithdrawWindow(display,windows->popup.id,windows->popup.screen);
-   XCheckRefreshWindow(display,&windows->image);
  }
  
  /*
--- 6446,6451 ----
***************
*** 7370,7378 ****
  {
  #define DismissButtonText  "Dismiss"
  
-   char
-     primary_selection[MaxTextLength];
- 
    int
      x,
      y;
--- 6492,6497 ----
***************
*** 7705,7751 ****
              XDrawBeveledButton(display,&windows->popup,&dismiss_info);
              break;
            }
-         if (MatteIsActive(list_info,event.xbutton))
-           {
-             unsigned int
-               id;
- 
-             static Time
-               click_time;
- 
-             /*
-               User pressed list matte.
-             */
-             id=slider_info.id+(event.xbutton.y-(list_info.y+(height >> 1))+1)/
-               selection_info.height;
-             if (id >= lines)
-               break;
-             if (id != list_info.id)
-               {
-                 list_info.id=id;
-                 click_time=event.xbutton.time;
-                 break;
-               }
-             list_info.id=id;
-             if (event.xbutton.time >= (click_time+DoubleClick))
-               {
-                 click_time=event.xbutton.time;
-                 break;
-               }
-             click_time=event.xbutton.time;
-             /*
-               Become the XA_PRIMARY selection owner.
-             */
-             (void) strcpy(primary_selection,textlist[list_info.id]);
-             XSetSelectionOwner(display,XA_PRIMARY,windows->popup.id,
-               event.xbutton.time);
-             if (XGetSelectionOwner(display,XA_PRIMARY) != windows->popup.id)
-               break;
-             selection_info.id=(~0);
-             list_info.id=id;
-             state|=RedrawListState;
-             break;
-           }
          break;
        }
        case ButtonRelease:
--- 6824,6829 ----
***************
*** 7960,8003 ****
            }
          break;
        }
-       case SelectionClear:
-       {
-         list_info.id=(~0);
-         selection_info.id=(~0);
-         state|=RedrawListState;
-         break;
-       }
-       case SelectionRequest:
-       {
-         XSelectionEvent
-           notify;
- 
-         XSelectionRequestEvent
-           *request;
- 
-         if (list_info.id == (~0))
-           break;
-         /*
-           Set primary selection.
-         */
-         request=(&(event.xselectionrequest));
-         XChangeProperty(request->display,request->requestor,request->property,
-           request->target,8,PropModeReplace,(unsigned char *) primary_selection,
-           strlen(primary_selection));
-         notify.type=SelectionNotify;
-         notify.send_event=True;
-         notify.display=request->display;
-         notify.requestor=request->requestor;
-         notify.selection=request->selection;
-         notify.target=request->target;
-         notify.time=request->time;
-         if (request->property == None)
-           notify.property=request->target;
-         else
-           notify.property=request->property;
-         (void) XSendEvent(request->display,request->requestor,False,NoEventMask,
-           (XEvent *) &notify);
-       }
        default:
          break;
      }
--- 7038,7043 ----
***************
*** 8004,8008 ****
    } while (!(state & ExitState));
    XDefineCursor(display,windows->image.id,windows->image.cursor);
    XWithdrawWindow(display,windows->popup.id,windows->popup.screen);
-   XCheckRefreshWindow(display,&windows->image);
  }
--- 7044,7047 ----
diff -c -r ImageMagick-3.1/magick/widget.h ImageMagick/magick/widget.h
*** ImageMagick-3.1/magick/widget.h	Wed Jul 13 10:52:14 1994
--- ImageMagick/magick/widget.h	Mon May 23 16:44:32 1994
***************
*** 50,56 ****
      char *)),
    XFileBrowserWidget _Declare((Display *,XWindows *,char *,char *)),
    XFontBrowserWidget _Declare((Display *,XWindows *,char *,char *)),
-   XListBrowserWidget _Declare((Display *,XWindows *,char **,char *,char *,
-     char *)),
    XNoticeWidget _Declare((Display *,XWindows *,char *,char *)),
    XTextViewWidget _Declare((Display *,XWindows *,char *,char **));
--- 50,54 ----
diff -c -r ImageMagick-3.1/mogrify.c ImageMagick/mogrify.c
*** ImageMagick-3.1/mogrify.c	Wed Jul 13 10:52:10 1994
--- ImageMagick/mogrify.c	Fri Jun  3 15:17:33 1994
***************
*** 51,65 ****
  %
  %  Where options include:
  %    -blur                apply a filter to blur the image
- %    -brighten            brighten or darken an image
  %    -border geometry     surround image with a border of color
  %    -colormap filename   transform image colors to match this set of colors
  %    -colors value        preferred number of colors in the image
  %    -colorspace type     GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV
  %    -comment string      annotate image with comment
  %    -compress type       RunlengthEncoded or QEncoded
- %    -contrast            enhance or reduce the image contrast
- %    -crop geometry       preferred size and location of the cropped image
  %    -density geometry    vertical and horizontal density of the image
  %    -despeckle           reduce the speckles within an image",
  %    -display server      obtain image or font from this X server
--- 51,63 ----
  %
  %  Where options include:
  %    -blur                apply a filter to blur the image
  %    -border geometry     surround image with a border of color
+ %    -clip geometry       preferred size and location of the clipped image
  %    -colormap filename   transform image colors to match this set of colors
  %    -colors value        preferred number of colors in the image
  %    -colorspace type     GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV
  %    -comment string      annotate image with comment
  %    -compress type       RunlengthEncoded or QEncoded
  %    -density geometry    vertical and horizontal density of the image
  %    -despeckle           reduce the speckles within an image",
  %    -display server      obtain image or font from this X server
***************
*** 82,88 ****
  %    -quality value       JPEG quality setting
  %    -roll geometry       roll an image vertically or horizontally
  %    -rotate degrees      apply Paeth rotation to the image
- %    -saturate value      percent increase or decrease in color saturation
  %    -scene value         image scene number
  %    -sharpen             apply a filter to sharpen the image
  %    -shear geometry      slide one edge of the image along the X or Y axis
--- 80,85 ----
***************
*** 137,151 ****
      *options[]=
      {
        "-blur                apply a filter to blur the image",
-       "-brighten            brighten or darken an image",
        "-border geometry     surround image with a border of color",
        "-colormap filename   transform image colors to match this set of colors",
        "-colors value        preferred number of colors in the image",
        "-colorspace type     GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV",
        "-comment string      annotate image with comment",
        "-compress type       RunlengthEncoded or QEncoded",
-       "-contrast            enhance or reduce the image contrast",
-       "-crop geometry       preferred size and location of the cropped image",
        "-density geometry    vertical and horizontal density of the image",
        "-despeckle           reduce the speckles within an image",
        "-display server      obtain image or font from this X server",
--- 134,146 ----
      *options[]=
      {
        "-blur                apply a filter to blur the image",
        "-border geometry     surround image with a border of color",
+       "-clip geometry       preferred size and location of the clipped image",
        "-colormap filename   transform image colors to match this set of colors",
        "-colors value        preferred number of colors in the image",
        "-colorspace type     GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV",
        "-comment string      annotate image with comment",
        "-compress type       RunlengthEncoded or QEncoded",
        "-density geometry    vertical and horizontal density of the image",
        "-despeckle           reduce the speckles within an image",
        "-display server      obtain image or font from this X server",
***************
*** 168,174 ****
        "-quality value       JPEG quality setting",
        "-roll geometry       roll an image vertically or horizontally",
        "-rotate degrees      apply Paeth rotation to the image",
-       "-saturate value      percent increase or decrease in color saturation",
        "-scene number        image scene number",
        "-sharpen             apply a filter to sharpen the image",
        "-shear geometry      slide one edge of the image along the X or Y axis",
--- 163,168 ----
***************
*** 222,230 ****
      *border_color,
      *colormap_filename,
      *comment,
      *gamma,
      *label,
!     *option;
  
    ColorPacket
      border_packet;
--- 216,230 ----
      *border_color,
      *colormap_filename,
      *comment,
+     *density,
+     *font,
      *gamma,
+     *image_geometry,
      *label,
!     *option,
!     *page_geometry,
!     *server_name,
!     *undercolor_geometry;
  
    ColorPacket
      border_packet;
***************
*** 238,244 ****
    int
      flags,
      i,
!     j,
      x,
      y;
  
--- 238,245 ----
    int
      flags,
      i,
!     p,
!     q,
      x,
      y;
  
***************
*** 245,256 ****
--- 246,262 ----
    unsigned int
      colorspace,
      compression,
+     dither,
      height,
      image_number,
+     interlace,
      maximum_images,
+     monochrome,
      number_colors,
+     quality,
      scene,
      tree_depth,
+     verbose,
      width;
  
    /*
***************
*** 270,281 ****
    colorspace=RGBColorspace;
    comment=(char *) NULL;
    compression=UndefinedCompression;
    gamma=(char *) NULL;
!   GetImageInfo(&image_info);
    label=(char *) NULL;
    number_colors=0;
    scene=0;
    tree_depth=0;
    maximum_images=MaxTextLength;
    images=(Image **) malloc(maximum_images*sizeof(Image *));
    if (images == (Image **) NULL)
--- 276,297 ----
    colorspace=RGBColorspace;
    comment=(char *) NULL;
    compression=UndefinedCompression;
+   density=(char *) NULL;
+   dither=False;
+   font=(char *) NULL;
    gamma=(char *) NULL;
!   image_geometry=(char *) NULL;
!   interlace=NoneInterlace;
    label=(char *) NULL;
+   monochrome=False;
    number_colors=0;
+   quality=85;
+   page_geometry=(char *) NULL;
+   server_name=(char *) NULL;
    scene=0;
    tree_depth=0;
+   undercolor_geometry=(char *) NULL;
+   verbose=False;
    maximum_images=MaxTextLength;
    images=(Image **) malloc(maximum_images*sizeof(Image *));
    if (images == (Image **) NULL)
***************
*** 284,289 ****
--- 300,306 ----
      Parse command line.
    */
    image_number=0;
+   p=1;
    for (i=1; i < argc; i++)
    {
      option=argv[i];
***************
*** 316,328 ****
                  }
                break;
              }
-           if (strncmp("brighten",option+1,2) == 0)
-             break;
            Error("Unrecognized option",option);
            break;
          }
          case 'c':
          {
            if (strncmp("colormap",option+1,7) == 0)
              {
                colormap_filename=(char *) NULL;
--- 333,353 ----
                  }
                break;
              }
            Error("Unrecognized option",option);
            break;
          }
          case 'c':
          {
+           if (strncmp("clip",option+1,2) == 0)
+             {
+               if (*option == '-')
+                 {
+                   i++;
+                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
+                     Error("Missing geometry on -clip",(char *) NULL);
+                 }
+               break;
+             }
            if (strncmp("colormap",option+1,7) == 0)
              {
                colormap_filename=(char *) NULL;
***************
*** 411,428 ****
                  }
                break;
              }
-           if (strncmp("contrast",option+1,3) == 0)
-             break;
-           if (strncmp("crop",option+1,2) == 0)
-             {
-               if (*option == '-')
-                 {
-                   i++;
-                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
-                     Error("Missing geometry on -crop",(char *) NULL);
-                 }
-               break;
-             }
            Error("Unrecognized option",option);
            break;
          }
--- 436,441 ----
***************
*** 430,442 ****
          {
            if (strncmp("density",option+1,3) == 0)
              {
!               image_info.density=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -density",(char *) NULL);
!                   image_info.density=argv[i];
                  }
                break;
              }
--- 443,455 ----
          {
            if (strncmp("density",option+1,3) == 0)
              {
!               density=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -density",(char *) NULL);
!                   density=argv[i];
                  }
                break;
              }
***************
*** 444,462 ****
              break;
            if (strncmp("display",option+1,3) == 0)
              {
!               image_info.server_name=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if (i == argc)
                      Error("Missing server name on -display",(char *) NULL);
!                   image_info.server_name=argv[i];
                  }
                break;
              }
            if (strncmp("dither",option+1,3) == 0)
              {
!               image_info.dither=(*option == '-');
                break;
              }
            Error("Unrecognized option",option);
--- 457,475 ----
              break;
            if (strncmp("display",option+1,3) == 0)
              {
!               server_name=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if (i == argc)
                      Error("Missing server name on -display",(char *) NULL);
!                   server_name=argv[i];
                  }
                break;
              }
            if (strncmp("dither",option+1,3) == 0)
              {
!               dither=(*option == '-');
                break;
              }
            Error("Unrecognized option",option);
***************
*** 481,493 ****
              break;
            if (strncmp("font",option+1,2) == 0)
              {
!               image_info.font=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if (i == argc)
                      Error("Missing font name on -font",(char *) NULL);
!                   image_info.font=argv[i];
                  }
              }
            Error("Unrecognized option",option);
--- 494,506 ----
              break;
            if (strncmp("font",option+1,2) == 0)
              {
!               font=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if (i == argc)
                      Error("Missing font name on -font",(char *) NULL);
!                   font=argv[i];
                  }
              }
            Error("Unrecognized option",option);
***************
*** 509,521 ****
              }
            if (strncmp("geometry",option+1,2) == 0)
              {
!               image_info.geometry=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -geometry",(char *) NULL);
!                   image_info.geometry=argv[i];
                  }
                break;
              }
--- 522,534 ----
              }
            if (strncmp("geometry",option+1,2) == 0)
              {
!               image_geometry=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -geometry",(char *) NULL);
!                   image_geometry=argv[i];
                  }
                break;
              }
***************
*** 536,542 ****
          {
            if (strncmp("interlace",option+1,3) == 0)
              {
!               image_info.interlace=NoneInterlace;
                if (*option == '-')
                  {
                    i++;
--- 549,555 ----
          {
            if (strncmp("interlace",option+1,3) == 0)
              {
!               interlace=NoneInterlace;
                if (*option == '-')
                  {
                    i++;
***************
*** 543,556 ****
                    if (i == argc)
                      Error("Missing type on -interlace",(char *) NULL);
                    option=argv[i];
!                   image_info.interlace=UndefinedInterlace;
                    if (Latin1Compare("none",option) == 0)
!                     image_info.interlace=NoneInterlace;
                    if (Latin1Compare("line",option) == 0)
!                     image_info.interlace=LineInterlace;
                    if (Latin1Compare("plane",option) == 0)
!                     image_info.interlace=PlaneInterlace;
!                   if (image_info.interlace == UndefinedInterlace)
                      Error("Invalid interlace type on -interlace",option);
                  }
                break;
--- 556,569 ----
                    if (i == argc)
                      Error("Missing type on -interlace",(char *) NULL);
                    option=argv[i];
!                   interlace=UndefinedInterlace;
                    if (Latin1Compare("none",option) == 0)
!                     interlace=NoneInterlace;
                    if (Latin1Compare("line",option) == 0)
!                     interlace=LineInterlace;
                    if (Latin1Compare("plane",option) == 0)
!                     interlace=PlaneInterlace;
!                   if (interlace == UndefinedInterlace)
                      Error("Invalid interlace type on -interlace",option);
                  }
                break;
***************
*** 577,584 ****
          }
          case 'm':
          {
!           image_info.monochrome=(*option == '-');
!           if (image_info.monochrome)
              {
                number_colors=2;
                tree_depth=8;
--- 590,597 ----
          }
          case 'm':
          {
!           monochrome=(*option == '-');
!           if (monochrome)
              {
                number_colors=2;
                tree_depth=8;
***************
*** 601,613 ****
          {
            if (strncmp("page",option+1,2) == 0)
              {
!               image_info.page=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing page geometry on -page",(char *) NULL);
!                   image_info.page=argv[i];
                  }
                break;
              }
--- 614,626 ----
          {
            if (strncmp("page",option+1,2) == 0)
              {
!               page_geometry=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing page geometry on -page",(char *) NULL);
!                   page_geometry=argv[i];
                  }
                break;
              }
***************
*** 619,625 ****
            i++;
            if ((i == argc) || !sscanf(argv[i],"%d",&x))
              Error("Missing quality on -quality",(char *) NULL);
!           image_info.quality=atoi(argv[i]);;
            break;
          }
          case 'r':
--- 632,638 ----
            i++;
            if ((i == argc) || !sscanf(argv[i],"%d",&x))
              Error("Missing quality on -quality",(char *) NULL);
!           quality=atoi(argv[i]);;
            break;
          }
          case 'r':
***************
*** 649,664 ****
          }
          case 's':
          {
-           if (strncmp("saturate",option+1,2) == 0)
-             {
-               if (*option == '-')
-                 {
-                   i++;
-                   if ((i == argc) || !sscanf(argv[i],"%d",(int *) &x))
-                     Error("Missing value on -saturate",(char *) NULL);
-                 }
-               break;
-             }
            if (strncmp("scene",option+1,3) == 0)
              {
                scene=0;
--- 662,667 ----
***************
*** 702,708 ****
          {
            if (strncmp("undercolor",option+1,2) == 0)
              {
!               image_info.undercolor=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
--- 705,711 ----
          {
            if (strncmp("undercolor",option+1,2) == 0)
              {
!               undercolor_geometry=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
***************
*** 709,715 ****
                    if ((i == argc) || !sscanf(argv[i],"%f",(float *) &x))
                      Error("Missing undercolor geometry on -undercolor",
                        (char *) NULL);
!                   image_info.undercolor=argv[i];
                  }
                break;
              }
--- 712,718 ----
                    if ((i == argc) || !sscanf(argv[i],"%f",(float *) &x))
                      Error("Missing undercolor geometry on -undercolor",
                        (char *) NULL);
!                   undercolor_geometry=argv[i];
                  }
                break;
              }
***************
*** 718,724 ****
          }
          case 'v':
          {
!           image_info.verbose=(*option == '-');
            break;
          }
          default:
--- 721,727 ----
          }
          case 'v':
          {
!           verbose=(*option == '-');
            break;
          }
          default:
***************
*** 751,757 ****
            Option is a file name: begin by reading image from specified file.
          */
          start_time=time((time_t *) NULL);
!         (void) strcpy(image_info.filename,argv[i]);
          image=ReadImage(&image_info);
          if (image == (Image *) NULL)
            if (*option == '-')
--- 754,770 ----
            Option is a file name: begin by reading image from specified file.
          */
          start_time=time((time_t *) NULL);
!         GetImageInfo(argv[i],&image_info);
!         image_info.server_name=server_name;
!         image_info.font=font;
!         image_info.geometry=image_geometry;
!         image_info.page=page_geometry;
!         image_info.density=density;
!         image_info.interlace=interlace;
!         image_info.monochrome=monochrome;
!         image_info.quality=quality;
!         image_info.verbose=verbose;
!         image_info.undercolor=undercolor_geometry;
          image=ReadImage(&image_info);
          if (image == (Image *) NULL)
            if (*option == '-')
***************
*** 770,778 ****
            /*
              Transform image as defined by the image geometries.
            */
!           for (j=1; j < i; j++)
            {
!             option=argv[j];
              if (strncmp("-blur",option,3) == 0)
                {
                  Image
--- 783,791 ----
            /*
              Transform image as defined by the image geometries.
            */
!           for (q=p; q < i; q++)
            {
!             option=argv[q];
              if (strncmp("-blur",option,3) == 0)
                {
                  Image
***************
*** 801,807 ****
                  */
                  border_info.width=0;
                  border_info.height=0;
!                 flags=XParseGeometry(argv[++j],&border_info.x,&border_info.y,
                    &border_info.width,&border_info.height);
                  if ((flags & HeightValue) == 0)
                    border_info.height=border_info.width;
--- 814,820 ----
                  */
                  border_info.width=0;
                  border_info.height=0;
!                 flags=XParseGeometry(argv[++q],&border_info.x,&border_info.y,
                    &border_info.width,&border_info.height);
                  if ((flags & HeightValue) == 0)
                    border_info.height=border_info.width;
***************
*** 839,854 ****
                      XCloseDisplay(display);
                    }
                }
!             if (strncmp("-brighten",option,3) == 0)
!               GammaImage(image,"1.25");
!             if (strncmp("+brighten",option,3) == 0)
!               GammaImage(image,"0.75");
!             if (strncmp("-contrast",option,4) == 0)
!               ContrastImage(image,True);
!             if (strncmp("+contrast",option,4) == 0)
!               ContrastImage(image,False);
!             if (strncmp("-crop",option,3) == 0)
!               TransformImage(&image,argv[++j],(char *) NULL);
              if (strncmp("-despeckle",option,4) == 0)
                {
                  Image
--- 852,859 ----
                      XCloseDisplay(display);
                    }
                }
!             if (strncmp("-clip",option,3) == 0)
!               TransformImage(&image,argv[++q],(char *) NULL);
              if (strncmp("-despeckle",option,4) == 0)
                {
                  Image
***************
*** 927,935 ****
                    }
                }
              if (strncmp("-gamma",option,3) == 0)
!               GammaImage(image,argv[++j]);
              if (strncmp("-geometry",option,4) == 0)
!               TransformImage(&image,(char *) NULL,argv[++j]);
              if (strncmp("-negate",option,4) == 0)
                NegateImage(image);
              if (strncmp("-noise",option,4) == 0)
--- 932,940 ----
                    }
                }
              if (strncmp("-gamma",option,3) == 0)
!               GammaImage(image,argv[++q]);
              if (strncmp("-geometry",option,4) == 0)
!               TransformImage(&image,(char *) NULL,argv[++q]);
              if (strncmp("-negate",option,4) == 0)
                NegateImage(image);
              if (strncmp("-noise",option,4) == 0)
***************
*** 959,965 ****
                  */
                  x=0;
                  y=0;
!                 flags=XParseGeometry(argv[++j],&x,&y,&width,&height);
                  rolled_image=RollImage(image,x,y);
                  if (rolled_image != (Image *) NULL)
                    {
--- 964,970 ----
                  */
                  x=0;
                  y=0;
!                 flags=XParseGeometry(argv[++q],&x,&y,&width,&height);
                  rolled_image=RollImage(image,x,y);
                  if (rolled_image != (Image *) NULL)
                    {
***************
*** 975,981 ****
                  /*
                    Rotate image.
                  */
!                 rotated_image=RotateImage(image,(double) atof(argv[++j]),
                    &border_packet,False);
                  if (rotated_image != (Image *) NULL)
                    {
--- 980,986 ----
                  /*
                    Rotate image.
                  */
!                 rotated_image=RotateImage(image,(double) atof(argv[++q]),
                    &border_packet,False);
                  if (rotated_image != (Image *) NULL)
                    {
***************
*** 983,990 ****
                      image=rotated_image;
                    }
                }
-             if (strncmp("-saturate",option,4) == 0)
-               SaturateImage(image,atoi(argv[++j]));
              if (strncmp("-sharpen",option,4) == 0)
                {
                  Image
--- 988,993 ----
***************
*** 1014,1020 ****
                  */
                  x_shear=0.0;
                  y_shear=0.0;
!                 (void) sscanf(argv[++j],"%fx%f",&x_shear,&y_shear);
                  sheared_image=ShearImage(image,(double) x_shear,
                    (double) y_shear,&border_packet,False);
                  if (sheared_image != (Image *) NULL)
--- 1017,1023 ----
                  */
                  x_shear=0.0;
                  y_shear=0.0;
!                 (void) sscanf(argv[++q],"%fx%f",&x_shear,&y_shear);
                  sheared_image=ShearImage(image,(double) x_shear,
                    (double) y_shear,&border_packet,False);
                  if (sheared_image != (Image *) NULL)
***************
*** 1032,1040 ****
                if ((image->class == DirectClass) ||
                    (image->colors > number_colors) ||
                    (colorspace == GRAYColorspace))
!                 QuantizeImage(image,number_colors,tree_depth,image_info.dither,
!                   colorspace,True);
!               if (image_info.verbose)
                  {
                    /*
                      Measure quantization error.
--- 1035,1043 ----
                if ((image->class == DirectClass) ||
                    (image->colors > number_colors) ||
                    (colorspace == GRAYColorspace))
!                 QuantizeImage(image,number_colors,tree_depth,dither,colorspace,
!                   True);
!               if (verbose)
                  {
                    /*
                      Measure quantization error.
***************
*** 1045,1051 ****
                  }
                SyncImage(image);
              }
!           if (image_info.verbose)
              {
                /*
                  Display detailed info about the image.
--- 1048,1054 ----
                  }
                SyncImage(image);
              }
!           if (verbose)
              {
                /*
                  Display detailed info about the image.
***************
*** 1097,1102 ****
--- 1100,1106 ----
          } while (next_image != (Image *) NULL);
          if (number_colors == 0)
            DestroyImages(image);
+         p=i+1;
        }
      }
    if (image_number == 0)
***************
*** 1119,1125 ****
          }
        maximum_images=image_number;
        QuantizeImages(images,maximum_images,colormap_image,number_colors,
!         tree_depth,image_info.dither,colorspace,True);
        if (colormap_image != (Image *) NULL)
          DestroyImage(colormap_image);
        for (image_number=0; image_number < maximum_images; image_number++)
--- 1123,1129 ----
          }
        maximum_images=image_number;
        QuantizeImages(images,maximum_images,colormap_image,number_colors,
!         tree_depth,dither,colorspace,True);
        if (colormap_image != (Image *) NULL)
          DestroyImage(colormap_image);
        for (image_number=0; image_number < maximum_images; image_number++)
diff -c -r ImageMagick-3.1/mogrify.man ImageMagick/mogrify.man
*** ImageMagick-3.1/mogrify.man	Wed Jul 13 10:52:17 1994
--- ImageMagick/mogrify.man	Wed Jun  1 22:12:56 1994
***************
*** 33,44 ****
  The color of the border is obtained from the X server and is defined as
  \fBbordercolor\fP (class \fBborderColor\fP).  See \fBX(1)\fP for details.
  .TP 5
! .B "-brighten"
! brighten or darken an image.
  
! This option increases or decreases the intensity of an image.  Use
! \fB-brighten\fP to brighten the image or \fB+brighten\fP to darken the
! image intensity.
  .TP 5
  .B "-colormap \fIfilename\fP"
  choose a particular set of colors from this image.
--- 33,45 ----
  The color of the border is obtained from the X server and is defined as
  \fBbordercolor\fP (class \fBborderColor\fP).  See \fBX(1)\fP for details.
  .TP 5
! .B "-clip \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
! preferred size and location of the clipped image.  See \fBX(1)\fP for details
! about the geometry specification.
  
! Use clipping to apply image processing options, or transmogrify, only a
! particular area of an image.   Use \fB-clip 0x0\fP to remove edges that are
! the background color.
  .TP 5
  .B "-colormap \fIfilename\fP"
  choose a particular set of colors from this image.
***************
*** 106,126 ****
  Specify \fB\+compress\fP to store the binary image in an uncompressed format.
  The default is the compression type of the specified image file.
  .TP 5
- .B "-contrast"
- enhance or reduce the image contrast.
- 
- This option enhances the intensity differences between the
- lighter and darker elements of the image.  Use \fB-contrast\fP to
- enhance the image or \fB+contrast\fP to reduce the image contrast.
- .TP 5
- .B "-crop \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
- preferred size and location of the cropped image.  See \fBX(1)\fP for details
- about the geometry specification.
- 
- Use cropping to apply image processing options, or transmogrify, only a
- particular area of an image.   Use \fB-crop 0x0\fP to remove edges that are
- the background color.
- .TP 5
  .B "-density \fI<width>x<height>
  vertical and horizontal density of the image.
  
--- 107,112 ----
***************
*** 255,261 ****
  picas or a TEXT page in pixels.  The default for a Postscript page is
  to center the image on a letter page 612 by 792 dots per inch.  The
  left and right margins are 18 picas and the top and bottom 94 picas
! (i.e.  612x792+36+36).  Other common sizes are:
  
      540x720   Note
      612x1008  Legal
--- 241,247 ----
  picas or a TEXT page in pixels.  The default for a Postscript page is
  to center the image on a letter page 612 by 792 dots per inch.  The
  left and right margins are 18 picas and the top and bottom 94 picas
! (i.e.  612x792+18+94).  Other common sizes are:
  
      540x720   Note
      612x1008  Legal
***************
*** 293,301 ****
  Empty triangles left over from rotating the image are filled with
  the color defined as \fBbordercolor\fP (class \fBborderColor\fP).
  See \fBX(1)\fP for details.
- .TP 5
- .B "-saturate \fIvalue\fP"
- precent increase or decrease in color saturation.
  .TP 5
  .B "-scene \fIvalue\fP"
  image scene number.
--- 279,284 ----
diff -c -r ImageMagick-3.1/montage.c ImageMagick/montage.c
*** ImageMagick-3.1/montage.c	Wed Jul 13 10:52:10 1994
--- ImageMagick/montage.c	Thu May 26 17:59:28 1994
***************
*** 83,94 ****
  %  Usage: montage [options ...] file [ [options ...] file ...] file
  %
  %  Where options include:
  %    -colors value         preferred number of colors in the image
  %    -colorspace type      GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV
  %    -comment string       annotate image with comment
  %    -compose operator     composite operator
  %    -compress type        RunlengthEncoded or QEncoded
- %    -crop geometry        preferred size and location of the cropped image
  %    -density geometry     vertical and horizontal density of the image
  %    -display server       query fonts from this X server
  %    -dither               apply Floyd/Steinberg error diffusion to image
--- 83,94 ----
  %  Usage: montage [options ...] file [ [options ...] file ...] file
  %
  %  Where options include:
+ %    -clip geometry        preferred size and location of the clipped image
  %    -colors value         preferred number of colors in the image
  %    -colorspace type      GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV
  %    -comment string       annotate image with comment
  %    -compose operator     composite operator
  %    -compress type        RunlengthEncoded or QEncoded
  %    -density geometry     vertical and horizontal density of the image
  %    -display server       query fonts from this X server
  %    -dither               apply Floyd/Steinberg error diffusion to image
***************
*** 695,706 ****
    static char
      *options[]=
      {
        "-colors value         preferred number of colors in the image",
        "-colorspace type      GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV",
        "-comment string       annotate image with comment",
        "-compose operator     composite operator",
        "-compress type        RunlengthEncoded or QEncoded",
-       "-crop geometry        preferred size and location of the cropped image",
        "-density geometry     vertical and horizontal density of the image",
        "-display server       query font from this X server",
        "-dither               apply Floyd/Steinberg error diffusion to image",
--- 695,706 ----
    static char
      *options[]=
      {
+       "-clip geometry        preferred size and location of the clipped image",
        "-colors value         preferred number of colors in the image",
        "-colorspace type      GRAY, OHTA, RGB, XYZ, YCbCr, YIQ, or YUV",
        "-comment string       annotate image with comment",
        "-compose operator     composite operator",
        "-compress type        RunlengthEncoded or QEncoded",
        "-density geometry     vertical and horizontal density of the image",
        "-display server       query font from this X server",
        "-dither               apply Floyd/Steinberg error diffusion to image",
***************
*** 769,779 ****
    **argv;
  {
    char
!     *crop_geometry,
      *comment,
      *gamma,
      *label,
      *option,
      *server_name,
      *write_filename;
  
--- 769,781 ----
    **argv;
  {
    char
!     *clip_geometry,
      *comment,
+     *density,
      *gamma,
      *label,
      *option,
+     *page_geometry,
      *server_name,
      *write_filename;
  
***************
*** 802,811 ****
      first_scene,
      frame,
      image_number,
      last_scene,
      maximum_images,
      scene,
!     tiles_per_row;
  
    XrmDatabase
      resource_database;
--- 804,816 ----
      first_scene,
      frame,
      image_number,
+     interlace,
      last_scene,
+     quality,
      maximum_images,
      scene,
!     tiles_per_row,
!     verbose;
  
    XrmDatabase
      resource_database;
***************
*** 822,840 ****
    /*
      Set defaults.
    */
!   crop_geometry=(char *) NULL;
    comment=(char *) NULL;
    compose=ReplaceCompositeOp;
    compression=UndefinedCompression;
    degrees=0;
    display=(Display *) NULL;
    display_image=True;
    first_scene=0;
    frame=False;
    gamma=(char *) NULL;
!   GetImageInfo(&image_info);
    label=(char *) NULL;
    last_scene=0;
    resource_database=(XrmDatabase) NULL;
    resource_info.border_color=(char *) NULL;
    resource_info.border_width=0;
--- 827,848 ----
    /*
      Set defaults.
    */
!   clip_geometry=(char *) NULL;
    comment=(char *) NULL;
    compose=ReplaceCompositeOp;
    compression=UndefinedCompression;
    degrees=0;
+   density=(char *) NULL;
    display=(Display *) NULL;
    display_image=True;
    first_scene=0;
    frame=False;
    gamma=(char *) NULL;
!   interlace=NoneInterlace;
    label=(char *) NULL;
    last_scene=0;
+   page_geometry=(char *) NULL;
+   quality=85;
    resource_database=(XrmDatabase) NULL;
    resource_info.border_color=(char *) NULL;
    resource_info.border_width=0;
***************
*** 851,856 ****
--- 859,865 ----
    server_name=(char *) NULL;
    start_time=0;
    tiles_per_row=0;
+   verbose=False;
    maximum_images=MaxTextLength;
    images=(Image **) malloc(maximum_images*sizeof(Image *));
    if (images == (Image **) NULL)
***************
*** 919,924 ****
--- 928,935 ----
        resource_value=
          XGetResourceClass(resource_database,client_name,"borderWidth","15");
        resource_info.border_width=atoi(resource_value);
+       clip_geometry=XGetResourceClass(resource_database,client_name,
+         "clipGeometry",(char *) NULL);
        comment=XGetResourceClass(resource_database,client_name,"comment",
          (char *) NULL);
        resource_value=XGetResourceClass(resource_database,client_name,
***************
*** 927,936 ****
          compression=QEncodedCompression;
        else
          compression=RunlengthEncodedCompression;
!       crop_geometry=XGetResourceClass(resource_database,client_name,
!         "cropGeometry",(char *) NULL);
!       image_info.density=XGetResourceClass(resource_database,client_name,
!         "density",(char *) NULL);
        resource_info.foreground_color=XGetResourceInstance(resource_database,
          client_name,"foreground","#600");
        resource_value=
--- 938,945 ----
          compression=QEncodedCompression;
        else
          compression=RunlengthEncodedCompression;
!       density=XGetResourceClass(resource_database,client_name,"density",
!         (char *) NULL);
        resource_info.foreground_color=XGetResourceInstance(resource_database,
          client_name,"foreground","#600");
        resource_value=
***************
*** 940,953 ****
          XGetResourceClass(resource_database,client_name,"gamma",(char *) NULL);
        resource_value=
          XGetResourceClass(resource_database,client_name,"interlace","none");
!       image_info.interlace=UndefinedInterlace;
        if (Latin1Compare("none",resource_value) == 0)
!         image_info.interlace=NoneInterlace;
        if (Latin1Compare("line",resource_value) == 0)
!         image_info.interlace=LineInterlace;
        if (Latin1Compare("plane",resource_value) == 0)
!         image_info.interlace=PlaneInterlace;
!       if (image_info.interlace == UndefinedInterlace)
          Warning("Unrecognized interlace type",resource_value);
        label=XGetResourceClass(resource_database,client_name,"label","%f");
        resource_info.image_geometry=XGetResourceInstance(resource_database,
--- 949,962 ----
          XGetResourceClass(resource_database,client_name,"gamma",(char *) NULL);
        resource_value=
          XGetResourceClass(resource_database,client_name,"interlace","none");
!       interlace=UndefinedInterlace;
        if (Latin1Compare("none",resource_value) == 0)
!         interlace=NoneInterlace;
        if (Latin1Compare("line",resource_value) == 0)
!         interlace=LineInterlace;
        if (Latin1Compare("plane",resource_value) == 0)
!         interlace=PlaneInterlace;
!       if (interlace == UndefinedInterlace)
          Warning("Unrecognized interlace type",resource_value);
        label=XGetResourceClass(resource_database,client_name,"label","%f");
        resource_info.image_geometry=XGetResourceInstance(resource_database,
***************
*** 954,960 ****
          client_name,"imageGeometry","160x160+2+2");
        resource_info.matte_color=XGetResourceInstance(resource_database,
          client_name,"mattecolor","#ccc");
!       image_info.page=XGetResourceClass(resource_database,client_name,
          "pageGeometry",(char *) NULL);
        resource_value=
          XGetResourceClass(resource_database,client_name,"rotate","0");
--- 963,969 ----
          client_name,"imageGeometry","160x160+2+2");
        resource_info.matte_color=XGetResourceInstance(resource_database,
          client_name,"mattecolor","#ccc");
!       page_geometry=XGetResourceClass(resource_database,client_name,
          "pageGeometry",(char *) NULL);
        resource_value=
          XGetResourceClass(resource_database,client_name,"rotate","0");
***************
*** 961,973 ****
        degrees=atoi(resource_value);
        resource_value=
          XGetResourceClass(resource_database,client_name,"quality","85");
!       image_info.quality=atoi(resource_value);
        resource_value=
          XGetResourceClass(resource_database,client_name,"tiles_per_row","0");
        tiles_per_row=atoi(resource_value);
        resource_value=
          XGetResourceClass(resource_database,client_name,"verbose","False");
!       image_info.verbose=IsTrue(resource_value);
      }
    /*
      Composite image is the last item on the command line.
--- 970,982 ----
        degrees=atoi(resource_value);
        resource_value=
          XGetResourceClass(resource_database,client_name,"quality","85");
!       quality=atoi(resource_value);
        resource_value=
          XGetResourceClass(resource_database,client_name,"tiles_per_row","0");
        tiles_per_row=atoi(resource_value);
        resource_value=
          XGetResourceClass(resource_database,client_name,"verbose","False");
!       verbose=IsTrue(resource_value);
      }
    /*
      Composite image is the last item on the command line.
***************
*** 1036,1041 ****
--- 1045,1062 ----
          }
          case 'c':
          {
+           if (strncmp("clip",option+1,2) == 0)
+             {
+               clip_geometry=(char *) NULL;
+               if (*option == '-')
+                 {
+                   i++;
+                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
+                     Error("Missing geometry on -clip",(char *) NULL);
+                   clip_geometry=argv[i];
+                 }
+               break;
+             }
            if (strncmp("colors",option+1,7) == 0)
              {
                resource_info.number_colors=0;
***************
*** 1149,1166 ****
                  }
                break;
              }
-           if (strncmp("crop",option+1,2) == 0)
-             {
-               crop_geometry=(char *) NULL;
-               if (*option == '-')
-                 {
-                   i++;
-                   if ((i == argc) || !sscanf(argv[i],"%d",&x))
-                     Error("Missing geometry on -crop",(char *) NULL);
-                   crop_geometry=argv[i];
-                 }
-               break;
-             }
            Error("Unrecognized option",option);
            break;
          }
--- 1170,1175 ----
***************
*** 1168,1180 ****
          {
            if (strncmp("density",option+1,3) == 0)
              {
!               image_info.density=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -density",(char *) NULL);
!                   image_info.density=argv[i];
                  }
                break;
              }
--- 1177,1189 ----
          {
            if (strncmp("density",option+1,3) == 0)
              {
!               density=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -density",(char *) NULL);
!                   density=argv[i];
                  }
                break;
              }
***************
*** 1312,1318 ****
          {
            if (strncmp("interlace",option+1,3) == 0)
              {
!               image_info.interlace=NoneInterlace;
                if (*option == '-')
                  {
                    i++;
--- 1321,1327 ----
          {
            if (strncmp("interlace",option+1,3) == 0)
              {
!               interlace=NoneInterlace;
                if (*option == '-')
                  {
                    i++;
***************
*** 1319,1332 ****
                    if (i == argc)
                      Error("Missing type on -interlace",(char *) NULL);
                    option=argv[i];
!                   image_info.interlace=UndefinedInterlace;
                    if (Latin1Compare("none",option) == 0)
!                     image_info.interlace=NoneInterlace;
                    if (Latin1Compare("line",option) == 0)
!                     image_info.interlace=LineInterlace;
                    if (Latin1Compare("plane",option) == 0)
!                     image_info.interlace=PlaneInterlace;
!                   if (image_info.interlace == UndefinedInterlace)
                      Error("Invalid interlace type on -interlace",option);
                  }
                break;
--- 1328,1341 ----
                    if (i == argc)
                      Error("Missing type on -interlace",(char *) NULL);
                    option=argv[i];
!                   interlace=UndefinedInterlace;
                    if (Latin1Compare("none",option) == 0)
!                     interlace=NoneInterlace;
                    if (Latin1Compare("line",option) == 0)
!                     interlace=LineInterlace;
                    if (Latin1Compare("plane",option) == 0)
!                     interlace=PlaneInterlace;
!                   if (interlace == UndefinedInterlace)
                      Error("Invalid interlace type on -interlace",option);
                  }
                break;
***************
*** 1383,1395 ****
          {
            if (strncmp("page",option+1,2) == 0)
              {
!               image_info.page=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing page geometry on -page",(char *) NULL);
!                   image_info.page=argv[i];
                  }
                break;
              }
--- 1392,1404 ----
          {
            if (strncmp("page",option+1,2) == 0)
              {
!               page_geometry=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing page geometry on -page",(char *) NULL);
!                   page_geometry=argv[i];
                  }
                break;
              }
***************
*** 1401,1407 ****
            i++;
            if ((i == argc) || !sscanf(argv[i],"%d",&x))
              Error("Missing quality on -quality",(char *) NULL);
!           image_info.quality=atoi(argv[i]);
            break;
          }
          case 'r':
--- 1410,1416 ----
            i++;
            if ((i == argc) || !sscanf(argv[i],"%d",&x))
              Error("Missing quality on -quality",(char *) NULL);
!           quality=atoi(argv[i]);
            break;
          }
          case 'r':
***************
*** 1479,1485 ****
          }
          case 'v':
          {
!           image_info.verbose=(*option == '-');
            break;
          }
          default:
--- 1488,1494 ----
          }
          case 'v':
          {
!           verbose=(*option == '-');
            break;
          }
          default:
***************
*** 1499,1505 ****
            Option is a file name: begin by reading image from specified file.
          */
          start_time=time((time_t *) NULL);
!         (void) strcpy(image_info.filename,argv[i]);
          if (first_scene != last_scene)
            {
              char
--- 1508,1514 ----
            Option is a file name: begin by reading image from specified file.
          */
          start_time=time((time_t *) NULL);
!         GetImageInfo(argv[i],&image_info);
          if (first_scene != last_scene)
            {
              char
***************
*** 1516,1523 ****
          image_info.server_name=resource_info.server_name;
          image_info.font=resource_info.font;
          image_info.geometry=resource_info.image_geometry;
!         image_info.dither=resource_info.dither;
          image_info.monochrome=resource_info.monochrome;
          image=ReadImage(&image_info);
          if (image == (Image *) NULL)
            if (*option == '-')
--- 1525,1536 ----
          image_info.server_name=resource_info.server_name;
          image_info.font=resource_info.font;
          image_info.geometry=resource_info.image_geometry;
!         image_info.page=page_geometry;
!         image_info.density=density;
!         image_info.interlace=interlace;
          image_info.monochrome=resource_info.monochrome;
+         image_info.quality=quality;
+         image_info.verbose=verbose;
          image=ReadImage(&image_info);
          if (image == (Image *) NULL)
            if (*option == '-')
***************
*** 1534,1542 ****
              Tile size maintains the aspect ratio of the image.
            */
            if (resource_info.image_geometry == (char *) NULL)
!             TransformImage(&image,crop_geometry,"256x256");
            else
!             TransformImage(&image,crop_geometry,resource_info.image_geometry);
            if ((degrees % 360) != 0)
              {
                Colormap
--- 1547,1555 ----
              Tile size maintains the aspect ratio of the image.
            */
            if (resource_info.image_geometry == (char *) NULL)
!             TransformImage(&image,clip_geometry,"256x256");
            else
!             TransformImage(&image,clip_geometry,resource_info.image_geometry);
            if ((degrees % 360) != 0)
              {
                Colormap
***************
*** 1570,1576 ****
              }
            if (gamma != (char *) NULL)
              GammaImage(image,gamma);
!           if (image_info.verbose)
              {
                /*
                  Display detailed info about the image.
--- 1583,1589 ----
              }
            if (gamma != (char *) NULL)
              GammaImage(image,gamma);
!           if (verbose)
              {
                /*
                  Display detailed info about the image.
***************
*** 1632,1638 ****
    if (comment != (char *) NULL)
      CommentImage(montage_image,comment);
    (void) WriteImage(&image_info,montage_image);
!   if (image_info.verbose)
      {
        /*
          Display detailed info about the image.
--- 1645,1651 ----
    if (comment != (char *) NULL)
      CommentImage(montage_image,comment);
    (void) WriteImage(&image_info,montage_image);
!   if (verbose)
      {
        /*
          Display detailed info about the image.
diff -c -r ImageMagick-3.1/montage.man ImageMagick/montage.man
*** ImageMagick-3.1/montage.man	Wed Jul 13 10:52:16 1994
--- ImageMagick/montage.man	Wed Jun  1 22:12:56 1994
***************
*** 73,78 ****
--- 73,88 ----
       montage -geometry 640x480 -bordercolor black -label "" parrot.miff bird.miff
  .SH OPTIONS
  .TP 5
+ .B "-clip \fI<width>x<height>+<x offset>+<y offset>\fP"
+ preferred size and location of the clipped image.  See \fBX(1)\fP for details
+ about the geometry specification.
+ 
+ Use clipping to tile only a particular area of an image.  Use \fB-clip
+ 0x0\fP to remove edges that are the background color.
+ 
+ The equivalent X resource for this option is \fBclipGeometry\fP
+ (class \fBClipGeometry\fP).  See \fBX RESOURCES\fP for details.
+ .TP 5
  .B "-colors \fIvalue\fP"
  preferred number of colors in the image.
  
***************
*** 165,175 ****
  .TP 9
  .B plus
  The result is just the sum of the image data.  Output values are
! cropped to 255 (no overflow).  This operation is independent
  of the matte channels.
  .TP 9
  .B minus
! The result of \fIimage\fP \- \fIcomposite image\fP, with underflow cropped
  to zero.  The matte channel is ignored (set to 255, full coverage).
  .TP 9
  .B add
--- 175,185 ----
  .TP 9
  .B plus
  The result is just the sum of the image data.  Output values are
! clipped to 255 (no overflow).  This operation is independent
  of the matte channels.
  .TP 9
  .B minus
! The result of \fIimage\fP \- \fIcomposite image\fP, with underflow clipped
  to zero.  The matte channel is ignored (set to 255, full coverage).
  .TP 9
  .B add
***************
*** 207,222 ****
  Specify \fB\+compress\fP to store the binary image in an uncompressed format.
  The default is the compression type of the specified image file.
  .TP 5
- .B "-crop \fI<width>x<height>+<x offset>+<y offset>\fP"
- preferred size and location of the cropped image.  See \fBX(1)\fP for details
- about the geometry specification.
- 
- Use cropping to tile only a particular area of an image.  Use \fB-crop
- 0x0\fP to remove edges that are the background color.
- 
- The equivalent X resource for this option is \fBcropGeometry\fP
- (class \fBCropGeometry\fP).  See \fBX RESOURCES\fP for details.
- .TP 5
  .B "-density \fI<width>x<height>
  vertical and horizontal density of the image.
  
--- 217,222 ----
***************
*** 329,335 ****
  picas or a TEXT page in pixels.  The default for a Postscript page is
  to center the image on a letter page 612 by 792 dots per inch.  The
  left and right margins are 18 picas and the top and bottom 94 picas
! (i.e.  612x792+36+36).  Other common sizes are:
  
      540x720   Note
      612x1008  Legal
--- 329,335 ----
  picas or a TEXT page in pixels.  The default for a Postscript page is
  to center the image on a letter page 612 by 792 dots per inch.  The
  left and right margins are 18 picas and the top and bottom 94 picas
! (i.e.  612x792+18+94).  Other common sizes are:
  
      540x720   Note
      612x1008  Legal
diff -c -r ImageMagick-3.1/scenes/Makefile ImageMagick/scenes/Makefile
*** ImageMagick-3.1/scenes/Makefile	Wed Jul 13 10:52:09 1994
--- ImageMagick/scenes/Makefile	Wed Nov 10 17:59:27 1993
***************
*** 2,81 ****
  # POV Makefile for DNA molecule.
  #
  all:
! 	povray +Idna.script +Odna.1 +ft +W256 +H256 -Q9 +R5 +A +J +V -K0
! 	povray +Idna.script +Odna.2 +ft +W256 +H256 -Q9 +R5 +A +J +V -K5
! 	povray +Idna.script +Odna.3 +ft +W256 +H256 -Q9 +R5 +A +J +V -K10
! 	povray +Idna.script +Odna.4 +ft +W256 +H256 -Q9 +R5 +A +J +V -K15
! 	povray +Idna.script +Odna.5 +ft +W256 +H256 -Q9 +R5 +A +J +V -K20
! 	povray +Idna.script +Odna.6 +ft +W256 +H256 -Q9 +R5 +A +J +V -K25
! 	povray +Idna.script +Odna.7 +ft +W256 +H256 -Q9 +R5 +A +J +V -K30
! 	povray +Idna.script +Odna.8 +ft +W256 +H256 -Q9 +R5 +A +J +V -K35
! 	povray +Idna.script +Odna.9 +ft +W256 +H256 -Q9 +R5 +A +J +V -K40
! 	povray +Idna.script +Odna.10 +ft +W256 +H256 -Q9 +R5 +A +J +V -K45
! 	povray +Idna.script +Odna.11 +ft +W256 +H256 -Q9 +R5 +A +J +V -K50
! 	povray +Idna.script +Odna.12 +ft +W256 +H256 -Q9 +R5 +A +J +V -K55
! 	povray +Idna.script +Odna.13 +ft +W256 +H256 -Q9 +R5 +A +J +V -K60
! 	povray +Idna.script +Odna.14 +ft +W256 +H256 -Q9 +R5 +A +J +V -K65
! 	povray +Idna.script +Odna.15 +ft +W256 +H256 -Q9 +R5 +A +J +V -K70
! 	povray +Idna.script +Odna.16 +ft +W256 +H256 -Q9 +R5 +A +J +V -K75
! 	povray +Idna.script +Odna.17 +ft +W256 +H256 -Q9 +R5 +A +J +V -K80
! 	povray +Idna.script +Odna.18 +ft +W256 +H256 -Q9 +R5 +A +J +V -K85
! 	povray +Idna.script +Odna.19 +ft +W256 +H256 -Q9 +R5 +A +J +V -K90
! 	povray +Idna.script +Odna.20 +ft +W256 +H256 -Q9 +R5 +A +J +V -K95
! 	povray +Idna.script +Odna.21 +ft +W256 +H256 -Q9 +R5 +A +J +V -K100
! 	povray +Idna.script +Odna.22 +ft +W256 +H256 -Q9 +R5 +A +J +V -K105
! 	povray +Idna.script +Odna.23 +ft +W256 +H256 -Q9 +R5 +A +J +V -K110
! 	povray +Idna.script +Odna.24 +ft +W256 +H256 -Q9 +R5 +A +J +V -K115
! 	povray +Idna.script +Odna.25 +ft +W256 +H256 -Q9 +R5 +A +J +V -K120
! 	povray +Idna.script +Odna.26 +ft +W256 +H256 -Q9 +R5 +A +J +V -K125
! 	povray +Idna.script +Odna.27 +ft +W256 +H256 -Q9 +R5 +A +J +V -K130
! 	povray +Idna.script +Odna.28 +ft +W256 +H256 -Q9 +R5 +A +J +V -K135
! 	povray +Idna.script +Odna.29 +ft +W256 +H256 -Q9 +R5 +A +J +V -K140
! 	povray +Idna.script +Odna.30 +ft +W256 +H256 -Q9 +R5 +A +J +V -K145
! 	povray +Idna.script +Odna.31 +ft +W256 +H256 -Q9 +R5 +A +J +V -K150
! 	povray +Idna.script +Odna.32 +ft +W256 +H256 -Q9 +R5 +A +J +V -K155
! 	povray +Idna.script +Odna.33 +ft +W256 +H256 -Q9 +R5 +A +J +V -K160
! 	povray +Idna.script +Odna.34 +ft +W256 +H256 -Q9 +R5 +A +J +V -K165
! 	povray +Idna.script +Odna.35 +ft +W256 +H256 -Q9 +R5 +A +J +V -K170
! 	povray +Idna.script +Odna.36 +ft +W256 +H256 -Q9 +R5 +A +J +V -K175
! 	povray +Idna.script +Odna.37 +ft +W256 +H256 -Q9 +R5 +A +J +V -K180
! 	povray +Idna.script +Odna.38 +ft +W256 +H256 -Q9 +R5 +A +J +V -K185
! 	povray +Idna.script +Odna.39 +ft +W256 +H256 -Q9 +R5 +A +J +V -K190
! 	povray +Idna.script +Odna.40 +ft +W256 +H256 -Q9 +R5 +A +J +V -K195
! 	povray +Idna.script +Odna.41 +ft +W256 +H256 -Q9 +R5 +A +J +V -K200
! 	povray +Idna.script +Odna.42 +ft +W256 +H256 -Q9 +R5 +A +J +V -K205
! 	povray +Idna.script +Odna.43 +ft +W256 +H256 -Q9 +R5 +A +J +V -K210
! 	povray +Idna.script +Odna.44 +ft +W256 +H256 -Q9 +R5 +A +J +V -K215
! 	povray +Idna.script +Odna.45 +ft +W256 +H256 -Q9 +R5 +A +J +V -K220
! 	povray +Idna.script +Odna.46 +ft +W256 +H256 -Q9 +R5 +A +J +V -K225
! 	povray +Idna.script +Odna.47 +ft +W256 +H256 -Q9 +R5 +A +J +V -K230
! 	povray +Idna.script +Odna.48 +ft +W256 +H256 -Q9 +R5 +A +J +V -K235
! 	povray +Idna.script +Odna.49 +ft +W256 +H256 -Q9 +R5 +A +J +V -K240
! 	povray +Idna.script +Odna.50 +ft +W256 +H256 -Q9 +R5 +A +J +V -K245
! 	povray +Idna.script +Odna.51 +ft +W256 +H256 -Q9 +R5 +A +J +V -K250
! 	povray +Idna.script +Odna.52 +ft +W256 +H256 -Q9 +R5 +A +J +V -K255
! 	povray +Idna.script +Odna.53 +ft +W256 +H256 -Q9 +R5 +A +J +V -K260
! 	povray +Idna.script +Odna.54 +ft +W256 +H256 -Q9 +R5 +A +J +V -K265
! 	povray +Idna.script +Odna.55 +ft +W256 +H256 -Q9 +R5 +A +J +V -K270
! 	povray +Idna.script +Odna.56 +ft +W256 +H256 -Q9 +R5 +A +J +V -K275
! 	povray +Idna.script +Odna.57 +ft +W256 +H256 -Q9 +R5 +A +J +V -K280
! 	povray +Idna.script +Odna.58 +ft +W256 +H256 -Q9 +R5 +A +J +V -K285
! 	povray +Idna.script +Odna.59 +ft +W256 +H256 -Q9 +R5 +A +J +V -K290
! 	povray +Idna.script +Odna.60 +ft +W256 +H256 -Q9 +R5 +A +J +V -K295
! 	povray +Idna.script +Odna.61 +ft +W256 +H256 -Q9 +R5 +A +J +V -K300
! 	povray +Idna.script +Odna.62 +ft +W256 +H256 -Q9 +R5 +A +J +V -K305
! 	povray +Idna.script +Odna.63 +ft +W256 +H256 -Q9 +R5 +A +J +V -K310
! 	povray +Idna.script +Odna.64 +ft +W256 +H256 -Q9 +R5 +A +J +V -K315
! 	povray +Idna.script +Odna.65 +ft +W256 +H256 -Q9 +R5 +A +J +V -K320
! 	povray +Idna.script +Odna.66 +ft +W256 +H256 -Q9 +R5 +A +J +V -K325
! 	povray +Idna.script +Odna.67 +ft +W256 +H256 -Q9 +R5 +A +J +V -K330
! 	povray +Idna.script +Odna.68 +ft +W256 +H256 -Q9 +R5 +A +J +V -K335
! 	povray +Idna.script +Odna.69 +ft +W256 +H256 -Q9 +R5 +A +J +V -K340
! 	povray +Idna.script +Odna.70 +ft +W256 +H256 -Q9 +R5 +A +J +V -K345
! 	povray +Idna.script +Odna.71 +ft +W256 +H256 -Q9 +R5 +A +J +V -K350
! 	povray +Idna.script +Odna.72 +ft +W256 +H256 -Q9 +R5 +A +J +V -K355
  	cat dna.[0-9] dna.[0-9][0-9] | convert tga:- miff:dna
- 	/bin/rm dna.72
  	mogrify -verbose -colors 256 dna.[0-9]*
  
  clean:
--- 2,80 ----
  # POV Makefile for DNA molecule.
  #
  all:
! 	povray +Idna.script +Odna.1 -ft +W256 +H256 -Q9 +R5 +A +J +V -K0
! 	povray +Idna.script +Odna.2 -ft +W256 +H256 -Q9 +R5 +A +J +V -K5
! 	povray +Idna.script +Odna.3 -ft +W256 +H256 -Q9 +R5 +A +J +V -K10
! 	povray +Idna.script +Odna.4 -ft +W256 +H256 -Q9 +R5 +A +J +V -K15
! 	povray +Idna.script +Odna.5 -ft +W256 +H256 -Q9 +R5 +A +J +V -K20
! 	povray +Idna.script +Odna.6 -ft +W256 +H256 -Q9 +R5 +A +J +V -K25
! 	povray +Idna.script +Odna.7 -ft +W256 +H256 -Q9 +R5 +A +J +V -K30
! 	povray +Idna.script +Odna.8 -ft +W256 +H256 -Q9 +R5 +A +J +V -K35
! 	povray +Idna.script +Odna.9 -ft +W256 +H256 -Q9 +R5 +A +J +V -K40
! 	povray +Idna.script +Odna.10 -ft +W256 +H256 -Q9 +R5 +A +J +V -K45
! 	povray +Idna.script +Odna.11 -ft +W256 +H256 -Q9 +R5 +A +J +V -K50
! 	povray +Idna.script +Odna.12 -ft +W256 +H256 -Q9 +R5 +A +J +V -K55
! 	povray +Idna.script +Odna.13 -ft +W256 +H256 -Q9 +R5 +A +J +V -K60
! 	povray +Idna.script +Odna.14 -ft +W256 +H256 -Q9 +R5 +A +J +V -K65
! 	povray +Idna.script +Odna.15 -ft +W256 +H256 -Q9 +R5 +A +J +V -K70
! 	povray +Idna.script +Odna.16 -ft +W256 +H256 -Q9 +R5 +A +J +V -K75
! 	povray +Idna.script +Odna.17 -ft +W256 +H256 -Q9 +R5 +A +J +V -K80
! 	povray +Idna.script +Odna.18 -ft +W256 +H256 -Q9 +R5 +A +J +V -K85
! 	povray +Idna.script +Odna.19 -ft +W256 +H256 -Q9 +R5 +A +J +V -K90
! 	povray +Idna.script +Odna.20 -ft +W256 +H256 -Q9 +R5 +A +J +V -K95
! 	povray +Idna.script +Odna.21 -ft +W256 +H256 -Q9 +R5 +A +J +V -K100
! 	povray +Idna.script +Odna.22 -ft +W256 +H256 -Q9 +R5 +A +J +V -K105
! 	povray +Idna.script +Odna.23 -ft +W256 +H256 -Q9 +R5 +A +J +V -K110
! 	povray +Idna.script +Odna.24 -ft +W256 +H256 -Q9 +R5 +A +J +V -K115
! 	povray +Idna.script +Odna.25 -ft +W256 +H256 -Q9 +R5 +A +J +V -K120
! 	povray +Idna.script +Odna.26 -ft +W256 +H256 -Q9 +R5 +A +J +V -K125
! 	povray +Idna.script +Odna.27 -ft +W256 +H256 -Q9 +R5 +A +J +V -K130
! 	povray +Idna.script +Odna.28 -ft +W256 +H256 -Q9 +R5 +A +J +V -K135
! 	povray +Idna.script +Odna.29 -ft +W256 +H256 -Q9 +R5 +A +J +V -K140
! 	povray +Idna.script +Odna.30 -ft +W256 +H256 -Q9 +R5 +A +J +V -K145
! 	povray +Idna.script +Odna.31 -ft +W256 +H256 -Q9 +R5 +A +J +V -K150
! 	povray +Idna.script +Odna.32 -ft +W256 +H256 -Q9 +R5 +A +J +V -K155
! 	povray +Idna.script +Odna.33 -ft +W256 +H256 -Q9 +R5 +A +J +V -K160
! 	povray +Idna.script +Odna.34 -ft +W256 +H256 -Q9 +R5 +A +J +V -K165
! 	povray +Idna.script +Odna.35 -ft +W256 +H256 -Q9 +R5 +A +J +V -K170
! 	povray +Idna.script +Odna.36 -ft +W256 +H256 -Q9 +R5 +A +J +V -K175
! 	povray +Idna.script +Odna.37 -ft +W256 +H256 -Q9 +R5 +A +J +V -K180
! 	povray +Idna.script +Odna.38 -ft +W256 +H256 -Q9 +R5 +A +J +V -K185
! 	povray +Idna.script +Odna.39 -ft +W256 +H256 -Q9 +R5 +A +J +V -K190
! 	povray +Idna.script +Odna.40 -ft +W256 +H256 -Q9 +R5 +A +J +V -K195
! 	povray +Idna.script +Odna.41 -ft +W256 +H256 -Q9 +R5 +A +J +V -K200
! 	povray +Idna.script +Odna.42 -ft +W256 +H256 -Q9 +R5 +A +J +V -K205
! 	povray +Idna.script +Odna.43 -ft +W256 +H256 -Q9 +R5 +A +J +V -K210
! 	povray +Idna.script +Odna.44 -ft +W256 +H256 -Q9 +R5 +A +J +V -K215
! 	povray +Idna.script +Odna.45 -ft +W256 +H256 -Q9 +R5 +A +J +V -K220
! 	povray +Idna.script +Odna.46 -ft +W256 +H256 -Q9 +R5 +A +J +V -K225
! 	povray +Idna.script +Odna.47 -ft +W256 +H256 -Q9 +R5 +A +J +V -K230
! 	povray +Idna.script +Odna.48 -ft +W256 +H256 -Q9 +R5 +A +J +V -K235
! 	povray +Idna.script +Odna.49 -ft +W256 +H256 -Q9 +R5 +A +J +V -K240
! 	povray +Idna.script +Odna.50 -ft +W256 +H256 -Q9 +R5 +A +J +V -K245
! 	povray +Idna.script +Odna.51 -ft +W256 +H256 -Q9 +R5 +A +J +V -K250
! 	povray +Idna.script +Odna.52 -ft +W256 +H256 -Q9 +R5 +A +J +V -K255
! 	povray +Idna.script +Odna.53 -ft +W256 +H256 -Q9 +R5 +A +J +V -K260
! 	povray +Idna.script +Odna.54 -ft +W256 +H256 -Q9 +R5 +A +J +V -K265
! 	povray +Idna.script +Odna.55 -ft +W256 +H256 -Q9 +R5 +A +J +V -K270
! 	povray +Idna.script +Odna.56 -ft +W256 +H256 -Q9 +R5 +A +J +V -K275
! 	povray +Idna.script +Odna.57 -ft +W256 +H256 -Q9 +R5 +A +J +V -K280
! 	povray +Idna.script +Odna.58 -ft +W256 +H256 -Q9 +R5 +A +J +V -K285
! 	povray +Idna.script +Odna.59 -ft +W256 +H256 -Q9 +R5 +A +J +V -K290
! 	povray +Idna.script +Odna.60 -ft +W256 +H256 -Q9 +R5 +A +J +V -K295
! 	povray +Idna.script +Odna.61 -ft +W256 +H256 -Q9 +R5 +A +J +V -K300
! 	povray +Idna.script +Odna.62 -ft +W256 +H256 -Q9 +R5 +A +J +V -K305
! 	povray +Idna.script +Odna.63 -ft +W256 +H256 -Q9 +R5 +A +J +V -K310
! 	povray +Idna.script +Odna.64 -ft +W256 +H256 -Q9 +R5 +A +J +V -K315
! 	povray +Idna.script +Odna.65 -ft +W256 +H256 -Q9 +R5 +A +J +V -K320
! 	povray +Idna.script +Odna.66 -ft +W256 +H256 -Q9 +R5 +A +J +V -K325
! 	povray +Idna.script +Odna.67 -ft +W256 +H256 -Q9 +R5 +A +J +V -K330
! 	povray +Idna.script +Odna.68 -ft +W256 +H256 -Q9 +R5 +A +J +V -K335
! 	povray +Idna.script +Odna.69 -ft +W256 +H256 -Q9 +R5 +A +J +V -K340
! 	povray +Idna.script +Odna.70 -ft +W256 +H256 -Q9 +R5 +A +J +V -K345
! 	povray +Idna.script +Odna.71 -ft +W256 +H256 -Q9 +R5 +A +J +V -K350
! 	povray +Idna.script +Odna.72 -ft +W256 +H256 -Q9 +R5 +A +J +V -K355
  	cat dna.[0-9] dna.[0-9][0-9] | convert tga:- miff:dna
  	mogrify -verbose -colors 256 dna.[0-9]*
  
  clean:
diff -c -r ImageMagick-3.1/scenes/README ImageMagick/scenes/README
*** ImageMagick-3.1/scenes/README	Wed Jul 13 10:52:10 1994
--- ImageMagick/scenes/README	Fri May 27 10:27:49 1994
***************
*** 1,5 ****
! The DNA sequence is useful for testing the animate(1) program from
! contrib/apllications/ImageMagick/ImageMagick-3.1.tar.gz on ftp.x.org.
  Animate(1) is a program that can display image sequences on any X
  server.  Type:
  
--- 1,5 ----
! DNA sequence useful for testing the animate(1) program from
! contrib/apllications/ImageMagick/ImageMagick-3.0.tar.gz on ftp.x.org.
  Animate(1) is a program that can display image sequences on any X
  server.  Type:
  
diff -c -r ImageMagick-3.1/scenes/dna.script ImageMagick/scenes/dna.script
*** ImageMagick-3.1/scenes/dna.script	Wed Jul 13 10:52:10 1994
--- ImageMagick/scenes/dna.script	Mon May 23 17:31:39 1994
***************
*** 608,615 ****
  
  camera
  {
!   location <0.00, -300.00, 0.0>
!   direction <0.0, -2.5, 0.0>
    up <0.00, 0.00, 1.00>
    sky <0.00, 0.00, 1.00>
    right <-1.0, 0.00, 0.00>
--- 608,615 ----
  
  camera
  {
!   location <0.00, -150.00, 0.0>
!   direction <0.0, -1.33, 0.0>
    up <0.00, 0.00, 1.00>
    sky <0.00, 0.00, 1.00>
    right <-1.0, 0.00, 0.00>
diff -c -r ImageMagick-3.1/segment.c ImageMagick/segment.c
*** ImageMagick-3.1/segment.c	Wed Jul 13 10:52:11 1994
--- ImageMagick/segment.c	Mon May 23 16:52:00 1994
***************
*** 1519,1525 ****
  
  float
    smoothing_threshold,
!   cluster_threshold;
  {
  #define DeltaTau  0.5
  #define Tau  5.2
--- 1519,1525 ----
  
  float
    smoothing_threshold,
!   cluster_threshold;  
  {
  #define DeltaTau  0.5
  #define Tau  5.2
***************
*** 1597,1605 ****
  
    char
      *comment,
      *filename,
      *label,
!     *option;
  
    double
      normalized_maximum_error,
--- 1597,1610 ----
  
    char
      *comment,
+     *density,
      *filename,
+     *font,
+     *image_geometry,
      *label,
!     *option,
!     *page_geometry,
!     *server_name;
  
    double
      normalized_maximum_error,
***************
*** 1627,1635 ****
    unsigned int
      colorspace,
      compression,
      matte,
      mean_error_per_pixel,
!     scene;
  
    unsigned long
      total_colors;
--- 1632,1643 ----
    unsigned int
      colorspace,
      compression,
+     interlace,
      matte,
      mean_error_per_pixel,
!     quality,
!     scene,
!     verbose;
  
    unsigned long
      total_colors;
***************
*** 1647,1659 ****
    colorspace=RGBColorspace;
    comment=(char *) NULL;
    compression=UndefinedCompression;
    image=(Image *) NULL;
!   GetImageInfo(&image_info);
    label=(char *) NULL;
    matte=NotInitialized;
    scene=0;
    smoothing_threshold=5.0;
    start_time=time((time_t *) NULL);
    /*
      Check command syntax.
    */
--- 1655,1674 ----
    colorspace=RGBColorspace;
    comment=(char *) NULL;
    compression=UndefinedCompression;
+   density=(char *) NULL;
+   font=(char *) NULL;
    image=(Image *) NULL;
!   image_geometry=(char *) NULL;
!   interlace=NoneInterlace;
    label=(char *) NULL;
    matte=NotInitialized;
+   page_geometry=(char *) NULL;
+   quality=85;
    scene=0;
+   server_name=(char *) NULL;
    smoothing_threshold=5.0;
    start_time=time((time_t *) NULL);
+   verbose=False;
    /*
      Check command syntax.
    */
***************
*** 1667,1673 ****
            Read input image.
          */
          filename=argv[i];
!         (void) strcpy(image_info.filename,filename);
          if (image != (Image *) NULL)
            Error("input image already specified",filename);
          image=ReadImage(&image_info);
--- 1682,1696 ----
            Read input image.
          */
          filename=argv[i];
!         GetImageInfo(filename,&image_info);
!         image_info.server_name=server_name;
!         image_info.font=font;
!         image_info.geometry=image_geometry;
!         image_info.page=page_geometry;
!         image_info.density=density;
!         image_info.interlace=interlace;
!         image_info.quality=quality;
!         image_info.verbose=verbose;
          if (image != (Image *) NULL)
            Error("input image already specified",filename);
          image=ReadImage(&image_info);
***************
*** 1758,1782 ****
          {
            if (strncmp("density",option+1,3) == 0)
              {
!               image_info.density=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -density",(char *) NULL);
!                   image_info.density=argv[i];
                  }
                break;
              }
            if (strncmp("display",option+1,3) == 0)
              {
!               image_info.server_name=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if (i == argc)
                      Error("Missing server name on -display",(char *) NULL);
!                   image_info.server_name=argv[i];
                  }
                break;
              }
--- 1781,1805 ----
          {
            if (strncmp("density",option+1,3) == 0)
              {
!               density=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing geometry on -density",(char *) NULL);
!                   density=argv[i];
                  }
                break;
              }
            if (strncmp("display",option+1,3) == 0)
              {
!               server_name=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if (i == argc)
                      Error("Missing server name on -display",(char *) NULL);
!                   server_name=argv[i];
                  }
                break;
              }
***************
*** 1785,1809 ****
          }
          case 'f':
          {
!           image_info.font=(char *) NULL;
            if (*option == '-')
              {
                i++;
                if (i == argc)
                  Error("Missing font name on -font",(char *) NULL);
!               image_info.font=argv[i];
              }
            break;
          }
          case 'g':
          {
!           image_info.geometry=(char *) NULL;
            if (*option == '-')
              {
                i++;
                if ((i == argc) || !sscanf(argv[i],"%d",&x))
                  Error("Missing geometry on -geometry",(char *) NULL);
!               image_info.geometry=argv[i];
              }
            break;
          }
--- 1808,1832 ----
          }
          case 'f':
          {
!           font=(char *) NULL;
            if (*option == '-')
              {
                i++;
                if (i == argc)
                  Error("Missing font name on -font",(char *) NULL);
!               font=argv[i];
              }
            break;
          }
          case 'g':
          {
!           image_geometry=(char *) NULL;
            if (*option == '-')
              {
                i++;
                if ((i == argc) || !sscanf(argv[i],"%d",&x))
                  Error("Missing geometry on -geometry",(char *) NULL);
!               image_geometry=argv[i];
              }
            break;
          }
***************
*** 1816,1822 ****
          {
            if (strncmp("interlace",option+1,3) == 0)
              {
!               image_info.interlace=NoneInterlace;
                if (*option == '-')
                  {
                    i++;
--- 1839,1845 ----
          {
            if (strncmp("interlace",option+1,3) == 0)
              {
!               interlace=NoneInterlace;
                if (*option == '-')
                  {
                    i++;
***************
*** 1823,1836 ****
                    if (i == argc)
                      Error("Missing type on -interlace",(char *) NULL);
                    option=argv[i];
!                   image_info.interlace=UndefinedInterlace;
                    if (Latin1Compare("none",option) == 0)
!                     image_info.interlace=NoneInterlace;
                    if (Latin1Compare("line",option) == 0)
!                     image_info.interlace=LineInterlace;
                    if (Latin1Compare("plane",option) == 0)
!                     image_info.interlace=PlaneInterlace;
!                   if (image_info.interlace == UndefinedInterlace)
                      Error("Invalid interlace type on -interlace",option);
                  }
                break;
--- 1846,1859 ----
                    if (i == argc)
                      Error("Missing type on -interlace",(char *) NULL);
                    option=argv[i];
!                   interlace=UndefinedInterlace;
                    if (Latin1Compare("none",option) == 0)
!                     interlace=NoneInterlace;
                    if (Latin1Compare("line",option) == 0)
!                     interlace=LineInterlace;
                    if (Latin1Compare("plane",option) == 0)
!                     interlace=PlaneInterlace;
!                   if (interlace == UndefinedInterlace)
                      Error("Invalid interlace type on -interlace",option);
                  }
                break;
***************
*** 1868,1880 ****
          {
            if (strncmp("page",option+1,2) == 0)
              {
!               image_info.page=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing page geometry on -page",(char *) NULL);
!                   image_info.page=argv[i];
                  }
                break;
              }
--- 1891,1903 ----
          {
            if (strncmp("page",option+1,2) == 0)
              {
!               page_geometry=(char *) NULL;
                if (*option == '-')
                  {
                    i++;
                    if ((i == argc) || !sscanf(argv[i],"%d",&x))
                      Error("Missing page geometry on -page",(char *) NULL);
!                   page_geometry=argv[i];
                  }
                break;
              }
***************
*** 1886,1892 ****
            i++;
            if ((i == argc) || !sscanf(argv[i],"%d",&x))
              Error("Missing quality on -quality",(char *) NULL);
!           image_info.quality=atoi(argv[i]);
            break;
          }
          case 's':
--- 1909,1915 ----
            i++;
            if ((i == argc) || !sscanf(argv[i],"%d",&x))
              Error("Missing quality on -quality",(char *) NULL);
!           quality=atoi(argv[i]);
            break;
          }
          case 's':
***************
*** 1922,1928 ****
          {
            if (strncmp("verbose",option+1,2) == 0)
              {
!               image_info.verbose=(*option == '-');
                break;
              }
            Error("Unrecognized option",option);
--- 1945,1951 ----
          {
            if (strncmp("verbose",option+1,2) == 0)
              {
!               verbose=(*option == '-');
                break;
              }
            Error("Unrecognized option",option);
***************
*** 1964,1973 ****
        Reduce the number of colors in the image.
      */
      RGBTransformImage(image,colorspace);
!     SegmentImage(image,colorspace,image_info.verbose,smoothing_threshold,
        cluster_threshold);
      TransformRGBImage(image,colorspace);
!     if (image_info.verbose)
        {
          /*
            Measure quantization error.
--- 1987,1996 ----
        Reduce the number of colors in the image.
      */
      RGBTransformImage(image,colorspace);
!     SegmentImage(image,colorspace,verbose,smoothing_threshold,
        cluster_threshold);
      TransformRGBImage(image,colorspace);
!     if (verbose)
        {
          /*
            Measure quantization error.
***************
*** 1978,1984 ****
        }
      SyncImage(image);
      status=WriteImage(&image_info,image);
!     if (image_info.verbose)
        {
          /*
            Display detailed info about the image.
--- 2001,2007 ----
        }
      SyncImage(image);
      status=WriteImage(&image_info,image);
!     if (verbose)
        {
          /*
            Display detailed info about the image.
diff -c -r ImageMagick-3.1/segment.man ImageMagick/segment.man
*** ImageMagick-3.1/segment.man	Wed Jul 13 10:52:17 1994
--- ImageMagick/segment.man	Wed Jun  1 22:12:56 1994
***************
*** 189,195 ****
  picas or a TEXT page in pixels.  The default for a Postscript page is
  to center the image on a letter page 612 by 792 dots per inch.  The
  left and right margins are 18 picas and the top and bottom 94 picas
! (i.e.  612x792+36+36).  Other common sizes are:
  
      540x720   Note
      612x1008  Legal
--- 189,195 ----
  picas or a TEXT page in pixels.  The default for a Postscript page is
  to center the image on a letter page 612 by 792 dots per inch.  The
  left and right margins are 18 picas and the top and bottom 94 picas
! (i.e.  612x792+18+94).  Other common sizes are:
  
      540x720   Note
      612x1008  Legal
diff -c -r ImageMagick-3.1/xtp/get ImageMagick/xtp/get
*** ImageMagick-3.1/xtp/get	Wed Jul 13 10:52:09 1994
--- ImageMagick/xtp/get	Sat Jul  4 00:46:02 1992
***************
*** 1,4 ****
! #!/usr/local/bin/perl
  #
  # Retrieve files from remote host using standard 'host: filename' string:
  #
--- 1,4 ----
! #!/usr/bin/perl
  #
  # Retrieve files from remote host using standard 'host: filename' string:
  #
