cristy@dupont.com (05/24/91)
Submitted-by: cristy@dupont.com Posting-number: Volume 13, Issue 37 Archive-name: imagemagic/part21 #!/bin/sh # this is img.21 (part 21 of ImageMagick) # do not concatenate these parts, unpack them in order with /bin/sh # file ImageMagick/animate.c continued # if test ! -r _shar_seq_.tmp; then echo 'Please unpack part 1 first!' exit 1 fi (read Scheck if test "$Scheck" != 21; 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/animate.c' else echo 'x - continuing file ImageMagick/animate.c' sed 's/^X//' << 'SHAR_EOF' >> 'ImageMagick/animate.c' && %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function Delay suspends animation for the number of milliseconds specified. % % The format of the Delay routine is: % % Delay(milliseconds) % % A description of each parameter follows: % % o milliseconds: Specifies the number of milliseconds to delay before % returning. % % */ void Timer() { } X void Delay(milliseconds) unsigned long X milliseconds; { #include <signal.h> X #ifndef vms X struct itimerval X timer; X X if (milliseconds == 0) X return; X /* X Schedule interval timer. X */ X timer.it_interval.tv_sec=0; X timer.it_interval.tv_usec=0; X timer.it_value.tv_sec=milliseconds/1000; X timer.it_value.tv_usec=(milliseconds % 1000)*1000; X (void) signal(SIGALRM,Timer); X (void) setitimer(ITIMER_REAL,&timer,(struct itimerval *) NULL); X (void) pause(); #endif } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % E r r o r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function Error displays an error message and then terminates the program. % % The format of the Error routine is: % % Error(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. % % */ void Error(message,qualifier) char X *message, X *qualifier; { X (void) fprintf(stderr,"%s: %s",application_name,message); X if (qualifier != (char *) NULL) X (void) fprintf(stderr," (%s)",qualifier); X (void) fprintf(stderr,".\n"); X exit(1); } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % U s a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function Usage displays the program command syntax. % % The format of the Usage routine is: % % Usage(message,terminate) % % A description of each parameter follows: % % o message: Specifies a specific message to display to the user. % % o terminate: The program will exit if the value is not zero. % % */ static void Usage(message,terminate) char X *message; X unsigned int X terminate; { X char X **p; X X static char X *buttons[]= X { X "1 press and drag to select a command from a pop-up menu", X (char *) NULL X }, X *keys[]= X { X "0-9 press to change the level of delay", X "p press to animate the sequence of images", X "s press to display the next image in the sequence", X ". press to continually display the sequence of images", X "a press to automatically reverse the sequence of images", X "f press to animate in the forward direction", X "r press to animate in the reverse direction", X "i press to display information about the image", X "q press to discard all images and exit program", X (char *) NULL X }, X *options[]= X { X "-backdrop display image centered on a backdrop", X "-clip geometry preferred size and location of the clipped image", X "-colors value preferred number of colors in the image", X "-compress type compress image: RunlengthEncoded or QEncoded", X "-delay milliseconds display the next image after pausing", X "-display server display image to this X server", X "-dither apply Floyd/Steinberg error diffusion to image", X "-gamma value level of gamma correction", X "-geometry geometry preferred size and location of the image window", X "-gray transform image to gray scale colors", X "-map type display image using this Standard Colormap", X "-monochrome transform image to black and white", X "-reflect reflect the image scanlines", X "-rotate degrees apply Paeth rotation to the image", X "-scale geometry preferred size factors of the image", X "-treedepth value depth of the color classification tree", X "-verbose print detailed information about the image", X "-visual type display image using this visual type", X (char *) NULL X }; X if (message != (char *) NULL) X (void) fprintf(stderr,"Can't continue, %s\n\n",message); X (void) fprintf(stderr, X "Usage: %s [-options ...] file [ [-options ...] file ...]\n", X application_name); X (void) fprintf(stderr,"\nWhere options include: \n"); X for (p=options; *p != (char *) NULL; p++) X (void) fprintf(stderr," %s\n",*p); X (void) fprintf(stderr, X "\nIn addition to those listed above, you can specify these standard X\n"); X (void) fprintf(stderr, X "resources as command line options: -background, -bordercolor,\n"); X (void) fprintf(stderr, X "-borderwidth, -font, -foreground, -iconGeometry, -iconic, -name, or\n"); X (void) fprintf(stderr,"-title.\n"); X (void) fprintf(stderr, X "\nChange '-' to '+' in any option above to reverse its effect. For\n"); X (void) fprintf(stderr, X "example, specify +compress to store the image as uncompressed.\n"); X (void) fprintf(stderr, X "\nSpecify 'file' as '-' for standard input or output.\n"); X (void) fprintf(stderr,"\nButtons: \n"); X for (p=buttons; *p != (char *) NULL; p++) X (void) fprintf(stderr," %s\n",*p); X (void) fprintf(stderr,"\nKeys: \n"); X for (p=keys; *p != (char *) NULL; p++) X (void) fprintf(stderr," %s\n",*p); X if (terminate) X exit(1); } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % U s e r C o m m a n d % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function UserCommand makes a transform to the image or image window as % specified by a user menu button or keyboard command. % % The format of the UserCommand routine is: % % UserCommand(display,info_window,image_window,image,command,state); % % A description of each parameter follows: % % o display: Specifies a connection to an X server; returned from % XOpenDisplay. % % o info_window: Specifies a pointer to a XWindowInfo structure. % % o image_window: Specifies a pointer to a XWindowInfo structure. % % o image: Specifies a pointer to a Image structure; UserCommand % may transform the image and return a new image pointer. % % o state: Specifies an unsigned int; UserCommand may return a % modified state. % % */ static void UserCommand(display,info_window,image_window,command,image,state) Display X *display; X XXWindowInfo X *info_window, X *image_window; X char X *command; X Image X **image; X unsigned int X *state; { X if (*state & InfoMappedState) X XWithdrawWindow(display,info_window->id,info_window->screen); X /* X Process user command. X */ X switch (*command) X { X case 'i': X { X char X text[256]; X X /* X Display information about the image in the info window. X */ X (void) sprintf(text," [%d] %s %dx%d \0",(*image)->scene, X (*image)->filename,image_window->width,image_window->height); X if ((*image)->colors > 0) X (void) sprintf(text,"%s%dc \0",text,(*image)->colors); X info_window->width=XTextWidth(info_window->font_info,text,strlen(text)); X info_window->height= X info_window->font_info->ascent+info_window->font_info->descent+4; X XResizeWindow(display,info_window->id,info_window->width, X info_window->height); X XMapWindow(display,info_window->id); X XClearWindow(display,info_window->id); X XDrawString(display,info_window->id,info_window->graphic_context,2, X info_window->font_info->ascent+2,text,(unsigned int) strlen(text)); X break; X } X case 'p': X { X *state|=PlayAnimationState; X *state&=(~AutoReverseAnimationState); X break; X } X case 's': X { X *state|=StepAnimationState; X *state&=(~PlayAnimationState); X break; X } X case '.': X { X *state|=RepeatAnimationState; X *state&=(~AutoReverseAnimationState); X *state|=PlayAnimationState; X break; X } X case 'a': X { X *state|=AutoReverseAnimationState; X *state&=(~RepeatAnimationState); X *state|=PlayAnimationState; X break; X } X case 'f': X { X *state=ForwardAnimationState; X *state&=(~AutoReverseAnimationState); X break; X } X case 'r': X { X *state&=(~ForwardAnimationState); X *state&=(~AutoReverseAnimationState); X break; X } X case 'q': X { X /* X Exit program X */ X *state|=ExitState; /* exit program */ X break; X } X case ' ': X case '\0': X break; X default: X { X XBell(display,0); X break; X } X } } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % X A n i m a t e I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function XAnimateImage displays an image via X11. % % The format of the XAnimateImage routine is: % % XAnimateImage(display,resource_info,argv,argc,image,number_scenes) % % A description of each parameter follows: % % o display: Specifies a connection to an X server; returned from % XOpenDisplay. % % o resource_info: Specifies a pointer to a X11 XResourceInfo structure. % % o argv: Specifies the application's argument list. % % o argc: Specifies the number of arguments. % % o image: Specifies a pointer to a Image structure; returned from % ReadImage. % % */ static int LinearCompare(image_1,image_2) Image X **image_1, X **image_2; { X return((int) (*image_1)->scene-(int) (*image_2)->scene); } X static void XAnimateImage(display,resource_info,argv,argc,images,number_scenes) Display X *display; X XXResourceInfo X *resource_info; X char X **argv; X int X argc; X Image X **images; X unsigned int X number_scenes; { X Atom X delete_property, X protocols_property; X X Colormap X colormap; X X char X text[256]; X X Cursor X arrow_cursor, X watch_cursor; X X GC X graphic_context; X X int X scene; X X unsigned int X state; X X Window X root_window; X X XClassHint X *class_hint; X X XColor X color; X X XEvent X event; X X XFontStruct X *font_info; X X XGCValues X graphic_context_value; X X XPixelInfo X *pixel_info; X X XStandardColormap X **map_info; X X XVisualInfo X *visual_info; X X XWindowInfo X backdrop_window, X icon_window, X image_window, X info_window, X menu_window, X superclass_window; X X XWMHints X *manager_hints; X X /* X Sort images by increasing scene number. X */ X qsort((char *) images,(int) number_scenes,sizeof(Image *),LinearCompare); X /* X Allocate pixel and map info. X */ X pixel_info=(XPixelInfo *) malloc(number_scenes*sizeof(XPixelInfo)); X map_info=(XStandardColormap **) X malloc(number_scenes*sizeof(XStandardColormap *)); X if ((pixel_info == (XPixelInfo *) NULL) || X (map_info == (XStandardColormap **) NULL)) X Error("unable to animate images","memory allocation failed"); X /* X Get the best visual this server supports. X */ X visual_info=XBestVisualInfo(display,resource_info->visual_type, X resource_info->map_type,&map_info[0]); X if (visual_info == (XVisualInfo *) NULL) X Error("unable to get visual",resource_info->visual_type); X /* X Initialize colormap. X */ X pixel_info[0].pixels=(unsigned long *) NULL; X if (resource_info->map_type == (char *) NULL) X { X /* X Create Standard Colormap. X */ X map_info[0]=XMakeStandardColormap(display,visual_info,resource_info, X &pixel_info[0],images[0]); X colormap=map_info[0]->colormap; X } X else X { X if (images[0]->class == PseudoClass) X { X register int X i; X X /* X Initialize pixel array for images of type PseudoClass. X */ X pixel_info[0].pixels=(unsigned long *) X malloc((unsigned int) images[0]->colors*sizeof(unsigned long)); X if (pixel_info[0].pixels == (unsigned long *) NULL) X Error("unable to create colormap","memory allocation failed"); X for (i=0; i < images[0]->colors; i++) X pixel_info[0].pixels[i]= X XStandardPixel(map_info[0],images[0]->colormap[i],8); X } X /* X Define background/border/foreground pixels. X */ X colormap=map_info[0]->colormap; X XParseColor(display,colormap,resource_info->background_color,&color); X pixel_info[0].background_pixel=XStandardPixel(map_info[0],color,16); X XParseColor(display,colormap,resource_info->border_color,&color); X pixel_info[0].border_pixel=XStandardPixel(map_info[0],color,16); X XParseColor(display,colormap,resource_info->foreground_color,&color); X pixel_info[0].foreground_pixel=XStandardPixel(map_info[0],color,16); X } X /* X Initialize font info. X */ X (void) sprintf(text," [%d] %s %dx%d \0",number_scenes, X images[0]->filename,images[0]->columns,images[0]->rows); X font_info=XBestFont(display,resource_info,text,images[0]->columns); X if (font_info == (XFontStruct *) NULL) X Error("unable to load font",resource_info->font_name); X /* X Initialize cursor. X */ X arrow_cursor=XCreateFontCursor(display,XC_arrow); X watch_cursor=XCreateFontCursor(display,XC_watch); X if ((arrow_cursor == (Cursor) NULL) || (watch_cursor == (Cursor) NULL)) X Error("unable to create cursor",(char *) NULL); X /* X Initialize atoms. X */ X protocols_property=XInternAtom(display,"WM_PROTOCOLS",False); X delete_property=XInternAtom(display,"WM_DELETE_WINDOW",False); X if ((protocols_property == (Atom) NULL) || (delete_property == (Atom) NULL)) X Error("unable to create property",(char *) NULL); X /* X Initialize class and manager hints. X */ X class_hint=XAllocClassHint(); X manager_hints=XAllocWMHints(); X if ((class_hint == (XClassHint *) NULL) || X (manager_hints == (XWMHints *) NULL)) X Error("unable to allocate X hints",(char *) NULL); X if (resource_info->name == (char *) NULL) X class_hint->res_name=application_name; X else X class_hint->res_name=resource_info->name; X class_hint->res_class=(char *) "ImageMagick"; X manager_hints->flags=InputHint | StateHint; X manager_hints->input=False; X manager_hints->initial_state=NormalState; X /* X Window superclass. X */ X superclass_window.screen=visual_info->screen; X superclass_window.depth=visual_info->depth; X superclass_window.visual_info=visual_info; X superclass_window.map_info=map_info[0]; X superclass_window.pixel_info=(&pixel_info[0]); X superclass_window.font_info=font_info; X superclass_window.cursor=arrow_cursor; X superclass_window.busy_cursor=watch_cursor; X superclass_window.name="ImageMagick SuperClass"; X superclass_window.geometry=(char *) NULL; X superclass_window.icon_geometry=resource_info->icon_geometry; X superclass_window.clip_geometry=(char *) NULL; X superclass_window.flags=PSize; X superclass_window.x=0; X superclass_window.y=0; X superclass_window.width=1; X superclass_window.height=1; X superclass_window.min_width=0; X superclass_window.min_height=0; X superclass_window.width_inc=1; X superclass_window.height_inc=1; X superclass_window.border_width=2; X superclass_window.immutable=True; X superclass_window.attributes.background_pixel=pixel_info[0].background_pixel; X superclass_window.attributes.background_pixmap=(Pixmap) NULL; X superclass_window.attributes.backing_store=WhenMapped; X superclass_window.attributes.bit_gravity=ForgetGravity; X superclass_window.attributes.border_pixel=pixel_info[0].border_pixel; X superclass_window.attributes.colormap=colormap; X superclass_window.attributes.cursor=arrow_cursor; X superclass_window.attributes.do_not_propagate_mask=NoEventMask; X superclass_window.attributes.event_mask=NoEventMask; X superclass_window.attributes.override_redirect=False; X superclass_window.attributes.save_under=False; X superclass_window.attributes.win_gravity=NorthWestGravity; X superclass_window.graphic_context=(GC) NULL; X superclass_window.ximage=(XImage *) NULL; X /* X Initialize graphic context. X */ X root_window=XRootWindow(display,visual_info->screen); X XMakeWindow(display,root_window,argv,argc,class_hint,manager_hints, X delete_property,&superclass_window); X graphic_context_value.background=pixel_info[0].background_pixel; X graphic_context_value.foreground=pixel_info[0].foreground_pixel; X graphic_context_value.font=font_info->fid; X graphic_context_value.function=GXcopy; X graphic_context_value.graphics_exposures=False; X graphic_context_value.plane_mask=AllPlanes; X graphic_context=XCreateGC(display,superclass_window.id,GCBackground | X GCFont | GCForeground | GCFunction | GCGraphicsExposures | GCPlaneMask, X &graphic_context_value); X if (graphic_context == (GC) NULL) X Error("unable to create graphic context",(char *) NULL); X superclass_window.graphic_context=graphic_context; X /* X Initialize icon window. X */ X icon_window=superclass_window; X icon_window.name="ImageMagick Icon"; X XBestIconSize(display,&icon_window,images[0]); X icon_window.attributes.event_mask=ExposureMask | StructureNotifyMask; X manager_hints->flags=InputHint | StateHint | WindowGroupHint; X manager_hints->input=False; X manager_hints->initial_state=IconicState; X manager_hints->window_group=superclass_window.id; X XMakeWindow(display,root_window,argv,argc,class_hint,manager_hints, X delete_property,&icon_window); X /* X Create icon image. X */ X icon_window.ximage=XMakeImage(display,resource_info,&icon_window,images[0], X icon_window.width,icon_window.height); X if (icon_window.ximage == (XImage *) NULL) X Error("unable to create icon image",(char *) NULL); X /* X Initialize image window. X */ X image_window=superclass_window; X image_window.name=(char *) malloc(256); X if (image_window.name == NULL) X Error("unable to create image window","memory allocation failed"); X if (resource_info->title == (char *) NULL) X (void) sprintf(image_window.name,"ImageMagick: %s\0",images[0]->filename); X else X (void) strcpy(image_window.name,resource_info->title); X image_window.geometry=resource_info->image_geometry; X image_window.width=images[0]->columns; X if (image_window.width > XDisplayWidth(display,visual_info->screen)) X image_window.width=XDisplayWidth(display,visual_info->screen); X image_window.height=images[0]->rows; X if (image_window.height > XDisplayHeight(display,visual_info->screen)) X image_window.height=XDisplayHeight(display,visual_info->screen); X image_window.border_width=resource_info->border_width; X backdrop_window=superclass_window; X if (resource_info->backdrop) X { X /* X Initialize backdrop window. X */ X backdrop_window.name="ImageMagick Background"; X backdrop_window.flags=USSize | USPosition; X backdrop_window.width=XDisplayWidth(display,visual_info->screen); X backdrop_window.height=XDisplayHeight(display,visual_info->screen); X backdrop_window.border_width=0; X backdrop_window.immutable=True; X backdrop_window.attributes.do_not_propagate_mask= X ButtonPressMask | ButtonReleaseMask; X manager_hints->flags=IconWindowHint | InputHint | StateHint | X WindowGroupHint; X manager_hints->icon_window=icon_window.id; X manager_hints->input=True; X manager_hints->initial_state= X resource_info->iconic ? IconicState : NormalState; X manager_hints->window_group=superclass_window.id; X XMakeWindow(display,root_window,argv,argc,class_hint,manager_hints, X delete_property,&backdrop_window); X XSetTransientForHint(display,backdrop_window.id,backdrop_window.id); X XMapWindow(display,backdrop_window.id); X /* X Position image in the center the backdrop. X */ X image_window.flags|=USPosition; X image_window.x=XDisplayWidth(display,visual_info->screen)/2- X (image_window.width+image_window.border_width)/2; X image_window.y=XDisplayHeight(display,visual_info->screen)/2- X (image_window.height+image_window.border_width)/2; X } X image_window.immutable=False; X image_window.attributes.cursor=image_window.cursor; X image_window.attributes.event_mask=ButtonMotionMask | ButtonPressMask | X ButtonReleaseMask | EnterWindowMask | ExposureMask | KeyPressMask | X LeaveWindowMask | OwnerGrabButtonMask | StructureNotifyMask; X manager_hints->flags= X IconWindowHint | InputHint | StateHint | WindowGroupHint; X manager_hints->icon_window=icon_window.id; X manager_hints->input=True; X manager_hints->initial_state= X resource_info->iconic ? IconicState : NormalState; X manager_hints->window_group=superclass_window.id; X XMakeWindow(display,(resource_info->backdrop ? backdrop_window.id : X root_window),argv,argc,class_hint,manager_hints,delete_property, X &image_window); X XMapWindow(display,image_window.id); X /* X Create X image. X */ X image_window.ximage=XMakeImage(display,resource_info,&image_window,images[0], X images[0]->columns,images[0]->rows); X if (image_window.ximage == (XImage *) NULL) X Error("unable to create X image",(char *) NULL); X /* X Create X pixmap. X */ X image_window.pixmaps=(Pixmap *) malloc(number_scenes*sizeof(Pixmap)); X if (image_window.pixmaps == (Pixmap *) NULL) X Error("unable to animate images","memory allocation failed"); X image_window.pixmaps[0]=XCreatePixmap(display,image_window.id, X images[0]->columns,images[0]->rows,image_window.depth); X XPutImage(display,image_window.pixmaps[0],image_window.graphic_context, X image_window.ximage,0,0,0,0,image_window.width,image_window.height); X XDestroyImage(image_window.ximage); X (void) free((char *) images[0]->pixels); X images[0]->pixels=(RunlengthPacket *) NULL; X /* X Initialize menu window. X */ X menu_window=superclass_window; X menu_window.name="ImageMagick Menu"; X menu_window.flags=PSize | PPosition; X menu_window.attributes.override_redirect=True; X menu_window.attributes.save_under=True; X menu_window.attributes.event_mask=ButtonMotionMask | ButtonPressMask | X ButtonReleaseMask | EnterWindowMask | ExposureMask | LeaveWindowMask | X OwnerGrabButtonMask; X manager_hints->flags=InputHint | StateHint | WindowGroupHint; X manager_hints->input=False; X manager_hints->initial_state=NormalState; X manager_hints->window_group=superclass_window.id; X XMakeWindow(display,root_window,argv,argc,class_hint,manager_hints, X delete_property,&menu_window); X XSetTransientForHint(display,menu_window.id,image_window.id); X /* X Initialize info window. X */ X info_window=superclass_window; X info_window.name="ImageMagick Info"; X info_window.flags=PSize | PPosition; X info_window.x=2; X info_window.y=2; X info_window.attributes.event_mask=StructureNotifyMask; X manager_hints->flags=InputHint | StateHint | WindowGroupHint; X manager_hints->input=False; X manager_hints->initial_state=NormalState; X manager_hints->window_group=superclass_window.id; X XMakeWindow(display,image_window.id,argv,argc,class_hint,manager_hints, X delete_property,&info_window); X /* X Initialize image pixmaps structure. X */ X XDefineCursor(display,image_window.id,image_window.busy_cursor); X XMapWindow(display,info_window.id); X for (scene=1; scene < number_scenes; scene++) X { X /* X Display information about the image in the info window. X */ X (void) sprintf(text," [%d] %s %dx%d \0",images[scene]->scene, X images[scene]->filename,image_window.width,image_window.height); X if (images[scene]->colors > 0) X (void) sprintf(text,"%s%dc \0",text,images[scene]->colors); X info_window.width=XTextWidth(info_window.font_info,text,strlen(text)); X info_window.height= X info_window.font_info->ascent+info_window.font_info->descent+4; X XResizeWindow(display,info_window.id,info_window.width,info_window.height); X XClearWindow(display,info_window.id); X XDrawString(display,info_window.id,info_window.graphic_context,2, X info_window.font_info->ascent+2,text,(unsigned int) strlen(text)); X /* X Initialize colormap. X */ X pixel_info[scene].pixels=(unsigned long *) NULL; X if (resource_info->map_type == (char *) NULL) X map_info[scene]=XMakeStandardColormap(display,visual_info,resource_info, X &pixel_info[scene],images[scene]); X else X { X /* X Propogate identical Standard Colormap to each scene. X */ X map_info[scene]=map_info[0]; X if (images[scene]->class == PseudoClass) X { X register int X i; X X /* X Initialize pixel array for images of type PseudoClass. X */ X pixel_info[scene].pixels=(unsigned long *) malloc((unsigned int) X images[scene]->colors*sizeof(unsigned long)); X if (pixel_info[scene].pixels == (unsigned long *) NULL) X Error("unable to create colormap","memory allocation failed"); X for (i=0; i < images[scene]->colors; i++) X pixel_info[scene].pixels[i]= X XStandardPixel(map_info[scene],images[scene]->colormap[i],8); X } X pixel_info[scene].background_pixel=pixel_info[0].background_pixel; X pixel_info[scene].border_pixel=pixel_info[0].border_pixel; X pixel_info[scene].foreground_pixel=pixel_info[0].foreground_pixel; X } X if (colormap != map_info[scene]->colormap) X { X /* X Set image window colormap. X */ X colormap=map_info[scene]->colormap; X XSetWindowColormap(display,image_window.id,colormap); X XInductColormap(display,colormap); X XSync(display,False); X } X /* X Create X image. X */ X image_window.map_info=map_info[scene]; X image_window.pixel_info=(&pixel_info[scene]); X image_window.ximage=XMakeImage(display,resource_info,&image_window, X images[scene],images[scene]->columns,images[scene]->rows); X if (image_window.ximage == (XImage *) NULL) X Error("unable to create X image",(char *) NULL); X /* X Create X pixmap. X */ X image_window.pixmaps[scene]=XCreatePixmap(display,image_window.id, X images[scene]->columns,images[scene]->rows,image_window.depth); X XPutImage(display,image_window.pixmaps[scene],image_window.graphic_context, X image_window.ximage,0,0,0,0,image_window.width,image_window.height); X XDestroyImage(image_window.ximage); X (void) free((char *) images[scene]->pixels); X images[scene]->pixels=(RunlengthPacket *) NULL; X /* X Copy X pixmap to image window. X */ X XCopyArea(display,image_window.pixmaps[scene],image_window.id, X image_window.graphic_context,0,0,image_window.width,image_window.height, X 0,0); X XSync(display,False); X } X XWithdrawWindow(display,info_window.id,info_window.screen); X XDefineCursor(display,image_window.id,image_window.cursor); X /* X Respond to events. X */ X state=DefaultState; X scene=0; X do X { X if (XEventsQueued(display,QueuedAfterFlush) == 0) X if ((state & PlayAnimationState) || (state & StepAnimationState)) X { X if (state & InfoMappedState) X XWithdrawWindow(display,info_window.id,info_window.screen); X if (colormap != map_info[scene]->colormap) X { X /* X Set image window colormap. X */ X colormap=map_info[scene]->colormap; X XSetWindowColormap(display,image_window.id,colormap); X XInductColormap(display,colormap); X XSync(display,False); X } X /* X Copy X pixmap to image window. X */ X XCopyArea(display,image_window.pixmaps[scene],image_window.id, X image_window.graphic_context,0,0,image_window.width, X image_window.height,0,0); X XSync(display,False); X if (state & StepAnimationState) X { X state&=(~StepAnimationState); X UserCommand(display,&info_window,&image_window,"i", X &images[scene],&state); X } X if (resource_info->delay > 0) X Delay((unsigned long) resource_info->delay); X if (state & ForwardAnimationState) X { X /* X Forward animation: increment scene number. X */ X scene++; X if (scene == number_scenes) X if (state & AutoReverseAnimationState) X { X state&=(~ForwardAnimationState); X scene--; X } X else X { X if (!(state & RepeatAnimationState)) X state&=(~PlayAnimationState); X scene=0; X } X } X else X { X /* X Reverse animation: decrement scene number. X */ X scene--; X if (scene < 0) X if (state & AutoReverseAnimationState) X { X state|=ForwardAnimationState; X scene=0; X } X else X { X if (!(state & RepeatAnimationState)) X state&=(~PlayAnimationState); X scene=number_scenes-1; X } X } X continue; X } X /* X Handle a window event. X */ X XNextEvent(display,&event); X switch (event.type) X { X case ButtonPress: X { X if (event.xbutton.window == image_window.id) X switch (event.xbutton.button) X { X case Button1: X { X static char X command[256]; X X /* X Select a command from the pop-up menu. X */ X XMenuWindow(display,&menu_window,event.xbutton.x_root, X event.xbutton.y_root,command); X UserCommand(display,&info_window,&image_window,command, X &images[scene],&state); X break; X } X default: X break; X } X break; X } X case ClientMessage: X { X /* X If client window delete message, exit. X */ X if (event.xclient.message_type == protocols_property) X if (*event.xclient.data.l == delete_property) X if (event.xclient.window == image_window.id) X state|=ExitState; X else X XWithdrawWindow(display,event.xclient.window, X visual_info->screen); X break; X } X case ConfigureNotify: X { X if (event.xconfigure.window == image_window.id) X { X /* X Icon window has a new configuration. X */ X image_window.width=event.xconfigure.width; X image_window.height=event.xconfigure.height; X break; X } X if (event.xconfigure.window == icon_window.id) X { X /* X Icon window has a new configuration. X */ X icon_window.width=event.xconfigure.width; X icon_window.height=event.xconfigure.height; X break; X } X } X case EnterNotify: X { X /* X Selectively install colormap. X */ X if (colormap != XDefaultColormap(display,visual_info->screen)) X if (event.xcrossing.mode != NotifyUngrab) X XInductColormap(display,colormap); X break; X } X case Expose: X { X /* X Repaint windows that are now exposed. X */ X if (event.xexpose.window == image_window.id) X if (event.xexpose.count == 0) X { X XCopyArea(display,image_window.pixmaps[scene],image_window.id, X image_window.graphic_context,0,0,image_window.width, X image_window.height,0,0); X break; X } X if (event.xexpose.window == icon_window.id) X { X XPutImage(display,icon_window.id,icon_window.graphic_context, X icon_window.ximage,event.xexpose.x,event.xexpose.y, X event.xexpose.x,event.xexpose.y, X (unsigned int) event.xexpose.width, X (unsigned int) event.xexpose.height); X break; X } X break; X } X case KeyPress: X { X static char X command[256]; X X static KeySym X key_symbol; X X /* X Respond to a user key press. X */ X if (state & ConfigureWindowState) X { X XBell(display,0); X break; X } X *command=(char) NULL; X XLookupString((XKeyEvent *) &event.xkey,command,sizeof(command), X &key_symbol,(XComposeStatus *) NULL); X if (key_symbol == XK_Help) X Usage((char *) NULL,False); X else X if (!IsCursorKey(key_symbol) && !isdigit(*command)) X UserCommand(display,&info_window,&image_window,command, X &images[scene],&state); X else X if (isdigit(*command)) X resource_info->delay=(2 << atoi(command)); X break; X } X case LeaveNotify: X { X /* X Selectively uninstall colormap. X */ X if (colormap != XDefaultColormap(display,visual_info->screen)) X if (event.xcrossing.mode != NotifyUngrab) X XUninductColormap(display,colormap); X break; X } X case MapNotify: X { X if (event.xmap.window == image_window.id) X { X state=ForwardAnimationState | PlayAnimationState; X break; X } X if (event.xmap.window == info_window.id) X { X state|=InfoMappedState; X break; X } X break; X } X case MappingNotify: X { X XRefreshKeyboardMapping(&event.xmapping); X break; X } X case UnmapNotify: X { X if (event.xunmap.window == info_window.id) X { X state&=(~InfoMappedState); X break; X } X break; X } X default: X break; X } X } X while (!(state & ExitState)); X /* X Free up memory. X */ X XDestroyWindow(display,info_window.id); X XDestroyWindow(display,menu_window.id); X XDestroyWindow(display,image_window.id); X (void) free((char *) image_window.name); X if (resource_info->backdrop) X XDestroyWindow(display,backdrop_window.id); X XDestroyWindow(display,icon_window.id); X if (icon_window.ximage != (XImage *) NULL) X XDestroyImage(icon_window.ximage); X XDestroyWindow(display,superclass_window.id); X XFreeGC(display,graphic_context); X XFree((char *) class_hint); X XFree((char *) manager_hints); X XFreeCursor(display,arrow_cursor); X XFreeCursor(display,watch_cursor); X XFreeFont(display,font_info); X /* X Discard pending events before freeing colormap. X */ X while (XEventsQueued(display,QueuedAfterFlush) > 0) X XNextEvent(display,&event); X for (scene=0; scene < number_scenes; scene++) X { X XFreePixmap(display,image_window.pixmaps[scene]); X DestroyImage(images[scene]); X if (resource_info->map_type == (char *) NULL) X { X colormap=map_info[scene]->colormap; X if (colormap != XDefaultColormap(display,visual_info->screen)) X XFreeColormap(display,colormap); X else X if ((visual_info->class == GrayScale) || X (visual_info->class == PseudoColor)) X XFreeColors(display,colormap,pixel_info[scene].pixels, X (int) images[scene]->colors,0); X } X if (pixel_info[scene].pixels != (unsigned long *) NULL) X (void) free((char *) pixel_info[scene].pixels); X XFree((char *) map_info[scene]); X } X (void) free((char *) pixel_info); X (void) free((char *) map_info); X XFree((char *) visual_info); } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % X M e n u W i n d o w % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function XMenuWindow maps a menu and returns the command pointed to by the % user when the button is released. % % The format of the XMenuWindow routine is: % % XMenuWindow(display,menu_window,x,y) % % A description of each parameter follows: % % o display: Specifies a connection to an X server; returned from % XOpenDisplay. % % o menu_window: Specifies a pointer to a XWindowInfo structure. % % o x: Specifies an unsigned integer representing the root offset the % x-direction. % % o y: Specifies an unsigned integer representing the root offset the % x-direction. % % o command: Specifies a character array. The command selected from % the menu is returned here. % % */ static void XMenuWindow(display,menu_window,x,y,command) Display X *display; X XXWindowInfo X *menu_window; X int X x, X y; X char X *command; { #define MaxMenuSelections 8 X X typedef struct _Selection X { X int X id, X x, X y; X X unsigned int X width, X height; X } Selection; X X static char X *MenuSelections[]= X { X "iImage Info ", X "pPlay ", X "sStep ", X ".Repeat ", X "aAuto Reverse", X "fForward ", X "rReverse ", X "qQuit ", X }; X X char X text[256]; X X Selection X last_selection, X selection; X X unsigned int X height, X state, X width; X X XEvent X event; X X /* X Size and position menu window under current pointer location and map. X */ X (void) sprintf(text," %s\0",MenuSelections[0]); X menu_window->width=XTextWidth(menu_window->font_info,text,strlen(text)); X menu_window->height=MaxMenuSelections* X (menu_window->font_info->ascent+menu_window->font_info->descent+4); X width=menu_window->width+2*menu_window->border_width; X menu_window->x=x-(int) width/2; X if (menu_window->x < 0) X menu_window->x=0; X else X if (menu_window->x > (XDisplayWidth(display,menu_window->screen)-width)) X menu_window->x=XDisplayWidth(display,menu_window->screen)-width; X height=menu_window->height+2*menu_window->border_width; X menu_window->y=y-(int) menu_window->border_width; X if (menu_window->y < 0) X menu_window->y=0; X else X if (menu_window->y > (XDisplayHeight(display,menu_window->screen)-height)) X menu_window->y=XDisplayHeight(display,menu_window->screen)-height; X XMoveResizeWindow(display,menu_window->id,menu_window->x,menu_window->y, X menu_window->width,menu_window->height); X XMapRaised(display,menu_window->id); X XWindowEvent(display,menu_window->id,ExposureMask,&event); X /* X Draw menu selection selections. X */ X selection.x=menu_window->font_info->max_bounds.rbearing- X menu_window->font_info->min_bounds.lbearing; X selection.y=menu_window->font_info->ascent+2; X selection.width=strlen(MenuSelections[0]+1); X selection.height=menu_window->font_info->descent+ X menu_window->font_info->ascent+4; X for (selection.id=0; selection.id < MaxMenuSelections; selection.id++) X { X XDrawString(display,menu_window->id,menu_window->graphic_context, X selection.x,selection.y,MenuSelections[selection.id]+1,selection.width); X selection.y+=(int) selection.height; X } X /* X Highlight menu as pointer moves; return command on button release. X */ X selection.id=0; X last_selection=selection; X state=DefaultState; X do X { X /* X Wait for next event. X */ X XMaskEvent(display,ButtonPressMask | Button1MotionMask | X ButtonReleaseMask | EnterWindowMask | LeaveWindowMask,&event); X switch (event.type) X { X case ButtonPress: X break; X case ButtonRelease: X { X /* X Determine if user choose a menu item. X */ X if (event.xbutton.button != Button1) X break; X state|=ExitState; X break; X } X case EnterNotify: X { X if (event.xcrossing.window != menu_window->id) X break; X selection.id=event.xcrossing.y/(int) selection.height; X /* X Check boundary conditions. X */ X if (selection.id < 0) X selection.id=0; X if (selection.id >= MaxMenuSelections) X selection.id=MaxMenuSelections-1; X /* X Highlight this selection. X */ X selection.y= X menu_window->font_info->ascent+2+selection.id*selection.height; X XSetBackground(display,menu_window->graphic_context, X menu_window->pixel_info->foreground_pixel); X XSetForeground(display,menu_window->graphic_context, X menu_window->pixel_info->background_pixel); X XDrawImageString(display,menu_window->id, X menu_window->graphic_context,selection.x,selection.y, X MenuSelections[selection.id]+1,selection.width); X XSetBackground(display,menu_window->graphic_context, X menu_window->pixel_info->background_pixel); X XSetForeground(display,menu_window->graphic_context, X menu_window->pixel_info->foreground_pixel); X last_selection=selection; X state|=HighlightState; X break; X } X case LeaveNotify: X { X if (event.xcrossing.window != menu_window->id) X break; X /* X Unhighlight last selection. X */ X XDrawImageString(display,menu_window->id, X menu_window->graphic_context,last_selection.x,last_selection.y, X MenuSelections[last_selection.id]+1,last_selection.width); X state&=(~HighlightState); X break; X } X case MotionNotify: X { X /* X Discard pending selection motion events. X */ X while (XCheckMaskEvent(display,Button1MotionMask,&event)); X if (event.xmotion.window != menu_window->id) X break; X /* X Check boundary conditions. X */ X selection.id=event.xmotion.y/(int) selection.height; X if (selection.id < 0) X selection.id=0; X if (selection.id >= MaxMenuSelections) X selection.id=MaxMenuSelections-1; X if (!(state & HighlightState)) X break; X if (selection.id == last_selection.id) X break; X /* X Unhighlight last selection. X */ X XDrawImageString(display,menu_window->id, X menu_window->graphic_context,last_selection.x,last_selection.y, X MenuSelections[last_selection.id]+1,last_selection.width); X /* X Highlight this selection. X */ X selection.y= X menu_window->font_info->ascent+2+selection.id*selection.height; X XSetBackground(display,menu_window->graphic_context, X menu_window->pixel_info->foreground_pixel); X XSetForeground(display,menu_window->graphic_context, X menu_window->pixel_info->background_pixel); X XDrawImageString(display,menu_window->id, X menu_window->graphic_context,selection.x,selection.y, X MenuSelections[selection.id]+1,selection.width); X XSetBackground(display,menu_window->graphic_context, X menu_window->pixel_info->background_pixel); X XSetForeground(display,menu_window->graphic_context, X menu_window->pixel_info->foreground_pixel); X last_selection=selection; X break; X } X default: X break; X } X } while (!(state & ExitState)); X XWithdrawWindow(display,menu_window->id,menu_window->screen); X *command=(char) NULL; X if (state & HighlightState) X (void) strcpy(command,MenuSelections[selection.id]); } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M a i n % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % */ int main(argc,argv) int X argc; X char X **argv; { X char X *clip_geometry, X *option, X *scale_geometry, X *server_name; X X Display X *display; X X double X gamma; X X Image X **images; X X int X degrees; X X register int X i; X X unsigned int X display_image, X dither, X gray, X image_number, X number_colors, X reflect, X tree_depth, X verbose; X X XResourceInfo X resource_info; X X /* X Display usage profile if there are no command line arguments. X */ X application_name=(*argv); X if (argc < 2) X Usage((char *) NULL,True); X /* X Set defaults. X */ X clip_geometry=(char *) NULL; X degrees=0; X display=(Display *) NULL; X display_image=True; X dither=False; X gamma=0.0; X gray=False; X number_colors=0; X reflect=False; X scale_geometry=(char *) NULL; X server_name=(char *) NULL; X tree_depth=0; X verbose=False; X images=(Image **) malloc((unsigned int) argc*sizeof(Image *)); X if (images == (Image **) NULL) X Error("unable to animate images","memory allocation failed"); X /* X Check for server name specified on the command line. X */ X for (i=1; i < argc-1; i++) X { X /* X Check command line for server name. X */ X option=argv[i]; X if ((strlen(option) > 1) && ((*option == '-') || (*option == '+'))) X if (strncmp("display",option+1,3) == 0) X { X /* X User specified server name. X */ X display_image=(*option == '-'); X if (display_image) X { X i++; X if (i == argc) X Usage("missing server name on -display",True); X server_name=argv[i]; X } X break; X } X } X if (display_image) X { X char X *user_default; X X /* X Open X server connection. X */ X display=XOpenDisplay(server_name); X if (display == (Display *) NULL) X Error("unable to connect to X server",XDisplayName(server_name)); X /* X Get user_defaults from X resource database. X */ X user_default=XGetDefault(display,application_name,"backdrop"); X resource_info.backdrop=IsTrue(user_default); X user_default=XGetDefault(display,application_name,"background"); X if (user_default == (char *) NULL) X user_default=XGetDefault(display,application_name,"Background"); X if (user_default == (char *) NULL) X user_default="black"; X resource_info.background_color=user_default; X user_default=XGetDefault(display,application_name,"borderColor"); X if (user_default == (char *) NULL) X user_default=XGetDefault(display,application_name,"BorderColor"); X if (user_default == (char *) NULL) X user_default="white"; X resource_info.border_color=user_default; X user_default=XGetDefault(display,application_name,"borderWidth"); X if (user_default == (char *) NULL) X user_default=XGetDefault(display,application_name,"BorderWidth"); X resource_info.border_width= X (user_default == (char *) NULL) ? 2 : atoi(user_default); X clip_geometry=XGetDefault(display,application_name,"clip"); X user_default=XGetDefault(display,application_name,"colors"); X number_colors=user_default ? atoi(user_default) : 0; X user_default=XGetDefault(display,application_name,"delay"); X resource_info.delay= X (user_default == (char *) NULL) ? 0 : atoi(user_default); X user_default=XGetDefault(display,application_name,"dither"); X dither=IsTrue(user_default); X user_default=XGetDefault(display,application_name,"font"); X if (user_default == (char *) NULL) X user_default=XGetDefault(display,application_name,"Font"); X resource_info.font_name=user_default; X user_default=XGetDefault(display,application_name,"foreground"); X if (user_default == (char *) NULL) X user_default=XGetDefault(display,application_name,"Foreground"); X if (user_default == (char *) NULL) X user_default="white"; X resource_info.foreground_color=user_default; X user_default=XGetDefault(display,application_name,"gamma"); X gamma=(user_default == (char *) NULL) ? 0.0 : atof(user_default); X user_default=XGetDefault(display,application_name,"geometry"); X if (user_default == (char *) NULL) X user_default=XGetDefault(display,application_name,"Geometry"); X resource_info.image_geometry=user_default; X user_default=XGetDefault(display,application_name,"gray"); X gray=IsTrue(user_default); X user_default=XGetDefault(display,application_name,"iconGeometry"); X if (user_default == (char *) NULL) X user_default=XGetDefault(display,application_name,"IconGeometry"); X resource_info.icon_geometry=user_default; X user_default=XGetDefault(display,application_name,"iconic"); X if (user_default == (char *) NULL) X user_default=XGetDefault(display,application_name,"Iconic"); X resource_info.iconic=IsTrue(user_default); X resource_info.map_type=XGetDefault(display,application_name,"map"); X user_default=XGetDefault(display,application_name,"monochrome"); X resource_info.monochrome=IsTrue(user_default); X user_default=XGetDefault(display,application_name,"name"); X if (user_default == (char *) NULL) X user_default=XGetDefault(display,application_name,"Name"); X resource_info.name=user_default; X user_default=XGetDefault(display,application_name,"reflect"); X reflect=IsTrue(user_default); X user_default=XGetDefault(display,application_name,"rotate"); X degrees=(user_default == (char *) NULL) ? 0 : atoi(user_default); X user_default=XGetDefault(display,application_name,"scale"); X if (user_default == (char *) NULL) X user_default=XGetDefault(display,application_name,"Scale"); X scale_geometry=user_default; X user_default=XGetDefault(display,application_name,"title"); X if (user_default == (char *) NULL) X user_default=XGetDefault(display,application_name,"Title"); X resource_info.title=user_default; X user_default=XGetDefault(display,application_name,"treedepth"); X tree_depth=(user_default == (char *) NULL) ? 0 : atoi(user_default); X user_default=XGetDefault(display,application_name,"verbose"); X verbose=IsTrue(user_default); X resource_info.visual_type=XGetDefault(display,application_name,"visual"); X } X /* X Parse command line. X */ X image_number=0; X for (i=1; i < argc; i++) X { X option=argv[i]; X if ((strlen(option) > 1) && ((*option == '-') || (*option == '+'))) X switch (*(option+1)) X { X case 'b': X { X if (strncmp("backdrop",option+1,5) == 0) X resource_info.backdrop=(*option == '-'); X else X if (strncmp("background",option+1,5) == 0) X { X resource_info.background_color=(char *) NULL; X if (*option == '-') X { X i++; X if (i == argc) X Usage("missing color on -background",True); X resource_info.background_color=argv[i]; X } X } X else X if (strncmp("bordercolor",option+1,7) == 0) X { X resource_info.border_color=(char *) NULL; X if (*option == '-') X { X i++; X if (i == argc) X Usage("missing color on -bordercolor",True); X resource_info.border_color=argv[i]; X } X } X else X if (strncmp("borderwidth",option+1,7) == 0) X { X resource_info.border_width=0; X if (*option == '-') X { X i++; X if (i == argc) X Usage("missing width on -borderwidth",True); X resource_info.border_width=atoi(argv[i]); X } X } X else X Usage(option,True); X break; X } X case 'c': X { X if (strncmp("clip",option+1,2) == 0) X { X clip_geometry=(char *) NULL; X if (*option == '-') X { X i++; X if (i == argc) X Usage("missing geometry on -clip",True); X clip_geometry=argv[i]; X } X } X else X if (strncmp("colors",option+1,3) == 0) X { X number_colors=0; X if (*option == '-') X { X i++; X if (i == argc) X Usage("missing colors on -colors",True); X number_colors=atoi(argv[i]); X } X } X else X Usage(option,True); X break; X } X case 'd': X { X if (strncmp("delay",option+1,2) == 0) X { X resource_info.delay=0; X if (*option == '-') X { X i++; X if (i == argc) X Usage("missing seconds on -delay",True); X resource_info.delay=atoi(argv[i]); X } X } X else X if (strncmp("display",option+1,3) == 0) X { X server_name=(char *) NULL; X if (*option == '-') X { X i++; X if (i == argc) X Usage("missing server name on -display",True); X server_name=argv[i]; X } X } X else X if (strncmp("dither",option+1,3) == 0) X dither=(*option == '-'); X else X Usage(option,True); X break; X } X case 'f': X { X if (strncmp("font",option+1,3) == 0) X { X resource_info.font_name=(char *) NULL; X if (*option == '-') X { X i++; X if (i == argc) X Usage("missing font name on -font",True); X resource_info.font_name=argv[i]; X } X } X else 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 Usage("missing foreground on -foreground",True); X resource_info.foreground_color=argv[i]; X } X } X else X Usage(option,True); 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) X Usage("missing gamma on -gamma",True); X gamma=atof(argv[i]); X } X } X else 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 Usage("missing geometry on -geometry",True); X resource_info.image_geometry=argv[i]; X } X } X else X if (strncmp("gray",option+1,2) == 0) X gray=(*option == '-'); X else X Usage(option,True); X break; X } X case 'h': X { X Usage((char *) NULL,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 Usage("missing geometry on -iconGeometry",True); X resource_info.icon_geometry=argv[i]; X } X } X else X if (strncmp("iconic",option+1,5) == 0) X resource_info.iconic=(*option == '-'); X else X Usage(option,True); X break; X } X case 'm': 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 Usage("missing map type on -map",True); X resource_info.map_type=argv[i]; X } X } X else X if (strncmp("monochrome",option+1,2) == 0) X resource_info.monochrome=(*option == '-'); X else X Usage(option,True); 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 Usage("missing name on -name",True); X resource_info.name=argv[i]; X } X } X else X Usage(option,True); X break; X } X case 'r': X { X if (strncmp("reflect",option+1,2) == 0) X reflect=(*option == '-'); X else X if (strncmp("rotate",option+1,3) == 0) X { X degrees=0.0; X if (*option == '-') X { X i++; X if (i == argc) X Usage("missing degrees on -rotate",True); X degrees=atoi(argv[i]); X } X } X else X Usage(option,True); X break; X } X case 's': X { X scale_geometry=(char *) NULL; X if (*option == '-') X { X i++; X if (i == argc) X Usage("missing scale geometry on -scale",True); X scale_geometry=argv[i]; X } 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 Usage("missing title on -title",True); X resource_info.title=argv[i]; X } X } X else X if (strncmp("tree_depth",option+1,2) == 0) X { X tree_depth=0; X if (*option == '-') X { X i++; X if (i == argc) X Usage("missing depth on -treedepth",True); X tree_depth=atoi(argv[i]); X } X } X else X Usage(option,True); X break; X } X case 'v': X { X if (strncmp("verbose",option+1,2) == 0) X verbose=(*option == '-'); X else 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 Usage("missing visual class on -visual",True); X resource_info.visual_type=argv[i]; X } X } X else X Usage(option,True); X break; X } X default: X { X Usage((char *) NULL,True); X break; X } X } X else X { X Image X *image, X info_image; X X /* X Option is a file name: begin by reading image from specified file. X */ X image=ReadImage(option); X if (image == (Image *) NULL) X continue; X if (image->scene == 0) X image->scene=image_number; X info_image=(*image); X /* X Transform image as defined by the clip, image and scale geometries. X */ X image=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 (gamma > 0.0) X (void) GammaImage(image,gamma); X if (gray) X { X /* X Convert image to gray scale PseudoColor class. X */ X (void) GrayImage(image); X if (image->class == DirectClass) X QuantizeImage(image,256,tree_depth,dither,True); X } X if (resource_info.monochrome) X { X register unsigned int X bit; X X /* X Convert image to resource_info.monochrome PseudoColor class. X */ X (void) GrayImage(image); X (void) QuantizeImage(image,2,tree_depth,dither,True); X bit=Intensity(image->colormap[0]) > Intensity(image->colormap[1]); X image->colormap[bit].red=0; X image->colormap[bit].green=0; X image->colormap[bit].blue=0; X image->colormap[!bit].red=255; X image->colormap[!bit].green=255; X image->colormap[!bit].blue=255; X } X if (number_colors > 0) X if ((image->class == DirectClass) || (image->colors > number_colors)) X QuantizeImage(image,number_colors,tree_depth,dither,True); X if (verbose) X { X /* X Display detailed info about the image. X */ X (void) fprintf(stderr,"[%d] %s",(image->scene == 0 ? image_number : X image->scene),image->filename); X (void) fprintf(stderr," %dx%d",info_image.columns,info_image.rows); X if ((info_image.columns != image->columns) || X (info_image.rows != image->rows)) X (void) fprintf(stderr,"=>%dx%d",image->columns,image->rows); X if (image->class == DirectClass) X (void) fprintf(stderr," DirectClass "); X else X (void) fprintf(stderr," PseudoClass "); X (void) fprintf(stderr,"%dc \r",image->colors); X } X images[image_number++]=image; X } X } X if (verbose) X (void) fprintf(stderr,"\n"); X if (image_number == 0) X Usage("missing an image file name",True); X else X XAnimateImage(display,&resource_info,argv,argc,images,image_number); X (void) free((char *) images); X if (display != (Display *) NULL) X XCloseDisplay(display); X return(False); } SHAR_EOF echo 'File ImageMagick/animate.c is complete' && chmod 0755 ImageMagick/animate.c || echo 'restore of ImageMagick/animate.c failed' Wc_c="`wc -c < 'ImageMagick/animate.c'`" test 73911 -eq "$Wc_c" || echo 'ImageMagick/animate.c: original size 73911, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= ImageMagick/PreR4Icccm.c ============== if test -f 'ImageMagick/PreR4Icccm.c' -a X"$1" != X"-c"; then echo 'x - skipping ImageMagick/PreR4Icccm.c (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting ImageMagick/PreR4Icccm.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/PreR4Icccm.c' && /* X Compatibility routines for pre X11R4 ICCCM. */ #include "display.h" #include "X.h" #ifdef PRE_R4_ICCCM XXClassHint *XAllocClassHint() { X return((XClassHint *) malloc(sizeof(XClassHint))); } X XXIconSize *XAllocIconSize() { X return((XIconSize *) malloc(sizeof(XIconSize))); } X XXSizeHints *XAllocSizeHints() { X return((XSizeHints *) malloc(sizeof(XSizeHints))); } X Status XReconfigureWMWindow(display,window,screen_number,value_mask,values) Display X *display; X Window X window; X int X screen_number; X unsigned int X value_mask; X XXWindowChanges X *values; { X return(XConfigureWindow(display,window,value_mask,values)); } X XXStandardColormap *XAllocStandardColormap() { X return((XStandardColormap *) malloc(sizeof(XStandardColormap))); } X XXWMHints *XAllocWMHints() { X return((XWMHints *) malloc(sizeof(XWMHints))); } X Status XGetRGBColormaps(display,window,colormap,count,property) Display X *display; X Window X window; X XXStandardColormap X **colormap; X int X *count; X Atom X property; { X *count=1; X return(XGetStandardColormap(display,window,colormap,property)); } X Status XGetWMName(display,window,text_property) Display X *display; X Window X window; X XXTextProperty X *text_property; { X char X *window_name; X X if (XFetchName(display,window,&window_name) == 0) X return(False); X text_property->value=(unsigned char *) window_name; X text_property->encoding=XA_STRING; X text_property->format=8; X text_property->nitems=strlen(window_name); X return(True); } X void XSetWMProperties(display,window,window_name,icon_name,argv,argc, X size_hints,manager_hints,class_hint) Display X *display; X Window X window; X XXTextProperty X *window_name, X *icon_name; X char X **argv; X int X argc; X XXSizeHints X *size_hints; X XXWMHints *manager_hints; X XXClassHint X *class_hint; { X XSetStandardProperties(display,window,window_name->value,icon_name,None, X argv,argc,size_hints); X XSetWMHints(display,window,manager_hints); X XSetClassHint(display,window,class_hint); } X Status XSetWMProtocols(display,window,protocols,count) Display X *display; X Window X window; X Atom X *protocols; X int X count; { X Atom X protocols_property; X X protocols_property=XInternAtom(display,"WM_PROTOCOLS",False); X XChangeProperty(display,window,protocols_property,XA_ATOM,32,PropModeReplace, X (unsigned char *) protocols, count); X return(True); } X VisualID XVisualIDFromVisual(visual) Visual X *visual; { X return(visual->visualid); } X Status XWithdrawWindow(display,window,screen) Display X *display; X Window X window; X int X screen; { X return(XUnmapWindow(display,window)); } X int XWMGeometry(display,screen,user_geometry,default_geometry,border_width, X size_hints,x,y,width,height,gravity) Display X *display; X int X screen; X char X *user_geometry, X *default_geometry; X unsigned int X border_width; X XXSizeHints X *size_hints; X int X *x, X *y, X *width, X *height, X *gravity; { X int X status; X X status=XGeometry(display,screen,user_geometry,default_geometry,border_width, X 0,0,0,0,x,y,width,height); X *gravity=NorthWestGravity; X return(status); } #endif SHAR_EOF chmod 0755 ImageMagick/PreR4Icccm.c || echo 'restore of ImageMagick/PreR4Icccm.c failed' Wc_c="`wc -c < 'ImageMagick/PreR4Icccm.c'`" test 3056 -eq "$Wc_c" || echo 'ImageMagick/PreR4Icccm.c: original size 3056, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= ImageMagick/patchlevel.h ============== if test -f 'ImageMagick/patchlevel.h' -a X"$1" != X"-c"; then echo 'x - skipping ImageMagick/patchlevel.h (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting ImageMagick/patchlevel.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/patchlevel.h' && #define PATCHLEVEL 0 SHAR_EOF chmod 0755 ImageMagick/patchlevel.h || echo 'restore of ImageMagick/patchlevel.h failed' Wc_c="`wc -c < 'ImageMagick/patchlevel.h'`" test 22 -eq "$Wc_c" || echo 'ImageMagick/patchlevel.h: original size 22, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi rm -f _shar_seq_.tmp echo You have unpacked the last part exit 0 -- Dan Heller O'Reilly && Associates Z-Code Software Comp-sources-x: Senior Writer President comp-sources-x@uunet.uu.net argv@ora.com argv@zipcode.com