home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-12-14 | 57.3 KB | 1,830 lines |
- Newsgroups: comp.sources.misc
- Path: sparky!kent
- From: cristy@eplrx7.es.duPont.com (John Cristy)
- Subject: v34i042: imagemagick - X11 image processing and display v2.2, Part14/26
- Message-ID: <1992Dec15.035244.21694@sparky.imd.sterling.com>
- Followup-To: comp.sources.d
- X-Md4-Signature: 094348b8daf5a085eb62a9d6d9e02206
- Sender: kent@sparky.imd.sterling.com (Kent Landfield)
- Organization: Sterling Software
- References: <csm-v34i028=imagemagick.141926@sparky.IMD.Sterling.COM>
- Date: Tue, 15 Dec 1992 03:52:44 GMT
- Approved: kent@sparky.imd.sterling.com
- Lines: 1815
-
- Submitted-by: cristy@eplrx7.es.duPont.com (John Cristy)
- Posting-number: Volume 34, Issue 42
- Archive-name: imagemagick/part14
- Environment: UNIX, VMS, X11, SGI, DEC, Cray, Sun, Vax
-
- #!/bin/sh
- # this is Part.14 (part 14 of a multipart archive)
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file ImageMagick/display.c continued
- #
- if test ! -r _shar_seq_.tmp; then
- echo 'Please unpack part 1 first!'
- exit 1
- fi
- (read Scheck
- if test "$Scheck" != 14; then
- echo Please unpack part "$Scheck" next!
- exit 1
- else
- exit 0
- fi
- ) < _shar_seq_.tmp || exit 1
- if test ! -f _shar_wnt_.tmp; then
- echo 'x - still skipping ImageMagick/display.c'
- else
- echo 'x - continuing file ImageMagick/display.c'
- sed 's/^X//' << 'SHAR_EOF' >> 'ImageMagick/display.c' &&
- X break;
- X }
- X if (strncmp("foreground",option+1,3) == 0)
- X {
- X resource_info.foreground_color=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing foreground on -foreground",(char *) NULL);
- X resource_info.foreground_color=argv[i];
- X }
- X break;
- X }
- X Error("unrecognized option",option);
- X break;
- X }
- X case 'g':
- X {
- X if (strncmp("gamma",option+1,2) == 0)
- X {
- X gamma=0.0;
- X if (*option == '-')
- X {
- X i++;
- X if ((i == argc) || !sscanf(argv[i],"%d",&x))
- X Error("missing gamma on -gamma",(char *) NULL);
- X gamma=atof(argv[i]);
- X }
- X break;
- X }
- X if (strncmp("geometry",option+1,2) == 0)
- X {
- X resource_info.image_geometry=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing geometry on -geometry",(char *) NULL);
- X resource_info.image_geometry=argv[i];
- X }
- X alien_info.geometry=resource_info.image_geometry;
- X break;
- X }
- X Error("unrecognized option",option);
- X break;
- X }
- X case 'h':
- X {
- X Usage(True);
- X break;
- X }
- X case 'i':
- X {
- X if (strncmp("iconGeometry",option+1,5) == 0)
- X {
- X resource_info.icon_geometry=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing geometry on -iconGeometry",(char *) NULL);
- X resource_info.icon_geometry=argv[i];
- X }
- X break;
- X }
- X if (strncmp("iconic",option+1,5) == 0)
- X {
- X resource_info.iconic=(*option == '-');
- X break;
- X }
- X if (strncmp("inverse",option+1,2) == 0)
- X {
- X inverse=(*option == '-');
- X break;
- X }
- X Error("unrecognized option",option);
- X break;
- X }
- X case 'm':
- X {
- X if (strncmp("magnify",option+1,3) == 0)
- X {
- X resource_info.magnify=2;
- X if (*option == '-')
- X {
- X i++;
- X if ((i == argc) || !sscanf(argv[i],"%d",&x))
- X Error("missing level on -magnify",(char *) NULL);
- X resource_info.magnify=atoi(argv[i]);
- X }
- X break;
- X }
- X if (strncmp("map",option+1,3) == 0)
- X {
- X resource_info.map_type=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing map type on -map",(char *) NULL);
- X resource_info.map_type=argv[i];
- X }
- X break;
- X }
- X if (strncmp("monochrome",option+1,2) == 0)
- X {
- X resource_info.monochrome=(*option == '-');
- X break;
- X }
- X Error("unrecognized option",option);
- X break;
- X }
- X case 'n':
- X {
- X if (strncmp("name",option+1,2) == 0)
- X {
- X resource_info.name=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing name on -name",(char *) NULL);
- X resource_info.name=argv[i];
- X }
- X break;
- X }
- X if (strncmp("noise",option+1,3) == 0)
- X {
- X noise=(*option == '-');
- X break;
- X }
- X if (strncmp("normalize",option+1,3) == 0)
- X {
- X normalize=(*option == '-');
- X break;
- X }
- X Error("unrecognized option",option);
- X break;
- X }
- X case 'p':
- X {
- X if (strncmp("print",option+1,2) == 0)
- X {
- X resource_info.print_filename=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing file name on -print",(char *) NULL);
- X resource_info.print_filename=argv[i];
- X if (access(resource_info.print_filename,0) == 0)
- X {
- X char
- X answer[2];
- X
- X (void) fprintf(stderr,"Overwrite %s? ",
- X resource_info.print_filename);
- X (void) gets(answer);
- X if (!((*answer == 'y') || (*answer == 'Y')))
- X exit(1);
- X }
- X }
- X break;
- X }
- X Error("unrecognized option",option);
- X break;
- X }
- X case 'r':
- X {
- X if (strncmp("reflect",option+1,2) == 0)
- X {
- X reflect=(*option == '-');
- X break;
- X }
- X if (strncmp("rotate",option+1,3) == 0)
- X {
- X degrees=0;
- X if (*option == '-')
- X {
- X i++;
- X if ((i == argc) || !sscanf(argv[i],"%d",&x))
- X Error("missing degrees on -rotate",(char *) NULL);
- X degrees=atoi(argv[i]);
- X }
- X break;
- X }
- X Error("unrecognized option",option);
- X break;
- X }
- X case 's':
- X {
- X if (strncmp("scale",option+1,3) == 0)
- X {
- X scale_geometry=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if ((i == argc) || !sscanf(argv[i],"%f",(float *) &x))
- X Error("missing scale geometry on -scale",(char *) NULL);
- X scale_geometry=argv[i];
- X }
- X break;
- X }
- X if (strncmp("scene",option+1,3) == 0)
- X {
- X scene=0;
- X if (*option == '-')
- X {
- X i++;
- X if ((i == argc) || !sscanf(argv[i],"%d",&x))
- X Error("missing scene number on -scene",(char *) NULL);
- X scene=atoi(argv[i]);
- X }
- X break;
- X }
- X Error("unrecognized option",option);
- X break;
- X }
- X case 't':
- X {
- X if (strncmp("title",option+1,2) == 0)
- X {
- X resource_info.title=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing title on -title",(char *) NULL);
- X resource_info.title=argv[i];
- X }
- X break;
- X }
- X if (strncmp("treedepth",option+1,2) == 0)
- X {
- X resource_info.tree_depth=0;
- X if (*option == '-')
- X {
- X i++;
- X if ((i == argc) || !sscanf(argv[i],"%d",&x))
- X Error("missing depth on -treedepth",(char *) NULL);
- X resource_info.tree_depth=atoi(argv[i]);
- X }
- X break;
- X }
- X Error("unrecognized option",option);
- X break;
- X }
- X case 'v':
- X {
- X if (strncmp("verbose",option+1,2) == 0)
- X {
- X verbose=(*option == '-');
- X alien_info.verbose=verbose;
- X break;
- X }
- X if (strncmp("visual",option+1,2) == 0)
- X {
- X resource_info.visual_type=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing visual class on -visual",(char *) NULL);
- X resource_info.visual_type=argv[i];
- X }
- X break;
- X }
- X Error("unrecognized option",option);
- X break;
- X }
- X case 'w':
- X {
- X if (strncmp("window",option+1,2) == 0)
- X {
- X window_id=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing id, name, or 'root' on -window",
- X (char *) NULL);
- X window_id=argv[i];
- X }
- X break;
- X }
- X if (strncmp("write",option+1,2) == 0)
- X {
- X resource_info.write_filename=(char *) NULL;
- X if (*option == '-')
- X {
- X i++;
- X if (i == argc)
- X Error("missing file name on -write",(char *) NULL);
- X resource_info.write_filename=argv[i];
- X if (access(resource_info.write_filename,0) == 0)
- X {
- X char
- X answer[2];
- X
- X (void) fprintf(stderr,"Overwrite %s? ",
- X resource_info.write_filename);
- X (void) gets(answer);
- X if (!((*answer == 'y') || (*answer == 'Y')))
- X exit(1);
- X }
- X }
- X break;
- X }
- X Error("unrecognized option",option);
- X break;
- X }
- X default:
- X {
- X Error("unrecognized option",option);
- X break;
- X }
- X }
- X else
- X {
- X Image
- X *image,
- X info_image,
- X *next_image;
- X
- X time_t
- X start_time;
- X
- X unsigned long
- X total_colors;
- X
- X /*
- X Option is a file name: begin by reading image from specified file.
- X */
- X start_time=time((time_t *) 0);
- X (void) strcpy(alien_info.filename,option);
- X image=ReadAlienImage(&alien_info);
- X if (image == (Image *) NULL)
- X if (*option == '-')
- X break;
- X else
- X continue;
- X do
- X {
- X info_image=(*image);
- X if (scene > 0)
- X image->scene=scene;
- X /*
- X Transform image as defined by the clip, image and scale geometries.
- X */
- X TransformImage(&image,clip_geometry,resource_info.image_geometry,
- X scale_geometry);
- X if (reflect)
- X {
- X Image
- X *reflected_image;
- X
- X /*
- X Reverse image scanlines.
- X */
- X reflected_image=ReflectImage(image);
- X if (reflected_image != (Image *) NULL)
- X {
- X DestroyImage(image);
- X image=reflected_image;
- X }
- X }
- X if ((degrees % 360) != 0)
- X {
- X Image
- X *rotated_image;
- X
- X /*
- X Rotate image.
- X */
- X rotated_image=RotateImage(image,(double) degrees,False);
- X if (rotated_image != (Image *) NULL)
- X {
- X DestroyImage(image);
- X image=rotated_image;
- X }
- X }
- X if (enhance)
- X {
- X Image
- X *enhanced_image;
- X
- X /*
- X Enhance image.
- X */
- X enhanced_image=EnhanceImage(image);
- X if (enhanced_image != (Image *) NULL)
- X {
- X DestroyImage(image);
- X image=enhanced_image;
- X }
- X }
- X if (noise)
- X {
- X Image
- X *noisy_image;
- X
- X /*
- X Reduce noise in image.
- X */
- X noisy_image=NoisyImage(image);
- X if (noisy_image != (Image *) NULL)
- X {
- X DestroyImage(image);
- X image=noisy_image;
- X }
- X }
- X if (gamma > 0.0)
- X GammaImage(image,gamma);
- X if (inverse)
- X InverseImage(image);
- X if (normalize)
- X NormalizeImage(image);
- X if (verbose)
- X {
- X /*
- X Initialize image error attributes.
- X */
- X if (image->class == DirectClass)
- X image->colors=NumberColors(image);
- X total_colors=image->colors;
- X }
- X if (resource_info.colorspace == GRAYColorspace)
- X QuantizeImage(image,256,8,resource_info.dither,GRAYColorspace,True);
- X if (resource_info.monochrome)
- X QuantizeImage(image,2,8,resource_info.dither,GRAYColorspace,True);
- X if (resource_info.number_colors > 0)
- X if ((image->class == DirectClass) ||
- X (image->colors > resource_info.number_colors))
- X QuantizeImage(image,resource_info.number_colors,
- X resource_info.tree_depth,resource_info.dither,
- X resource_info.colorspace,True);
- X /*
- X Display image to X server.
- X */
- X if (compression != UndefinedCompression)
- X image->compression=compression;
- X else
- X image->compression=info_image.compression;
- X if (window_id != (char *) NULL)
- X {
- X /*
- X Display image to a specified X window.
- X */
- X XDisplayBackgroundImage(display,&resource_info,window_id,image);
- X state&=ExitState;
- X }
- X else
- X if (image->montage == (char *) NULL)
- X (void) XDisplayImage(display,&resource_info,argv,argc,&image,
- X &state);
- X else
- X do
- X {
- X Image
- X *tile_image;
- X
- X /*
- X Display montage image.
- X */
- X tile_image=
- X XDisplayImage(display,&resource_info,argv,argc,&image,&state);
- X if ((!(state & TileImageState)) || (state & ExitState))
- X break;
- X (void) XDisplayImage(display,&resource_info,argv,argc,
- X &tile_image,&state);
- X DestroyImage(tile_image);
- X } while (!(state & ExitState));
- X if (resource_info.print_filename != (char *) NULL)
- X {
- X /*
- X Print image as Encapsulated Postscript.
- X */
- X (void) strcpy(image->filename,resource_info.print_filename);
- X (void) PrintImage(image,resource_info.image_geometry);
- X }
- X if (resource_info.write_filename != (char *) NULL)
- X {
- X /*
- X Write image in MIFF format.
- X */
- X (void) strcpy(image->filename,resource_info.write_filename);
- X (void) WriteAlienImage(image);
- X }
- X if (verbose)
- X {
- X /*
- X Display detailed info about the image.
- X */
- X (void) fprintf(stderr,"[%u] %s",
- X image->scene == 0 ? image_number : image->scene,
- X info_image.filename);
- X if (resource_info.write_filename != (char *) NULL)
- X (void) fprintf(stderr,"=>%s",resource_info.write_filename);
- X (void) fprintf(stderr," %ux%u",info_image.columns,
- X info_image.rows);
- X if ((info_image.columns != image->columns) ||
- X (info_image.rows != image->rows))
- X (void) fprintf(stderr,"=>%ux%u",image->columns,image->rows);
- X if (image->class == DirectClass)
- X (void) fprintf(stderr," DirectClass ");
- X else
- X (void) fprintf(stderr," PseudoClass ");
- X if (total_colors != image->colors)
- X (void) fprintf(stderr,"%lu=>",total_colors);
- X (void) fprintf(stderr,"%uc",image->colors);
- X if ((resource_info.number_colors > 0) || resource_info.monochrome)
- X {
- X double
- X normalized_maximum_error,
- X normalized_mean_error;
- X
- X unsigned int
- X mean_error_per_pixel;
- X
- X /*
- X Measure quantization error.
- X */
- X QuantizationError(image,&mean_error_per_pixel,
- X &normalized_mean_error,&normalized_maximum_error);
- X (void) fprintf(stderr," %u/%.6f/%.6fe",mean_error_per_pixel,
- X normalized_mean_error,normalized_maximum_error);
- X }
- X (void) fprintf(stderr," %s %lds\n",image->magick,
- X time((time_t *) 0)-start_time+1);
- X }
- X /*
- X Proceed to next/previous image.
- X */
- X if (state & LastImageState)
- X next_image=image->last;
- X else
- X next_image=image->next;
- X if (next_image != (Image *) NULL)
- X image=next_image;
- X } while ((next_image != (Image *) NULL) && !(state & ExitState));
- X /*
- X Free image resources.
- X */
- X DestroyImages(image);
- X if (!(state & LastImageState))
- X image_marker[i]=image_number++;
- X else
- X {
- X /*
- X Proceed to last image.
- X */
- X for (i--; i > 0; i--)
- X if (image_marker[i] == (image_number-2))
- X break;
- X if (image_number > 0)
- X image_number--;
- X }
- X }
- X }
- X if (image_number == 0)
- X Error("missing an image file name",(char *) NULL);
- X XCloseDisplay(display);
- X (void) free((char *) image_marker);
- X return(False);
- }
- SHAR_EOF
- echo 'File ImageMagick/display.c is complete' &&
- chmod 0644 ImageMagick/display.c ||
- echo 'restore of ImageMagick/display.c failed'
- Wc_c="`wc -c < 'ImageMagick/display.c'`"
- test 187475 -eq "$Wc_c" ||
- echo 'ImageMagick/display.c: original size 187475, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= ImageMagick/X.h ==============
- if test -f 'ImageMagick/X.h' -a X"$1" != X"-c"; then
- echo 'x - skipping ImageMagick/X.h (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting ImageMagick/X.h (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/X.h' &&
- #undef False
- #undef True
- #include <X11/Xos.h>
- #include <X11/Xlib.h>
- #include <X11/Xutil.h>
- #include <X11/Xresource.h>
- #include <X11/Xproto.h>
- #include <X11/Xatom.h>
- #include <X11/cursorfont.h>
- #include <X11/keysym.h>
- #undef index
- #ifdef hpux
- #undef SYSV
- #endif
- X
- /*
- X Colormap declarations.
- */
- #define UndefinedColormap 0
- #define PrivateColormap 1
- #define SharedColormap 2
- /*
- X Define declarations.
- */
- #define MaxNumberFonts 9
- #define MaxNumberPens 9
- #define WindowBorderWidth 2
- #define XSetWindowExtents(window,text,border) \
- X window.width=XTextWidth(window.font_info,text,strlen(text))+ \
- X (int) border*window.font_info->max_bounds.width; \
- X window.height=window.font_info->ascent+window.font_info->descent+4; \
- X XResizeWindow(display,window.id,window.width,window.height);
- #define XStandardPixel(map,color,shift) (unsigned long) (map->base_pixel+ \
- X ((color.red*map->red_max+(1 << (shift-1))) >> shift)*map->red_mult+ \
- X ((color.green*map->green_max+(1 << (shift-1))) >> shift)*map->green_mult+ \
- X ((color.blue*map->blue_max+(1 << (shift-1))) >> shift)*map->blue_mult)
- X
- /*
- X Typedef declarations.
- */
- typedef struct _DiversityPacket
- {
- X unsigned char
- X red,
- X green,
- X blue;
- X
- X unsigned short
- X index;
- X
- X unsigned long
- X count;
- } DiversityPacket;
- X
- typedef struct _XAnnotateInfo
- {
- X int
- X x,
- X y;
- X
- X unsigned int
- X width,
- X height;
- X
- X double
- X degrees;
- X
- X XFontStruct
- X *font_info;
- X
- X char
- X *text,
- X geometry[2048];
- X
- X struct _XAnnotateInfo
- X *previous,
- X *next;
- } XAnnotateInfo;
- X
- typedef struct _XPixelInfo
- {
- X unsigned int
- X colors;
- X
- X unsigned long
- X *pixels;
- X
- X XColor
- X background_color,
- X border_color,
- X foreground_color,
- X pen_color[MaxNumberPens],
- X annotate_color;
- X
- X unsigned short
- X background_index,
- X annotate_index;
- } XPixelInfo;
- X
- typedef struct _XResourceInfo
- {
- X unsigned int
- X backdrop;
- X
- X char
- X *background_color,
- X *border_color;
- X
- X unsigned int
- X border_width,
- X colormap,
- X colorspace,
- X debug,
- X delay,
- X dither;
- X
- X char
- X *font,
- X *font_name[MaxNumberFonts],
- X *foreground_color;
- X
- X int
- X gravity;
- X
- X char
- X *icon_geometry;
- X
- X unsigned int
- X iconic;
- X
- X char
- X *image_geometry;
- X
- X unsigned int
- X magnify;
- X
- X char
- X *map_type;
- X
- X unsigned int
- X monochrome;
- X
- X char
- X *name;
- X
- X unsigned int
- X number_colors;
- X
- X char
- X *pen_color[MaxNumberPens],
- X *print_filename,
- X *server_name,
- X *title;
- X
- X unsigned int
- X tree_depth;
- X
- X char
- X *visual_type,
- X *write_filename;
- } XResourceInfo;
- X
- typedef struct _XWindowInfo
- {
- X Window
- X id;
- X
- X int
- X screen;
- X
- X unsigned int
- X depth;
- X
- X XVisualInfo
- X *visual_info;
- X
- X XStandardColormap
- X *map_info;
- X
- X XPixelInfo
- X *pixel_info;
- X
- X XFontStruct
- X *font_info;
- X
- X GC
- X graphic_context,
- X highlight_context;
- X
- X Cursor
- X cursor,
- X busy_cursor;
- X
- X char
- X *name,
- X *geometry,
- X *icon_name,
- X *icon_geometry,
- X *clip_geometry;
- X
- X unsigned long
- X flags;
- X
- X int
- X x,
- X y;
- X
- X unsigned int
- X width,
- X height,
- X min_width,
- X min_height,
- X width_inc,
- X height_inc,
- X border_width,
- X immutable;
- X
- X XImage
- X *ximage;
- X
- X Pixmap
- X pixmap,
- X *pixmaps;
- X
- X XSetWindowAttributes
- X attributes;
- } XWindowInfo;
- X
- typedef struct _XWindows
- {
- X XWindowInfo
- X superclass,
- X backdrop,
- X icon,
- X info,
- X image,
- X magnify,
- X pan,
- X popup;
- } XWindows;
- X
- /*
- X X utilities routines.
- */
- extern char
- X *XGetResource _Declare((XrmDatabase,char *,char *,char *,char *)),
- X *XVisualClassName _Declare((XVisualInfo *));
- X
- extern Cursor
- X XMakeInvisibleCursor _Declare((Display *,Window));
- X
- extern Image
- X *ReadTEXTImage _Declare((char *,char *,char *,char *)),
- X *ReadXImage _Declare((char *,char *,unsigned int,unsigned int,unsigned int)),
- X *ReadXCImage _Declare((char *,char *,char *));
- X
- extern int
- X Latin1Compare _Declare((char *,char *)),
- X XError _Declare((Display *,XErrorEvent *));
- X
- extern unsigned int
- X IsTrue _Declare((char *)),
- X XAnnotateImage _Declare((Display *,XWindowInfo *,XAnnotateInfo *,
- X unsigned int,Image *)),
- X XMakeImage _Declare((Display *,XResourceInfo *,XWindowInfo *,Image *,
- X unsigned int,unsigned int)),
- X XMakePixmap _Declare((Display *,XResourceInfo *,XWindowInfo *)),
- X XPopupMenu _Declare((Display *,XWindowInfo *,int,int,char *,char **,
- X unsigned int,char *)),
- X XReadColormap _Declare((Display *,XWindowAttributes *,XColor **));
- X
- extern XVisualInfo
- X *XBestVisualInfo _Declare((Display *,char *,char *,XStandardColormap *));
- X
- extern void
- X Latin1Upper _Declare((char *)),
- X XBestIconSize _Declare((Display *,XWindowInfo *,Image *)),
- X XFreeStandardColormap _Declare((Display *,XVisualInfo *,XPixelInfo *,
- X XStandardColormap *)),
- X XGetAnnotateInfo _Declare((XAnnotateInfo *)),
- X XGetPixelInfo _Declare((Display *,XVisualInfo *,XStandardColormap *,
- X XResourceInfo *,Image *,XPixelInfo *)),
- X XGetResourceInfo _Declare((XrmDatabase,char *,XResourceInfo *)),
- X XGetWindowInfo _Declare((XWindowInfo *,XWindowInfo *)),
- X XMakeStandardColormap _Declare((Display *,XVisualInfo *,XResourceInfo *,
- X XPixelInfo *,Image *,XStandardColormap *)),
- X XMakeWindow _Declare((Display *,Window,char **,int,XClassHint *,XWMHints *,
- X Atom,XWindowInfo *)),
- X XPopupAlert _Declare((Display *,XWindowInfo *,char *,char *)),
- X XPopupQuery _Declare((Display *,XWindowInfo *,char *,char *)),
- X XRefreshWindow _Declare((Display *,XWindowInfo *,XEvent *));
- X
- extern Window
- X XClientWindow _Declare((Display *,Window)),
- X XWindowByProperty _Declare((Display *,Window,Atom)),
- X XSelectWindow _Declare((Display *,XRectangle *)),
- X XWindowByID _Declare((Display *,Window,unsigned long)),
- X XWindowByName _Declare((Display *,Window,char *));
- X
- extern XFontStruct
- X *XBestFont _Declare((Display *,XResourceInfo *,char *,unsigned int));
- X
- /*
- X Invoke pre-X11R5 ICCCM routines if XlibSpecificationRelease is not defined.
- */
- #ifndef XlibSpecificationRelease
- #define PRE_R5_ICCCM
- #endif
- /*
- X Invoke pre-X11R4 ICCCM routines if PWinGravity is not defined.
- */
- #ifndef PWinGravity
- #define PRE_R4_ICCCM
- #endif
- #include "PreRvIcccm.h"
- SHAR_EOF
- chmod 0644 ImageMagick/X.h ||
- echo 'restore of ImageMagick/X.h failed'
- Wc_c="`wc -c < 'ImageMagick/X.h'`"
- test 6075 -eq "$Wc_c" ||
- echo 'ImageMagick/X.h: original size 6075, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= ImageMagick/animate.man ==============
- if test -f 'ImageMagick/animate.man' -a X"$1" != X"-c"; then
- echo 'x - skipping ImageMagick/animate.man (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting ImageMagick/animate.man (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/animate.man' &&
- .ad l
- .nh
- .TH ANIMATE 1 "10 October 1992" "ImageMagick"
- .SH NAME
- animate - display a sequence of images on any workstation running X
- .SH SYNOPSIS
- .B "animate" [ \fIoptions\fP ...] \fIfile\fP
- [ [ \fIoptions\fP ...] \fIfile\fP ...]
- .SH DESCRIPTION
- \fIAnimate\fP displays a sequence of images on any workstation display
- running an X server. \fIAnimate\fP first determines the hardware
- capabilities of the workstation. If the number of unique colors in an
- image is less than or equal to the number the workstation can support,
- the image is displayed in an X window. Otherwise the number of colors
- in the image is first reduced to match the color resolution of the
- workstation before it is displayed.
- .PP
- This means that a continuous-tone 24 bits-per-pixel image can display on a
- 8 bit pseudo-color device or monochrome device. In most instances the
- reduced color image closely resembles the original. Alternatively, a
- monochrome or pseudo-color image sequence can display on a continuous-tone
- 24 bits-per-pixel device.
- .PP
- To help prevent color flashing on X server visuals that have colormaps,
- \fIanimate\fP creates a single colormap from the image sequence. This can
- be rather time consuming. You can speed this operation up by reducing
- the colors in the image before you `animate' them. Use \fImogrify\fP
- to color reduce the images to a single colormap. See \fBmogrify(1)\fP for
- details. Alternatively, you can use a Standard Colormap; or a static, direct,
- or true color visual. You can define a Standard Colormap with
- \fIxstdcmap\fP. See \fBxstdcmap(1)\fP for details.
- .SH EXAMPLES
- To animate a set of images of a cockatoo, use:
- .PP
- X animate cockatoo.*
- .PP
- To animate a cockatoo image sequence while using the Standard Colormap
- "best", use:
- .PP
- X xstdcmap -best
- X animate -map best cockatoo.*
- .PP
- To animate an image of a cockatoo without a border centered on a
- backdrop, use:
- .PP
- X animate +borderwidth -backdrop cockatoo.*
- .SH OPTIONS
- .TP 5
- .B "-backdrop"
- display the image centered on a backdrop.
- X
- This backdrop covers the entire workstation screen and is useful for
- hiding other X window activity while viewing the image sequence. The color
- 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.
- X
- Use clipping to apply image processing options, or display, only a
- particular area of an image.
- X
- 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: \fIShared\fP or \fIPrivate\fP.
- X
- This option only applies when the default X server visual is
- \fIPseudoColor\fP or \fIGrayScale\fP. Refer to \fB-visual\fP for more
- details. By default, a shared colormap is allocated. The image shares
- colors with other X clients. Some image colors could be approximated,
- therefore your image may look very different than intended. Choose
- \fIPrivate\fP and the image colors appear exactly as they are
- defined. However, other clients may go "technicolor" when the image
- colormap is installed.
- .TP 5
- .B "-colors \fIvalue\fP"
- preferred number of colors in the image.
- X
- The actual number of colors in the image may be less than your request,
- but never more. Note, this is a color reduction option. Images with
- less unique colors than specified with this option will remain unchanged.
- Refer to \fBQuantize(9)\fP for more details.
- X
- Note, options \fB-dither\fP, \fB-colorspace\fP, and \fB-treedepth\fP affect
- the color reduction algorithm.
- .TP 5
- .B "-colorspace \fIvalue\fP"
- the type of colorspace: \fIGRAY\fP, \fIRGB\fP, \fIXYZ\fP, \fIYIQ\fP, or
- \fIYUV\fP.
- X
- Color reduction, by default, takes place in the RGB color space.
- Empirical evidence suggests that distances in color spaces such as YUV
- or YIQ correspond to perceptual color differences more closely
- than do distances in RGB space. These color spaces may give better
- results when color reducing an image. Refer to \fBQuantize(9)\fP for
- more details.
- X
- The \fB-colors\fP or \fB-monochrome\fP option is required for this option
- to take effect.
- .TP 5
- .B "-delay \fImilliseconds\fP"
- display the next image after pausing.
- X
- This option is useful for regulating the display of the sequence of
- images. \fImilliseconds\fP milliseconds must expire before the display of
- the next image. The default is to display each image without delay.
- .TP 5
- .B "-density \fI<width>x<height>
- vertical and horizonal density of the image.
- X
- This option specifies an image density whose interpretation changes
- with the type of image. The default is 72 dots per inch in the
- horizonal and vertical direction for Postscript. Text files default to
- 80 characters in width and 60 lines in height. Use this option to
- alter the default density.
- .TP 5
- .B "-display \fIhost:display[.screen]\fP"
- specifies the X server to contact; see \fBX(1)\fP.
- .TP 5
- .B "-dither"
- apply Floyd/Steinberg error diffusion to the image.
- X
- The basic strategy of dithering is to trade intensity resolution for
- spatial resolution by averaging the intensities of several neighboring
- pixels. Images which suffer from severe contouring when reducing colors
- can be improved with this option.
- X
- The \fB-colors\fP or \fB-monochrome\fP option is required for this option
- to take effect.
- .TP 5
- .B "-gamma \fIvalue\fP"
- level of gamma correction.
- X
- The same color image displayed on two different workstations may look
- different due to differences in the display monitor. Use gamma
- correction to adjust for this color difference. Reasonable values
- extend from 0.8 to 2.3.
- .TP 5
- .B "-geometry \fI<width>x<height>{\+-}<x offset>{\+-}<y offset>\fP"
- preferred size and location of the image window. See \fBX(1)\fP for details
- about the geometry specification. By default, the window size is the image
- size and the location is choosen by you when it is mapped.
- X
- If the specified image size 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 image is then scaled to the exact
- specified image size with pixel replication. If the specified image
- size is greater than the actual image size, the image is first enlarged
- to an integral of the specified image size with bilinear
- interpolation. The image is then scaled to the exact specified image
- size with pixel replication.
- X
- When displaying an image on an X server, \fI<x offset>\fP and
- \fI<y offset>\fP is relative to the root window.
- X
- The equivalent X resource for this option is \fBimageGeometry\fP
- (class \fBImageGeometry\fP). See \fBX RESOURCES\fP for details.
- .TP 5
- .B "-map \fItype\fP"
- animate images using this Standard Colormap type.
- X
- Choose from these Standard Colormap types:
- X
- X default
- X best
- X red
- X green
- X blue
- X gray
- X
- The X server must support the Standard Colormap you choose, otherwise an
- error occurs. See \fBxstdcmap(1)\fP for one way of creating Standard Colormaps.
- .TP 5
- .B "-monochrome"
- transform the image to black and white.
- X
- Monochrome images can benefit from error diffusion. Use \fB-dither\fP with
- this option to diffuse the error.
- .TP 5
- .B "-reflect"
- create a "mirror image" by reflecting the image scanlines.
- .TP 5
- .B "-rotate \fIdegrees\fP"
- apply Paeth image rotation to the image.
- .TP 5
- .B "-scale \fI<width factor>x<height factor>\fP"
- preferred size factors of the image.
- X
- This option behaves like \fB-geometry\fP except the width and height values
- are relative instead of absolute. The image size is multiplied by the
- width and height factors to obtain the final image dimensions. If only
- one factor is specified, both the width and height factors assume the
- value.
- X
- Factors may be fractional. For example, a factor of 1.5 will increase the
- image size by one and one-half.
- X
- The equivalent X resource for this option is \fBscaleGeometry\fP
- (class \fBScaleGeometry\fP). See \fBX RESOURCES\fP for details.
- .TP 5
- .B "-treedepth \fIvalue\fP"
- Normally, this integer value is zero or one. A zero or one tells
- \fIAnimate\fP to choose a optimal tree depth for the color reduction
- algorithm.
- X
- An optimal depth generally allows the best representation of the source
- image with the fastest computational speed and the least amount of
- memory. However, the default depth is inappropriate for some images.
- To assure the best representation, try values between 2 and 8 for this
- parameter. Refer to \fBQuantize(9)\fP for more details.
- X
- The \fB-colors\fP or \fB-monochrome\fP option is required for this option
- to take effect.
- .TP 5
- .B "-visual \fItype\fP"
- animate images using this visual type.
- X
- Choose from these visual classes:
- X
- X StaticGray
- X GrayScale
- X StaticColor
- X PseudoColor
- X TrueColor
- X DirectColor
- X default
- X \fIvisual id\fP
- X
- The X server must support the visual you choose, otherwise an error occurs.
- If a visual is not specified, the visual class that can display the most
- simultaneous colors on the default screen is choosen.
- .PP
- In addition to those listed above, you can specify these standard X
- resources as command line options: \fB-background\fP,
- \fB-bordercolor\fP, \fB-borderwidth\fP, \fB-font\fP,
- \fB-foreground\fP, \fB-iconGeometry\fP, \fB-iconic\fP, \fB-name\fP, or
- \fB-title\fP. See \fBX RESOURCES\fP for details.
- .PP
- Any option you specify on the command line remains in effect until it is
- explicitly changed by specifying the option again with a different effect.
- For example, to animate two images, the first with 32 colors and the
- second with only 16 colors, use:
- .PP
- X animate -colors 32 cockatoo.1 -colors 16 cockatoo.2
- .PP
- Change \fI-\fP to \fI\+\fP in any option above to reverse its effect.
- For example, specify \fB\+dither\fP to not apply error diffusion to an image.
- .PP
- \fIfile\fP specifies the image filename. By default, the image format
- is determined by its magic number. To specify a particular image format, precede
- the filename with an image format name and a colon (i.e.
- mtv:image) or specify the image type as the filename suffix (i.e. image.mtv).
- See \fBCONVERT(1)\fP for a list of valid image formats. Specify \fIfile\fP
- as \fI-\fP for standard input or output. If \fIfile\fP has the
- extension \fB.Z\fP, the file is decoded with \fIuncompress\fP.
- .PP
- Image filenames may appear in any order on the command line if the image
- format is \fIMIFF\fI (refer to \fBMIFF(5)\fI) and the \fIscene\fP keyword is
- specified in the image. Otherwise the images will display in the order
- they appear on the command line.
- .SH BUTTONS
- .TP 5
- .B "1"
- Press and drag to select a command from a pop-up menu. Choose from
- these commands:
- X
- X Play
- X Step
- X Repeat
- X Auto Reverse
- X Slower
- X Faster
- X Forward
- X Reverse
- X Image Info
- X Quit
- .SH KEYBOARD ACCELERATORS
- .TP 5
- .B "p"
- Press to animate the sequence of images.
- .TP 5
- .B "s"
- Press to display the next image in the sequence.
- .TP 5
- .B "."
- Press to continually display the sequence of images.
- .TP 5
- .B "a"
- Press to automatically reverse the sequence of images.
- .TP 5
- .B "<"
- Press to slow the display of the images. Refer to \fB-delay\fP for more
- information.
- .TP 5
- .B ">"
- Press to speed-up the display of the images. Refer to \fB-delay\fP for more
- information.
- .TP 5
- .B "f"
- Press to animate in the forward direction.
- .TP 5
- .B "r"
- Press to animate in the reverse direction.
- .TP 5
- .B "i"
- Press to display information about the image. Press any key or button
- to erase the information.
- X
- This information is printed: image name; image size; and the total
- number of unique colors in the image.
- .TP 5
- .B "q"
- Press to discard all images and exit program.
- .SH "X RESOURCES"
- \fIAnimate\fP options can appear on the command line or in your X
- resource file. Options on the command line supersede values specified
- in your X resource file. See \fBX(1)\fP for more information on X
- resources.
- X
- All \fIanimate\fP options have a corresponding X resource. In addition,
- the \fIanimate\fP program uses the following X resources:
- .TP 5
- .B background (\fPclass\fB Background)
- Specifies the preferred color to use for the image window background. The
- default is black.
- .TP 5
- .B borderColor (\fPclass\fB BorderColor)
- Specifies the preferred color to use for the image window border. The
- default is white.
- .TP 5
- .B borderWidth (\fPclass\fB BorderWidth)
- Specifies the width in pixels of the image window border. The default is 2.
- .TP 5
- .B font (\fPclass\fB Font)
- Specifies the name of the preferred font to use when displaying text
- within the image window. The default is \fI/g9x15\fP, \fIfixed\fP, or
- \fI/g6x13\fP determined by the image window size.
- .TP 5
- .B foreground (\fPclass\fB Foreground)
- Specifies the preferred color to use for text within the image window. The
- default is white.
- .TP 5
- .B iconGeometry (\fPclass\fB IconGeometry)
- Specifies the preferred size and position of the application when
- iconified. It is not necessarily obeyed by all window managers.
- .TP 5
- .B iconic (\fPclass\fB Iconic)
- This resource indicates that you would prefer that the application's
- windows initially not be visible as if the windows had be immediately
- iconified by you. Window managers may choose not to honor the
- application's request.
- .TP 5
- .B name (\fPclass\fB Name)
- This resource specifies the name under which resources for the
- application should be found. This resource is useful in shell aliases to
- distinguish between invocations of an application, without resorting to
- creating links to alter the executable file name. The default is the
- application name.
- .TP 5
- .B title (\fPclass\fB Title)
- This resource specifies the title to be used for the image window. This
- information is sometimes used by a window manager to provide some sort
- of header identifying the window. The default is the image file name.
- .SH ENVIRONMENT
- .TP 5
- .B DISPLAY
- To get the default host, display number, and screen.
- .SH SEE ALSO
- display(1), import(1), XtoPS(1), mogrify(1), convert(1), Quantize(9), MIFF(5),
- XX(1), xstdcmap(1), compress(1),
- MIFF(5)
- .SH COPYRIGHT
- Copyright 1992 E. I. du Pont de Nemours & Company
- .PP
- Permission to use, copy, modify, distribute, and sell this software and
- its documentation for any purpose is hereby granted without fee,
- provided that the above copyright notice appear in all copies and that
- both that copyright notice and this permission notice appear in
- supporting documentation, and that the name of E. I. du Pont de Nemours
- & Company not be used in advertising or publicity pertaining to
- distribution of the software without specific, written prior
- permission. E. I. du Pont de Nemours & Company makes no representations
- about the suitability of this software for any purpose. It is provided
- "as is" without express or implied warranty.
- .PP
- E. I. du Pont de Nemours & Company disclaims all warranties with regard
- to this software, including all implied warranties of merchantability
- and fitness, in no event shall E. I. du Pont de Nemours & Company be
- liable for any special, indirect or consequential damages or any
- damages whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action, arising
- out of or in connection with the use or performance of this software.
- .SH ACKNOWLEDGEMENTS
- The MIT X Consortium for making network transparent graphics a reality.
- .PP
- Michael Halle, Spatial Imaging Group at MIT, for the initial
- implementation of Alan Paeth's image rotation algorithm.
- .PP
- David Pensak, E. I. du Pont de Nemours & Company, for providing a
- computing environment that made this program possible.
- .PP
- Paul Raveling, USC Information Sciences Institute, for the original
- idea of using space subdivision for the color reduction algorithm.
- .SH AUTHORS
- John Cristy, E.I. du Pont de Nemours & Company Incorporated
- SHAR_EOF
- chmod 0644 ImageMagick/animate.man ||
- echo 'restore of ImageMagick/animate.man failed'
- Wc_c="`wc -c < 'ImageMagick/animate.man'`"
- test 15842 -eq "$Wc_c" ||
- echo 'ImageMagick/animate.man: original size 15842, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= ImageMagick/X.c ==============
- if test -f 'ImageMagick/X.c' -a X"$1" != X"-c"; then
- echo 'x - skipping ImageMagick/X.c (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting ImageMagick/X.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/X.c' &&
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % %
- % X X %
- % X X %
- % X %
- % X X %
- % X X %
- % %
- % X11 Utility Routines for Display. %
- % %
- % %
- % Software Design %
- % John Cristy %
- % July 1992 %
- % %
- % %
- % Copyright 1992 E. I. du Pont de Nemours & Company %
- % %
- % Permission to use, copy, modify, distribute, and sell this software and %
- % its documentation for any purpose is hereby granted without fee, %
- % provided that the above Copyright notice appear in all copies and that %
- % both that Copyright notice and this permission notice appear in %
- % supporting documentation, and that the name of E. I. du Pont de Nemours %
- % & Company not be used in advertising or publicity pertaining to %
- % distribution of the software without specific, written prior %
- % permission. E. I. du Pont de Nemours & Company makes no representations %
- % about the suitability of this software for any purpose. It is provided %
- % "as is" without express or implied warranty. %
- % %
- % E. I. du Pont de Nemours & Company disclaims all warranties with regard %
- % to this software, including all implied warranties of merchantability %
- % and fitness, in no event shall E. I. du Pont de Nemours & Company be %
- % liable for any special, indirect or consequential damages or any %
- % damages whatsoever resulting from loss of use, data or profits, whether %
- % in an action of contract, negligence or other tortious action, arising %
- % out of or in connection with the use or performance of this software. %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- %
- */
- X
- /*
- X Include declarations.
- */
- #include "display.h"
- #include "image.h"
- #include "X.h"
- X
- /*
- X State declarations.
- */
- #define ControlState 0x0001
- #define DefaultState 0x0000
- #define ExitState 0x0002
- X
- /*
- X External declarations.
- */
- extern char
- X *application_name;
- X
- extern void
- X Error _Declare((char *,char *));
- X
- /*
- X Forward declarations.
- */
- int
- X Latin1Compare _Declare((char *,char *));
- X
- static void
- X XMakeImageLSBFirst _Declare((XWindowInfo *,Image *, XImage *)),
- X XMakeImageMSBFirst _Declare((XWindowInfo *,Image *, XImage *));
- X
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % I s T r u e %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Function IsTrue returns True if the boolean is "true", "on", "yes" or "1".
- %
- % The format of the IsTrue routine is:
- %
- % option=IsTrue(boolean)
- %
- % A description of each parameter follows:
- %
- % o option: either True or False depending on the boolean parameter.
- %
- % o boolean: Specifies a pointer to a character array.
- %
- %
- */
- unsigned int IsTrue(boolean)
- char
- X *boolean;
- {
- X if (boolean == (char *) NULL)
- X return(False);
- X if (Latin1Compare(boolean,"true") == 0)
- X return(True);
- X if (Latin1Compare(boolean,"on") == 0)
- X return(True);
- X if (Latin1Compare(boolean,"yes") == 0)
- X return(True);
- X if (Latin1Compare(boolean,"1") == 0)
- X return(True);
- X return(False);
- }
- X
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % L a t i n 1 C o m p a r e %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Function Latin1Compare compares two null terminated Latin-1 strings,
- % ignoring case differences, and returns an integer greater than, equal
- % to, or less than 0, according to whether first is lexicographically
- % greater than, equal to, or less than second. The two strings are
- % assumed to be encoded using ISO 8859-1.
- %
- % The format of the Latin1Upper routine is:
- %
- % Latin1Upper(first,second)
- %
- % A description of each parameter follows:
- %
- % o first: A pointer to the string to convert to Latin1 string.
- %
- % o second: A pointer to the string to convert to Latin1 string.
- %
- %
- */
- int Latin1Compare(first,second)
- char
- X *first,
- X *second;
- {
- X register unsigned char
- X *p,
- X *q;
- X
- X p=(unsigned char *) first;
- X q=(unsigned char *) second;
- X while ((*p != '\0') && (*q != '\0'))
- X {
- X register unsigned char
- X c,
- X d;
- X
- X c=(*p);
- X d=(*q);
- X if (c != d)
- X {
- X /*
- X Try lowercasing and try again.
- X */
- X if ((c >= XK_A) && (c <= XK_Z))
- X c+=(XK_a-XK_A);
- X else
- X if ((c >= XK_Agrave) && (c <= XK_Odiaeresis))
- X c+=(XK_agrave-XK_Agrave);
- X else
- X if ((c >= XK_Ooblique) && (c <= XK_Thorn))
- X c+=(XK_oslash-XK_Ooblique);
- X if ((d >= XK_A) && (d <= XK_Z))
- X d+=(XK_a-XK_A);
- X else
- X if ((d >= XK_Agrave) && (d <= XK_Odiaeresis))
- X d+=(XK_agrave-XK_Agrave);
- X else if ((d >= XK_Ooblique) && (d <= XK_Thorn))
- X d+=(XK_oslash-XK_Ooblique);
- X if (c != d)
- X return(((int) c)-((int) d));
- X }
- X p++;
- X q++;
- X }
- X return(((int) *p)-((int) *q));
- }
- X
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % L a t i n 1 U p p e r %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Function Latin1Upper copies a null terminated string from src to dst
- % (including the null), changing all Latin-1 lowercase letters to
- % uppercase. The string is assumed to be encoded using ISO 8859-1.
- %
- % The format of the Latin1Upper routine is:
- %
- % Latin1Upper(string)
- %
- % A description of each parameter follows:
- %
- % o string: A pointer to the string to convert to upper-case Latin1.
- %
- %
- */
- void Latin1Upper(string)
- char
- X *string;
- {
- X unsigned char
- X c;
- X
- X c=(*string);
- X while (c != '\0')
- X {
- X if ((c >= XK_a) && (c <= XK_z))
- X *string=c-(XK_a-XK_A);
- X else
- X if ((c >= XK_agrave) && (c <= XK_odiaeresis))
- X *string=c-(XK_agrave-XK_Agrave);
- X else
- X if ((c >= XK_oslash) && (c <= XK_thorn))
- X *string=c-(XK_oslash-XK_Ooblique);
- X string++;
- X c=(*string);
- X }
- }
- X
- /*
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % %
- % %
- % %
- % R e a d T E X T I m a g e %
- % %
- % %
- % %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %
- % Function ReadTEXTImage reads a text file and returns it as an image. It
- % allocates the memory necessary for the new Image structure and returns a
- % pointer to the new image.
- %
- % The format of the ReadTEXTImage routine is:
- %
- % image=ReadTEXTImage(filename,server_name,font,density)
- %
- % A description of each parameter follows:
- %
- % o image: Function ReadTEXTImage 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 filename: Specifies the name of the image to read.
- %
- % o server_name: Specifies the name of the X server to read fonts from.
- %
- % o font: Specifies the name of an X font to use for writing the text.
- %
- % o density: Specifies the vertical and horizonal density of the image.
- %
- %
- */
- Image *ReadTEXTImage(filename,server_name,font,density)
- char
- X *filename,
- X *server_name,
- X *font,
- X *density;
- {
- #define PageHeight 60
- #define PageWidth 80
- X
- X char
- X *resource_value,
- X *text_status,
- X text[2048];
- X
- X Display
- X *display;
- X
- X Image
- X *image;
- X
- X int
- X status,
- X x,
- X y;
- X
- X register int
- X i;
- X
- X register RunlengthPacket
- X *p;
- X
- X RunlengthPacket
- X background_color;
- X
- X unsigned int
- X height,
- X width;
- X
- X XAnnotateInfo
- X annotate_info;
- X
- X XFontStruct
- X *font_info;
- X
- X XPixelInfo
- X pixel_info;
- X
- X XResourceInfo
- X resource_info;
- X
- X XrmDatabase
- X resource_database,
- X server_database;
- X
- X XStandardColormap
- X map_info;
- X
- X XVisualInfo
- X *visual_info;
- X
- X XWindowInfo
- X image_window;
- X
- X /*
- X Allocate image structure.
- X */
- X image=AllocateImage("TEXT");
- X if (image == (Image *) NULL)
- X return((Image *) NULL);
- X /*
- X Open image file.
- X */
- X (void) strcpy(image->filename,filename);
- X OpenImage(image,"r");
- X if (image->file == (FILE *) NULL)
- X {
- X Warning("unable to open file",image->filename);
- X DestroyImage(image);
- X return((Image *) NULL);
- X }
- X /*
- X Open X server connection.
- X */
- X display=XOpenDisplay(server_name);
- X if (display == (Display *) NULL)
- X {
- X Warning("unable to connect to X server",XDisplayName(server_name));
- X return((Image *) NULL);
- X }
- X /*
- X Set our forgiving error handler.
- X */
- X XSetErrorHandler(XError);
- X /*
- X Initialize resource database.
- X */
- X XrmInitialize();
- X resource_database=XrmGetDatabase(display);
- X resource_value=XResourceManagerString(display);
- X if (resource_value == (char *) NULL)
- X resource_value="";
- X server_database=XrmGetStringDatabase(resource_value);
- X XrmMergeDatabases(server_database,&resource_database);
- X /*
- X Get user defaults from X resource database.
- X */
- X XGetResourceInfo(resource_database,application_name,&resource_info);
- X /*
- X Initialize visual info.
- X */
- X visual_info=XBestVisualInfo(display,"default",(char *) NULL,
- X (XStandardColormap *) NULL);
- X if (visual_info == (XVisualInfo *) NULL)
- X {
- X Warning("unable to get visual",resource_info.visual_type);
- X return((Image *) NULL);
- X }
- X /*
- X Determine background and foreground colors.
- X */
- X map_info.colormap=XDefaultColormap(display,visual_info->screen);
- X XGetPixelInfo(display,visual_info,&map_info,&resource_info,(Image *) NULL,
- X &pixel_info);
- X pixel_info.annotate_color=pixel_info.foreground_color;
- X pixel_info.annotate_index=1;
- X /*
- X Initialize font info.
- X */
- X if (font != (char *) NULL)
- X resource_info.font=font;
- X font_info=XBestFont(display,&resource_info,(char *) NULL,~0);
- X if (font_info == (XFontStruct *) NULL)
- X {
- X Warning("unable to load font",resource_info.font);
- X return((Image *) NULL);
- X }
- X /*
- X Window superclass.
- X */
- X image_window.id=XRootWindow(display,visual_info->screen);
- X image_window.screen=visual_info->screen;
- X image_window.depth=visual_info->depth;
- X image_window.visual_info=visual_info;
- X image_window.pixel_info=(&pixel_info);
- X image_window.font_info=font_info;
- X /*
- X Initialize Image structure.
- X */
- X width=PageWidth;
- X height=PageHeight;
- X if (density != (char *) NULL)
- X (void) XParseGeometry(density,&x,&y,&width,&height);
- X image->columns=width*font_info->max_bounds.width+4;
- X image->rows=height*
- X (font_info->max_bounds.ascent+font_info->max_bounds.descent)+4;
- X image->packets=image->columns*image->rows;
- X image->pixels=(RunlengthPacket *)
- X malloc((unsigned int) image->packets*sizeof(RunlengthPacket));
- X image->comments=(char *) malloc((strlen(image->filename)+2048)*sizeof(char));
- X if ((image->pixels == (RunlengthPacket *) NULL) ||
- SHAR_EOF
- true || echo 'restore of ImageMagick/X.c failed'
- fi
- echo 'End of part 14'
- echo 'File ImageMagick/X.c is continued in part 15'
- echo 15 > _shar_seq_.tmp
- exit 0
- exit 0 # Just in case...
-