cristy@dupont.com (05/24/91)
Submitted-by: cristy@dupont.com Posting-number: Volume 13, Issue 36 Archive-name: imagemagic/part20 #!/bin/sh # this is img.20 (part 20 of ImageMagick) # do not concatenate these parts, unpack them in order with /bin/sh # file ImageMagick/X.c continued # if test ! -r _shar_seq_.tmp; then echo 'Please unpack part 1 first!' exit 1 fi (read Scheck if test "$Scheck" != 20; 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/X.c' else echo 'x - continuing file ImageMagick/X.c' sed 's/^X//' << 'SHAR_EOF' >> 'ImageMagick/X.c' && X pixel>>=8; X } X for (j=0; j <= p->length; j++) X { X for (k=0; k < bytes_per_pixel; k++) X *q++=channel[k]; X x++; X if (x == ximage->width) X { X x=0; X q+=scanline_pad; X } X } X p++; X } X break; X } X } X else X { X /* X Convert image to little-endian continuous-tone X image. X */ X switch (ximage->bits_per_pixel) X { X case 2: X { X register unsigned int X nibble; X X /* X Convert to contiguous 2 bit continuous-tone X image. X */ X nibble=0; X for (i=0; i < image->packets; i++) X { X pixel=XStandardPixel(map_info,(*p),8); X pixel&=0xf; X for (j=0; j <= p->length; j++) X { X switch (nibble) X { X case 0: X { X *q=(unsigned char) pixel; X nibble++; X break; X } X case 1: X { X *q|=(unsigned char) (pixel << 2); X nibble++; X break; X } X case 2: X { X *q|=(unsigned char) (pixel << 4); X nibble++; X break; X } X case 3: X { X *q|=(unsigned char) (pixel << 6); X q++; X nibble=0; X break; X } X } X x++; X if (x == ximage->width) X { X x=0; X nibble=0; X q+=scanline_pad; X } X } X p++; X } X break; X } X case 4: X { X register unsigned int X nibble; X X /* X Convert to contiguous 4 bit continuous-tone X image. X */ X nibble=0; X for (i=0; i < image->packets; i++) X { X pixel=XStandardPixel(map_info,(*p),8); X pixel&=0xf; X for (j=0; j <= p->length; j++) X { X switch (nibble) X { X case 0: X { X *q=(unsigned char) pixel; X nibble++; X break; X } X case 1: X { X *q|=(unsigned char) (pixel << 4); X q++; X nibble=0; X break; X } X } X x++; X if (x == ximage->width) X { X x=0; X nibble=0; X q+=scanline_pad; X } X } X p++; X } X break; X } X case 6: X case 8: X { X /* X Convert to contiguous 8 bit continuous-tone X image. X */ X for (i=0; i < image->packets; i++) X { X pixel=XStandardPixel(map_info,(*p),8); X for (j=0; j <= p->length; j++) X { X *q++=(unsigned char) pixel; X x++; X if (x == ximage->width) X { X x=0; X q+=scanline_pad; X } X } X p++; X } X break; X } X default: X { X if ((ximage->bits_per_pixel == 32) && X (map_info->red_max == 255) && X (map_info->green_max == 255) && X (map_info->blue_max == 255) && X (map_info->red_mult == 65536) && X (map_info->green_mult == 256) && X (map_info->blue_mult == 1)) X { X /* X Convert to 32 bit continuous-tone X image. X */ X for (i=0; i < image->packets; i++) X { X for (j=0; j <= p->length; j++) X { X *q++=p->blue; X *q++=p->green; X *q++=p->red; X *q++=0; X } X p++; X } X } X else X { X register int X k; X X register unsigned int X bytes_per_pixel; X X unsigned char X channel[sizeof(unsigned long)]; X X /* X Convert to multi-byte continuous-tone X image. X */ X bytes_per_pixel=ximage->bits_per_pixel >> 3; X for (i=0; i < image->packets; i++) X { X pixel=XStandardPixel(map_info,(*p),8); X for (k=0; k < bytes_per_pixel; k++) X { X channel[k]=(unsigned char) pixel; X pixel>>=8; X } X for (j=0; j <= p->length; j++) X { X for (k=0; k < bytes_per_pixel; k++) X *q++=channel[k]; X x++; X if (x == ximage->width) X { X x=0; X q+=scanline_pad; X } X } X p++; X } X } X break; X } X } X } X } } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % X M a k e I m a g e M S B F i r s t % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function XMakeImageMSBFirst initializes the pixel data of an X11 Image. % The X image pixels are copied in most-significant bit and byte first order. % The server's scanline pad is also resprected. Rather than using one or two % general cases, many special cases are found here to help speed up the image % conversion. % % The format of the XMakeImageMSBFirst routine is: % % XMakeImageMSBFirst(map_info,pixel_info,image,ximage) % % A description of each parameter follows: % % o map_info: Specifies a pointer to a XStandardColormap structure. % % o pixel_info: Specifies a pointer to a XPixelInfo structure. % % o image: Specifies a pointer to a Image structure; returned from % ReadImage. % % o ximage: Specifies a pointer to a XImage structure; returned from % XCreateImage. % % */ void XMakeImageMSBFirst(map_info,pixel_info,image,ximage) XXStandardColormap X *map_info; X XXPixelInfo X *pixel_info; X Image X *image; X XXImage X *ximage; { X register int X i, X j, X x; X X register RunlengthPacket X *p; X X register unsigned char X *q; X X register unsigned long X pixel; X X unsigned int X scanline_pad; X X unsigned long X *pixels; X X pixels=pixel_info->pixels; X p=image->pixels; X q=(unsigned char *) ximage->data; X x=0; X if (ximage->format == XYBitmap) X { X register unsigned char X bit, X byte; X X register unsigned char X foreground_pixel; X X /* X Convert image to big-endian bitmap. X */ X foreground_pixel=(Intensity(image->colormap[0]) > X Intensity(image->colormap[1]) ? 0 : 1); X scanline_pad=ximage->bytes_per_line-(ximage->width >> 3); X bit=0; X byte=0; X for (i=0; i < image->packets; i++) X { X for (j=0; j <= p->length; j++) X { X byte<<=1; X if (p->index == foreground_pixel) X byte|=0x01; X bit++; X if (bit == 8) X { X *q++=byte; X bit=0; X byte=0; X } X x++; X if (x == ximage->width) X { X /* X Advance to the next scanline. X */ X if (bit > 0) X *q=byte << (8-bit); X q+=scanline_pad; X bit=0; X byte=0; X x=0; X } X } X p++; X } X } X else X { X /* X Convert image to big-endian X image. X */ X scanline_pad=ximage->bytes_per_line- X ((ximage->width*ximage->bits_per_pixel) >> 3); X if (pixels != (unsigned long *) NULL) X switch (ximage->bits_per_pixel) X { X case 2: X { X register unsigned int X nibble; X X /* X Convert to 2 bit color-mapped X image. X */ X nibble=0; X for (i=0; i < image->packets; i++) X { X pixel=pixels[p->index] & 0xf; X for (j=0; j <= p->length; j++) X { X switch (nibble) X { X case 0: X { X *q=(unsigned char) (pixel << 6); X nibble++; X break; X } X case 1: X { X *q|=(unsigned char) (pixel << 4); X nibble++; X break; X } X case 2: X { X *q|=(unsigned char) (pixel << 2); X nibble++; X break; X } X case 3: X { X *q|=(unsigned char) pixel; X q++; X nibble=0; X break; X } X } X x++; X if (x == ximage->width) X { X x=0; X nibble=0; X q+=scanline_pad; X } X } X p++; X } X break; X } X case 4: X { X register unsigned int X nibble; X X /* X Convert to 4 bit color-mapped X image. X */ X nibble=0; X for (i=0; i < image->packets; i++) X { X pixel=pixels[p->index] & 0xf; X for (j=0; j <= p->length; j++) X { X switch (nibble) X { X case 0: X { X *q=(unsigned char) (pixel << 4); X nibble++; X break; X } X case 1: X { X *q|=(unsigned char) pixel; X q++; X nibble=0; X break; X } X } X x++; X if (x == ximage->width) X { X x=0; X nibble=0; X q+=scanline_pad; X } X } X p++; X } X break; X } X case 8: X { X /* X Convert to 8 bit color-mapped X image. X */ X for (i=0; i < image->packets; i++) X { X pixel=pixels[p->index]; X for (j=0; j <= p->length; j++) X { X *q++=(unsigned char) pixel; X x++; X if (x == ximage->width) X { X x=0; X q+=scanline_pad; X } X } X p++; X } X break; X } X default: X { X register int X k; X X register unsigned int X bytes_per_pixel; X X unsigned char X channel[sizeof(unsigned long)]; X X /* X Convert to 8 bit color-mapped X image. X */ X bytes_per_pixel=ximage->bits_per_pixel >> 3; X for (i=0; i < image->packets; i++) X { X pixel=pixels[p->index]; X for (k=bytes_per_pixel-1; k >= 0; k--) X { X channel[k]=(unsigned char) pixel; X pixel>>=8; X } X for (j=0; j <= p->length; j++) X { X for (k=0; k < bytes_per_pixel; k++) X *q++=channel[k]; X x++; X if (x == ximage->width) X { X x=0; X q+=scanline_pad; X } X } X p++; X } X break; X } X } X else X { X /* X Convert to big-endian continuous-tone X image. X */ X switch (ximage->bits_per_pixel) X { X case 2: X { X register unsigned int X nibble; X X /* X Convert to 4 bit continuous-tone X image. X */ X nibble=0; X for (i=0; i < image->packets; i++) X { X pixel=XStandardPixel(map_info,(*p),8); X pixel&=0xf; X for (j=0; j <= p->length; j++) X { X switch (nibble) X { X case 0: X { X *q=(unsigned char) (pixel << 6); X nibble++; X break; X } X case 1: X { X *q|=(unsigned char) (pixel << 4); X nibble++; X break; X } X case 2: X { X *q|=(unsigned char) (pixel << 2); X nibble++; X break; X } X case 3: X { X *q|=(unsigned char) pixel; X q++; X nibble=0; X break; X } X } X x++; X if (x == ximage->width) X { X x=0; X nibble=0; X q+=scanline_pad; X } X } X p++; X } X break; X } X case 4: X { X register unsigned int X nibble; X X /* X Convert to 4 bit continuous-tone X image. X */ X nibble=0; X for (i=0; i < image->packets; i++) X { X pixel=XStandardPixel(map_info,(*p),8); X pixel&=0xf; X for (j=0; j <= p->length; j++) X { X switch (nibble) X { X case 0: X { X *q=(unsigned char) (pixel << 4); X nibble++; X break; X } X case 1: X { X *q|=(unsigned char) pixel; X q++; X nibble=0; X break; X } X } X x++; X if (x == ximage->width) X { X x=0; X nibble=0; X q+=scanline_pad; X } X } X p++; X } X break; X } X case 8: X { X /* X Convert to 8 bit continuous-tone X image. X */ X for (i=0; i < image->packets; i++) X { X pixel=XStandardPixel(map_info,(*p),8); X for (j=0; j <= p->length; j++) X { X *q++=(unsigned char) pixel; X x++; X if (x == ximage->width) X { X x=0; X q+=scanline_pad; X } X } X p++; X } X break; X } X default: X { X if ((ximage->bits_per_pixel == 32) && X (map_info->red_max == 255) && X (map_info->green_max == 255) && X (map_info->blue_max == 255) && X (map_info->red_mult == 65536) && X (map_info->green_mult == 256) && X (map_info->blue_mult == 1)) X { X /* X Convert to 32 bit continuous-tone X image. X */ X for (i=0; i < image->packets; i++) X { X for (j=0; j <= p->length; j++) X { X *q++=0; X *q++=p->red; X *q++=p->green; X *q++=p->blue; X } X p++; X } X } X else X { X register int X k; X X register unsigned int X bytes_per_pixel; X X unsigned char X channel[sizeof(unsigned long)]; X X /* X Convert to multi-byte continuous-tone X image. X */ X bytes_per_pixel=ximage->bits_per_pixel >> 3; X for (i=0; i < image->packets; i++) X { X pixel=XStandardPixel(map_info,(*p),8); X for (k=bytes_per_pixel-1; k >= 0; k--) X { X channel[k]=(unsigned char) pixel; X pixel>>=8; X } X for (j=0; j <= p->length; j++) X { X for (k=0; k < bytes_per_pixel; k++) X *q++=channel[k]; X x++; X if (x == ximage->width) X { X x=0; X q+=scanline_pad; X } X } X p++; X } X } X break; X } X } X } X } } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % X M a k e S t a n d a r d C o l o r m a p % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function XMakeStandardColormap creates an X11 colormap. If the visual % class is TrueColor or DirectColor a Standard Colormap is also created. % % The format of the XMakeStandardColormap routine is: % % XMakeStandardColormap(display,visual_info,resource_info,pixel_info, % image) % % A description of each parameter follows: % % o display: Specifies a connection to an X server; returned from % XOpenDisplay. % % o visual_info: Specifies a pointer to a X11 XVisualInfo structure; % returned from XGetVisualInfo. % % o resource_info: Specifies a pointer to a X11 XResourceInfo structure. % % o pixel_info: Specifies a pointer to a XPixelInfo structure. % % o image: Specifies a pointer to a Image structure; returned from % ReadImage. % % */ XXStandardColormap *XMakeStandardColormap(display,visual_info,resource_info, X pixel_info,image) Display X *display; X XXVisualInfo X *visual_info; X XXResourceInfo X *resource_info; X XXPixelInfo X *pixel_info; X Image X *image; { X char X *background_color, X *foreground_color; X X Colormap X colormap; X X int X status; X X register int X i; X X XColor X color; X X XStandardColormap X *map_info; X X Window X root_window; X X /* X Initialize function return parameters. X */ X root_window=XRootWindow(display,visual_info->screen); X map_info=XAllocStandardColormap(); X if (map_info == (XStandardColormap *) NULL) X Error("unable to create colormap","memory allocation failed"); X if ((visual_info->visual == XDefaultVisual(display,visual_info->screen)) && X (visual_info->class != DirectColor)) X map_info->colormap=XDefaultColormap(display,visual_info->screen); X else X if ((visual_info->class == StaticGray) || X (visual_info->class == StaticColor) || X (visual_info->class == TrueColor)) X map_info->colormap= X XCreateColormap(display,root_window,visual_info->visual,AllocNone); X else X map_info->colormap= X XCreateColormap(display,root_window,visual_info->visual,AllocAll); X if (map_info->colormap == (Colormap) NULL) X Error("unable to create colormap",(char *) NULL); X map_info->red_max=0; X map_info->green_max=0; X map_info->blue_max=0; X map_info->red_mult=0; X map_info->green_mult=0; X map_info->blue_mult=0; X map_info->base_pixel=0; X pixel_info->pixels=(unsigned long *) NULL; X pixel_info->background_pixel=XBlackPixel(display,visual_info->screen); X pixel_info->border_pixel=XWhitePixel(display,visual_info->screen); X pixel_info->foreground_pixel=XWhitePixel(display,visual_info->screen); X if (resource_info->monochrome) X { X background_color="black"; X foreground_color="white"; X } X else X { X background_color=resource_info->background_color; X foreground_color=resource_info->foreground_color; X } X colormap=map_info->colormap; X if ((visual_info->class != TrueColor) && (visual_info->class != DirectColor)) X { X if ((image->class == DirectClass) || X (image->colors > visual_info->colormap_size)) X { X unsigned int X number_colors; X X /* X Prevent colormap "flashing"; reserve some colormap entries. X */ X number_colors=visual_info->colormap_size; X if ((visual_info->class == GrayScale) || X (visual_info->class == PseudoColor)) X if (visual_info->visual == X XDefaultVisual(display,visual_info->screen)) X if ((visual_info->depth > 1) && !resource_info->backdrop) X number_colors=(number_colors*61) >> 6; X QuantizeImage(image,number_colors,0,False,False); X image->class=DirectClass; X } X /* X Allocate pixels array. X */ X pixel_info->pixels=(unsigned long *) X malloc((unsigned int) image->colors*sizeof(unsigned long)); X if (pixel_info->pixels == (unsigned long *) NULL) X Error("unable to create colormap","memory allocation failed"); X /* X Colormap creation is dictated by the server visual class. X */ X switch (visual_info->class) X { X case StaticGray: X case StaticColor: X { X /* X Immutable colormap; allocate shared colors. X */ X color.flags=DoRed | DoGreen | DoBlue; X for (i=0; i < image->colors; i++) X { X color.red=(unsigned short) (image->colormap[i].red << 8); X color.green=(unsigned short) (image->colormap[i].green << 8); X color.blue=(unsigned short) (image->colormap[i].blue << 8); X status=XAllocColor(display,colormap,&color); X if (status == 0) X { X colormap=XCopyColormapAndFree(display,colormap); X XAllocColor(display,colormap,&color); X } X pixel_info->pixels[i]=color.pixel; X } X break; X } X case GrayScale: X case PseudoColor: X { X XColor X *colors; X X /* X Read/write colormap; allocate private colors. X */ X colors=(XColor *) X malloc((unsigned int) visual_info->colormap_size*sizeof(XColor)); X if (colors == (XColor *) NULL) X Error("unable to create colormap","memory allocation failed"); X status=XAllocColorCells(display,colormap,False, X (unsigned long *) NULL,0,pixel_info->pixels,image->colors); X if (status == 0) X { X unsigned int X retain_colors; X X /* X Create a new colormap. X */ X colormap=XCreateColormap(display,root_window,visual_info->visual, X AllocNone); X retain_colors=visual_info->colormap_size-image->colors; X if (retain_colors > 0) X { X /* X Not enough colormap entries in the default colormap; X create a new colormap and retain as many colors from the X default colormap as possible. X */ X if (retain_colors > 144) X retain_colors=144; X for (i=0; i < retain_colors; i++) X colors[i].pixel=i; X XQueryColors(display,XDefaultColormap(display, X visual_info->screen),colors,retain_colors); X XAllocColorCells(display,colormap,False, X (unsigned long *) NULL,0,pixel_info->pixels,retain_colors); X XStoreColors(display,colormap,colors,retain_colors); X } X XAllocColorCells(display,colormap,False,(unsigned long *) NULL,0, X pixel_info->pixels,image->colors); X } X /* X Store the image colormap. X */ X if (visual_info->class != GrayScale) X for (i=0; i < image->colors; i++) X { X colors[i].flags=DoRed | DoGreen | DoBlue; X colors[i].red=(unsigned short) (image->colormap[i].red << 8); X colors[i].green=(unsigned short) (image->colormap[i].green << 8); X colors[i].blue=(unsigned short) (image->colormap[i].blue << 8); X colors[i].pixel=pixel_info->pixels[i]; X } X else X { X register unsigned char X gray_value; X X /* X Convert PseudoClass packets to grayscale. X */ X for (i=0; i < image->colors; i++) X { X colors[i].flags=DoRed | DoGreen | DoBlue; X gray_value=Intensity(image->colormap[i]); X colors[i].red=(unsigned short) (gray_value << 8); X colors[i].green=(unsigned short) (gray_value << 8); X colors[i].blue=(unsigned short) (gray_value << 8); X colors[i].pixel=pixel_info->pixels[i]; X } X } X XStoreColors(display,colormap,colors,image->colors); X if (image->colors == visual_info->colormap_size) X { X /* X Find closest color for background/border/foreground pixels. X */ X XParseColor(display,colormap,background_color,&color); X pixel_info->background_pixel= X XBestPixel(colors,image->colors,color); X XParseColor(display,colormap,resource_info->border_color,&color); X pixel_info->border_pixel=XBestPixel(colors,image->colors,color); X XParseColor(display,colormap,foreground_color,&color); X pixel_info->foreground_pixel= X XBestPixel(colors,image->colors,color); X } X (void) free((char *) colors); X break; X } X } X /* X Final check for background/border/foreground pixels. X */ X XParseColor(display,colormap,background_color,&color); X if (XAllocColor(display,colormap,&color) != 0) X pixel_info->background_pixel=color.pixel; X XParseColor(display,colormap,resource_info->border_color,&color); X if (XAllocColor(display,colormap,&color) != 0) X pixel_info->border_pixel=color.pixel; X XParseColor(display,colormap,foreground_color,&color); X if (XAllocColor(display,colormap,&color) != 0) X pixel_info->foreground_pixel=color.pixel; X } X else X { X unsigned long X shift; X X /* X Initialize the Standard Colormap attributes. X */ X shift=0; X map_info->red_max=visual_info->red_mask; X if (map_info->red_max > 0) X while ((map_info->red_max & 0x01) == 0) X { X shift++; X map_info->red_max>>=1; X } X map_info->red_mult=1 << shift; X shift=0; X map_info->green_max=visual_info->green_mask; X if (map_info->green_max > 0) X while ((map_info->green_max & 0x01) == 0) X { X shift++; X map_info->green_max>>=1; X } X map_info->green_mult=1 << shift; X shift=0; X map_info->blue_max=visual_info->blue_mask; X if (map_info->blue_max > 0) X while ((map_info->blue_max & 0x01) == 0) X { X shift++; X map_info->blue_max>>=1; X } X map_info->blue_mult=1 << shift; X switch (visual_info->class) X { X case TrueColor: X { X /* X TrueColor. X */ X break; X } X case DirectColor: X { X unsigned int X linear_colormap, X number_colors; X X unsigned long X blue_max, X green_max, X red_max; X X XColor X *colors; X X /* X Determine the number of colors this server supports. X */ X linear_colormap= X ((map_info->red_max+1) == visual_info->colormap_size) && X ((map_info->green_max+1) == visual_info->colormap_size) && X ((map_info->blue_max+1) == visual_info->colormap_size); X if (linear_colormap) X number_colors=visual_info->colormap_size; X else X number_colors=(map_info->red_max*map_info->red_mult)+ X (map_info->green_max*map_info->green_mult)+ X (map_info->blue_max*map_info->blue_mult)+1; X /* X Allocate color array. X */ X colors=(XColor *) malloc((unsigned int) number_colors*sizeof(XColor)); X if (colors == (XColor *) NULL) X Error("unable to create colormap","memory allocation failed"); X /* X Initialize linear color ramp. X */ X red_max=map_info->red_max; X if (red_max == 0) X red_max=1; X green_max=map_info->green_max; X if (green_max == 0) X green_max=1; X blue_max=map_info->blue_max; X if (blue_max == 0) X blue_max=1; X if (linear_colormap) X for (i=0; i < number_colors; i++) X { X colors[i].flags=DoRed | DoGreen | DoBlue; X colors[i].blue=(unsigned short) X (((i % map_info->green_mult)*65535)/blue_max); X colors[i].red=colors[i].blue; X colors[i].green=colors[i].blue; X colors[i].pixel=XStandardPixel(map_info,colors[i],16); X } X else X for (i=0; i < number_colors; i++) X { X colors[i].flags=DoRed | DoGreen | DoBlue; X colors[i].red=(unsigned short) X (((i/map_info->red_mult)*65535)/red_max); X colors[i].green=(unsigned short) ((((i/map_info->green_mult) % X (map_info->green_max+1))*65535)/green_max); X colors[i].blue=(unsigned short) X (((i % map_info->green_mult)*65535)/blue_max); X colors[i].pixel=XStandardPixel(map_info,colors[i],16); X } X XStoreColors(display,colormap,colors,number_colors); X (void) free((char *) colors); X break; X } X default: X break; X } X if (image->class == PseudoClass) X { X /* X Initialize pixel array for images of type PseudoClass. X */ X pixel_info->pixels=(unsigned long *) X malloc((unsigned int) image->colors*sizeof(unsigned long)); X if (pixel_info->pixels == (unsigned long *) NULL) X Error("unable to create colormap","memory allocation failed"); X for (i=0; i < image->colors; i++) X pixel_info->pixels[i]= X XStandardPixel(map_info,image->colormap[i],8); X } X /* X Define background/border/foreground pixels. X */ X XParseColor(display,colormap,background_color,&color); X pixel_info->background_pixel=XStandardPixel(map_info,color,16); X XParseColor(display,colormap,resource_info->border_color,&color); X pixel_info->border_pixel=XStandardPixel(map_info,color,16); X XParseColor(display,colormap,foreground_color,&color); X pixel_info->foreground_pixel=XStandardPixel(map_info,color,16); X } X map_info->colormap=colormap; X return(map_info); } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % X M a k e W i n d o w % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function XMakeWindow creates an X11 window. % % The format of the XMakeWindow routine is: % % XMakeWindow(display,parent,argv,argc,class_hint,manager_hints,property, % window_info) % % A description of each parameter follows: % % o display: Specifies a connection to an X server; returned from % XOpenDisplay. % % o parent: Specifies the parent window. % % o argv: Specifies the application's argument list. % % o argc: Specifies the number of arguments. % % o class_hint: Specifies a pointer to a X11 XClassHint structure. % % o manager_hints: Specifies a pointer to a X11 XWMHints structure. % % o property: A property to define on the window. % % o window_info: Specifies a pointer to a X11 XWindowInfo structure. % % */ void XMakeWindow(display,parent,argv,argc,class_hint,manager_hints,property, X window_info) Display X *display; X Window X parent; X char X **argv; X int X argc; X XXClassHint X *class_hint; X XXWMHints X *manager_hints; X Atom X property; X XXWindowInfo X *window_info; { #define MinWindowSize 64 X X XSizeHints X *size_hints; X X XTextProperty X name; X X /* X Set window hints. X */ X size_hints=XAllocSizeHints(); X if (size_hints == (XSizeHints *) NULL) X Error("unable to make window","memory allocation failed"); X size_hints->flags=window_info->flags; X size_hints->x=window_info->x; X size_hints->y=window_info->y; X size_hints->width=window_info->width; X size_hints->height=window_info->height; X size_hints->flags|=PMinSize | PMaxSize; X if (!window_info->immutable) X { X /* X Window size can be changed. X */ X size_hints->min_width=window_info->min_width; X size_hints->min_height=window_info->min_height; X size_hints->max_width=XDisplayWidth(display,window_info->screen); X size_hints->max_height=XDisplayHeight(display,window_info->screen); X } X else X { X /* X Window size cannot be changed. X */ X size_hints->min_width=window_info->width; X size_hints->min_height=window_info->height; X size_hints->max_width=window_info->width; X size_hints->max_height=window_info->height; X } X size_hints->flags|=PResizeInc; X size_hints->width_inc=window_info->width_inc; X size_hints->height_inc=window_info->height_inc; #ifndef PRE_R4_ICCCM X size_hints->flags|=PBaseSize; X size_hints->base_width=size_hints->min_width; X size_hints->base_height=size_hints->min_height; #endif X if (window_info->geometry != (char *) NULL) X { X char X default_geometry[256]; X X int X flags, X gravity; X X /* X User specified geometry. X */ X (void) sprintf(default_geometry,"%dx%d\0",size_hints->width, X size_hints->height); X flags=XWMGeometry(display,window_info->screen,window_info->geometry, X default_geometry,window_info->border_width,size_hints,&size_hints->x, X &size_hints->y,&size_hints->width,&size_hints->height,&gravity); X window_info->x=size_hints->x; X window_info->y=size_hints->y; X if ((flags & WidthValue) && (flags & HeightValue)) X size_hints->flags|=USSize; X if ((flags & XValue) && (flags & YValue)) X size_hints->flags|=USPosition; #ifndef PRE_R4_ICCCM X size_hints->win_gravity=gravity; X size_hints->flags|=PWinGravity; #endif X } X window_info->id=XCreateWindow(display,parent,window_info->x,window_info->y, X window_info->width,window_info->height,window_info->border_width, X window_info->depth,InputOutput,window_info->visual_info->visual, X CWBackingStore | CWBackPixel | CWBackPixmap | CWBitGravity | X CWBorderPixel | CWColormap | CWCursor | CWDontPropagate | CWEventMask | X CWOverrideRedirect | CWSaveUnder | CWWinGravity,&window_info->attributes); X if (window_info->id == (Window) NULL) X Error("unable to create window",window_info->name); X name.value=(unsigned char *) window_info->name; X name.encoding=XA_STRING; X name.format=8; X name.nitems=strlen(window_info->name); X if (window_info->icon_geometry != (char *) NULL) X { X int X flags, X gravity, X height, X width; X X /* X User specified icon geometry. X */ X size_hints->flags|=USPosition; X flags=XWMGeometry(display,window_info->screen,window_info->icon_geometry, X (char *) NULL,0,size_hints,&manager_hints->icon_x, X &manager_hints->icon_y,&width,&height,&gravity); X if ((flags & XValue) && (flags & YValue)) X manager_hints->flags|=IconPositionHint; X } X XSetWMProperties(display,window_info->id,&name,&name,argv,argc,size_hints, X manager_hints,class_hint); X XSetWMProtocols(display,window_info->id,&property,1); X XFree((char *) size_hints); } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % X R e a d C o l o r m a p % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function XReadColormap returns the red, green, and blue colormap of a window. % Additionally, the number of colors in the colormap is returned. % % The format of the XReadColormap function is: % % number_colors=XReadColormap(display,window_attributes,colors) % % A description of each parameter follows: % % o number_colors:XReadColormap returns the number of colors in the % colormap. % % o display:Specifies a pointer to the Display structure; returned from % XOpenDisplay. % % o window_attributes:Specifies a pointer to the window attributes % structure; returned from XGetWindowAttributes. % % o colors:Specifies a an array of XColor structures. The colormap % red, green, and blue are returned. % % */ int XReadColormap(display,window_attributes,colors) Display X *display; X XXWindowAttributes X *window_attributes; X XXColor X **colors; { X int X number_colors; X X register int X i; X X if (window_attributes->colormap == (Colormap) NULL) X return(0); X number_colors=window_attributes->visual->map_entries; X *colors=(XColor *) malloc((unsigned) (number_colors*sizeof(XColor))); X if (*colors == (XColor *) NULL) X { X Warning("unable to read colormap","memory allocation failed"); X return(0); X } X for (i=0; i < number_colors; i++) X if ((window_attributes->visual->class != DirectColor) && X (window_attributes->visual->class != TrueColor)) X for (i=0; i < number_colors; i++) X { X (*colors)[i].pixel=i; X (*colors)[i].pad=0; X } X else X { X unsigned long X blue, X blue_bit, X green, X green_bit, X red, X red_bit; X X /* X DirectColor or TrueColor visual. X */ X red=0; X green=0; X blue=0; X red_bit=window_attributes->visual->red_mask & X (~(window_attributes->visual->red_mask)+1); X green_bit=window_attributes->visual->green_mask & X (~(window_attributes->visual->green_mask)+1); X blue_bit=window_attributes->visual->blue_mask & X (~(window_attributes->visual->blue_mask)+1); X for (i=0; i < number_colors; i++) X { X (*colors)[i].pixel=red | green | blue; X (*colors)[i].pad=0; X red+=red_bit; X if (red > window_attributes->visual->red_mask) X red=0; X green+=green_bit; X if (green > window_attributes->visual->green_mask) X green=0; X blue+=blue_bit; X if (blue > window_attributes->visual->blue_mask) X blue=0; X } X } X XQueryColors(display,window_attributes->colormap,*colors,number_colors); X return(number_colors); } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % X R e a d I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Procedure XReadImage reads an image from an X window. % % The format of the XReadImage routine is: % % image=XReadImage(display,root_window,target_window,client_window, % screen,borders) % % A description of each parameter follows: % % o image:specifies a pointer to the Image structure. % % o display:Specifies a pointer to the Display structure; returned from % XOpenDisplay. % % o root_window:Specifies the id of the root window. % % o target_window:Specifies the id of the target window. % % o client_window:Specifies the id of the client of the target window. % % o borders:Specifies whether borders pixels are to be saved with % the image. % % */ Image *XReadImage(display,root_window,target_window,client_window,screen, X borders) Display X *display; X Window X root_window, X target_window, X client_window; X unsigned int X screen, X borders; { X Image X *image; X X int X display_width, X display_height, X x, X y; X X register int X i; X X register RunlengthPacket X *p; X X register unsigned long X pixel; X X unsigned char X blue, X green, X red; X X Window X child; X X XColor X *colors; X X XImage X *ximage; X X XTextProperty X window_name; X X XWindowAttributes X client_attributes, X target_attributes; X X /* X Inform the user not to alter the screen. X */ X XBell(display,0); X /* X Get the attributes of the window being dumped. X */ X if ((XGetWindowAttributes(display,target_window,&target_attributes) == 0) || X (XGetWindowAttributes(display,client_window,&client_attributes) == 0)) X { X Warning("unable to get target window attributes",(char *) NULL); X return((Image *) NULL); X } X XTranslateCoordinates(display,target_window,root_window,0,0,&x,&y,&child); X target_attributes.x=x; X target_attributes.y=y; X /* X Allocate image structure. X */ X image=(Image *) malloc(sizeof(Image)); X if (image == (Image *) NULL) X { X Warning("unable to read image","memory allocation failed"); X return((Image *) NULL); X } X /* X Initialize Image structure. X */ X image->id=UnknownId; X image->class=DirectClass; X image->compression=NoCompression; X image->columns=target_attributes.width; X image->rows=target_attributes.height; X image->packets=0; X image->colors=0; X image->scene=0; X image->colormap=(ColorPacket *) NULL; X image->pixels=(RunlengthPacket *) NULL; X image->comments=(char *) NULL; X if (borders) X { X /* X Do not include border in image. X */ X x-=target_attributes.border_width; X y-=target_attributes.border_width; X image->columns+=2*target_attributes.border_width; X image->rows+=2*target_attributes.border_width; X } X if (screen) X /* X clip to window X */ X if (x < 0) X { X image->columns+=x; X x=0; X } X if (y < 0) X { X image->rows+=y; X y=0; X } X display_width=DisplayWidth(display,XDefaultScreen(display)); X display_height=DisplayHeight(display,XDefaultScreen(display)); X if ((x+(int) image->columns) > display_width) X image->columns=display_width-x; X if ((y+(int) image->rows) > display_height) X image->rows=display_height-y; X /* X Get image from window with XGetImage. X */ X if (screen) X ximage=XGetImage(display,root_window,x,y,image->columns,image->rows, X AllPlanes,ZPixmap); X else X { X x-=target_attributes.x; X y-=target_attributes.y; X ximage=XGetImage(display,target_window,x,y,image->columns,image->rows, X AllPlanes,ZPixmap); X } X if (ximage == (XImage *) NULL) X { X Warning("unable to read image",(char *) NULL); X DestroyImage(image); X return((Image *) NULL); X } X /* X Obtain the window colormap from the client of the target window. X */ X image->colors=XReadColormap(display,&client_attributes,&colors); X XBell(display,0); X XBell(display,0); X XFlush(display); X /* X Convert image to MIFF format. X */ X image->comments=(char *) NULL; X if (XGetWMName(display,target_window,&window_name) != 0) X { X /* X Initial image comment. X */ X image->comments=(char *) X malloc((unsigned int) (strlen((char *) window_name.value)+256)); X if (image->comments == (char *) NULL) X { X Warning("unable to read image","memory allocation failed"); X DestroyImage(image); X return((Image *) NULL); X } X (void) sprintf(image->comments,"\n Imported from X11 window: %s\n\0", X window_name.value); X } X if ((target_attributes.visual->class == TrueColor) || X (target_attributes.visual->class == DirectColor)) X image->class=DirectClass; X else X image->class=PseudoClass; X image->compression=RunlengthEncodedCompression; X image->scene=0; X image->pixels=(RunlengthPacket *) X malloc(image->columns*image->rows*sizeof(RunlengthPacket)); X if (image->pixels == (RunlengthPacket *) NULL) X { X Warning("unable to read image","memory allocation failed"); X DestroyImage(image); X return((Image *) NULL); X } X image->packets=0; X p=image->pixels; X p->length=MaxRunlength; X switch (image->class) X { X case DirectClass: X { X register unsigned long X color, X index; X X unsigned long X blue_mask, X blue_shift, X green_mask, X green_shift, X red_mask, X red_shift; X X /* X Determine shift and mask for red, green, and blue. X */ X red_mask=target_attributes.visual->red_mask; X red_shift=0; X while ((red_mask & 0x01) == 0) X { X red_mask>>=1; X red_shift++; X } X green_mask=target_attributes.visual->green_mask; X green_shift=0; X while ((green_mask & 0x01) == 0) X { X green_mask>>=1; X green_shift++; X } X blue_mask=target_attributes.visual->blue_mask; X blue_shift=0; X while ((blue_mask & 0x01) == 0) X { X blue_mask>>=1; X blue_shift++; X } X /* X Convert X image to DirectClass packets. X */ X if ((image->colors > 0) && X (target_attributes.visual->class == DirectColor)) X for (y=0; y < image->rows; y++) X { X for (x=0; x < image->columns; x++) X { X pixel=XGetPixel(ximage,x,y); X index=(pixel >> red_shift) & red_mask; X red=(unsigned char) (colors[index].red >> 8); X index=(pixel >> green_shift) & green_mask; X green=(unsigned char) (colors[index].green >> 8); X index=(pixel >> blue_shift) & blue_mask; X blue=(unsigned char) (colors[index].blue >> 8); X if ((red == p->red) && (green == p->green) && (blue == p->blue) && X (p->length < MaxRunlength)) X p->length++; X else X { X if (image->packets > 0) X p++; X image->packets++; X p->red=red; X p->green=green; X p->blue=blue; X p->index=0; X p->length=0; X } X } X } X else X for (y=0; y < image->rows; y++) X for (x=0; x < image->columns; x++) X { X pixel=XGetPixel(ximage,x,y); X color=(pixel >> red_shift) & red_mask; X red=(unsigned char) X ((((unsigned long) color*65535)/red_mask) >> 8); X color=(pixel >> green_shift) & green_mask; X green=(unsigned char) X ((((unsigned long) color*65535)/green_mask) >> 8); X color=(pixel >> blue_shift) & blue_mask; X blue=(unsigned char) X ((((unsigned long) color*65535)/blue_mask) >> 8); X if ((red == p->red) && (green == p->green) && (blue == p->blue) && X (p->length < MaxRunlength)) X p->length++; X else X { X if (image->packets > 0) X p++; X image->packets++; X p->red=red; X p->green=green; X p->blue=blue; X p->index=0; X p->length=0; X } X } X break; X } X case PseudoClass: X { X /* X Convert X image to PseudoClass packets. X */ X image->colormap=(ColorPacket *) X malloc((unsigned) (image->colors*sizeof(ColorPacket))); X if (image->colormap == (ColorPacket *) NULL) X { X Warning("unable to read image","memory allocation failed"); X DestroyImage(image); X return((Image *) NULL); X } X for (i=0; i < image->colors; i++) X { X image->colormap[i].red=colors[i].red >> 8; X image->colormap[i].green=colors[i].green >> 8; X image->colormap[i].blue=colors[i].blue >> 8; X } X for (y=0; y < image->rows; y++) X for (x=0; x < image->columns; x++) X { X pixel=XGetPixel(ximage,x,y); X red=(unsigned char) (colors[pixel].red >> 8); X green=(unsigned char) (colors[pixel].green >> 8); X blue=(unsigned char) (colors[pixel].blue >> 8); X if ((red == p->red) && (green == p->green) && (blue == p->blue) && X (p->length < MaxRunlength)) X p->length++; X else X { X if (image->packets > 0) X p++; X image->packets++; X p->red=red; X p->green=green; X p->blue=blue; X p->index=(unsigned short) pixel; X p->length=0; X } X } X break; X } X } X /* X Free image and colormap. X */ X if (image->colors > 0) X (void) free((char *) colors); X XDestroyImage(ximage); X if (image->packets > ((image->columns*image->rows*3) >> 2)) X image->compression=NoCompression; X image->pixels=(RunlengthPacket *) X realloc((char *) image->pixels,image->packets*sizeof(RunlengthPacket)); X return(image); } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % X S e l e c t W i n d o w % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function XSelectWindow allows a user to select a window using the mouse. % % The format of the XSelectWindow function is: % % target_window=XSelectWindow(display,root_window) % % A description of each parameter follows: % % o window:XSelectWindow returns the window id. % % o display:Specifies a pointer to the Display structure; returned from % XOpenDisplay. % % o root_window:Specifies the window id of the root window. % % */ Window XSelectWindow(display,root_window) Display X *display; X Window X root_window; { X Cursor X crosshair_cursor; X X int X presses, X status; X X Window X target_window; X X XEvent X event; X X /* X Make the target cursor. X */ X crosshair_cursor=XCreateFontCursor(display,XC_crosshair); X /* X Grab the pointer using target cursor. X */ X status=XGrabPointer(display,root_window,False,ButtonPressMask | X ButtonReleaseMask,GrabModeSync,GrabModeAsync,root_window,crosshair_cursor, X CurrentTime); X if (status != GrabSuccess) X Error("unable to grab the mouse",(char *) NULL); X /* X Select a window. X */ X target_window=(Window) NULL; X presses=0; X do X { X /* X Allow another event. X */ X XAllowEvents(display,SyncPointer,CurrentTime); X XWindowEvent(display,root_window,ButtonPressMask | ButtonReleaseMask, X &event); X switch (event.type) X { X case ButtonPress: X { X if (target_window == (Window) NULL) X { X target_window=event.xbutton.subwindow; X if (target_window == (Window) NULL) X target_window=root_window; X } X presses++; X break; X } X case ButtonRelease: X { X presses--; X break; X } X default: X break; X } X } X while ((target_window == (Window) NULL) || (presses > 0)); X XUngrabPointer(display,CurrentTime); X XFreeCursor(display,crosshair_cursor); X return(target_window); } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % X V i s u a l C l a s s N a m e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function XVisualClassName returns the visual class name as a character % string. % % The format of the XVisualClassName routine is: % % visual_type=XVisualClassName(visual_info) % % A description of each parameter follows: % % o visual_type: XVisualClassName returns the visual class as a character % string. % % o visual_info: Specifies a pointer to a X11 XVisualInfo structure; % returned from XGetVisualInfo. % % */ char *XVisualClassName(visual_info) XXVisualInfo X *visual_info; { X if (visual_info == (XVisualInfo *) NULL) X return((char *) NULL); X switch (visual_info->class) X { X case StaticGray: return("StaticGray"); X case GrayScale: return("GrayScale"); X case StaticColor: return("StaticColor"); X case PseudoColor: return("PseudoColor"); X case TrueColor: return("TrueColor"); X case DirectColor: return("DirectColor"); X } X return("unknown visual class"); } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % X W i n d o w B y N a m e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function XWindowByName locates a window with a given name on a display. % If no window with the given name is found, 0 is returned. If more than % one window has the given name, the first one is returned. Only root and % its children are searched. % % The format of the XWindowByName function is: % % window=XWindowByName(display,root_window,name) % % A description of each parameter follows: % % o window:XWindowByName returns the window id. % % o display:Specifies a pointer to the Display structure; returned from % XOpenDisplay. % % o root_window:Specifies the id of the root window. % % o name:Specifies the name of the window to locate. % % */ Window XWindowByName(display,root_window,name) Display X *display; X Window X root_window; X char X *name; { X register int X i; X X unsigned int X number_children; X X Window X *children, X child, X window; X X XTextProperty X window_name; X X if (XGetWMName(display,root_window,&window_name) != 0) X if (strcmp((char *) window_name.value,name) == 0) X return(root_window); X if (!XQueryTree(display,root_window,&child,&child,&children,&number_children)) X return(0); X window=0; X for (i=0; i < number_children; i++) X { X /* X Search each child and their children. X */ X window=XWindowByName(display,children[i],name); X if (window != (Window) NULL) X break; X } X if (children != (Window *) NULL) X XFree((char *) children); X return(window); } X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % X W i n d o w B y P r o p e r y % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function XWindowByProperty locates a child window with a given property. % If no window with the given name is found, 0 is returned. If more than % one window has the given property, the first one is returned. Only the % window specified and its subwindows are searched. % % The format of the XWindowByProperty function is: % % child=XWindowByProperty(display,window,property) % % A description of each parameter follows: % % o child:XWindowByProperty returns the window id with the specified % property. If no windows are found, XWindowByProperty returns 0. % % o display:Specifies a pointer to the Display structure; returned from % XOpenDisplay. % % o property:Specifies the property of the window to locate. % % */ Window XWindowByProperty(display,window,property) Display X *display; X Window X window; X Atom X property; { X Atom X type; X X int X format; X X unsigned char X *data; X X unsigned int X i, X number_children; X X unsigned long X after, X number_items; X X Window X *children, X child, X parent, X root; X X if (XQueryTree(display,window,&root,&parent,&children,&number_children) == 0) X return((Window) NULL); X type=(Atom) NULL; X child=(Window) NULL; X for (i=0; (i < number_children) && (child == (Window) NULL); i++) X { X (void) XGetWindowProperty(display,children[i],property,0L,0L,False, X AnyPropertyType,&type,&format,&number_items,&after,&data); X if (type != (Atom) NULL) X child=children[i]; X } X for (i = 0; (i < number_children) && (child == (Window) NULL); i++) X child=XWindowByProperty(display,children[i],property); X if (children != (Window *) NULL) X XFree((char *) children); X return(child); } SHAR_EOF echo 'File ImageMagick/X.c is complete' && chmod 0755 ImageMagick/X.c || echo 'restore of ImageMagick/X.c failed' Wc_c="`wc -c < 'ImageMagick/X.c'`" test 99539 -eq "$Wc_c" || echo 'ImageMagick/X.c: original size 99539, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= ImageMagick/animate.h ============== if test -f 'ImageMagick/animate.h' -a X"$1" != X"-c"; then echo 'x - skipping ImageMagick/animate.h (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting ImageMagick/animate.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/animate.h' && X /* X Define declarations. */ #ifdef SYSV #include <poll.h> poll((struct poll *) 0, (size_t) 0, usec / 1000); #define Delay(milliseconds) \ X poll((struct poll *) 0,(size_t) 0,milliseconds/1000); #else #ifdef vms #define Delay(milliseconds) #else #define Delay(milliseconds) \ { \ X struct timeval \ X timeout; \ X \ X timeout.tv_usec=(milliseconds % 1000)*1000; \ X timeout.tv_sec=milliseconds/1000; \ X select(0,(void *) 0,(void *) 0,(void *) 0,&timeout); \ } #endif #endif SHAR_EOF chmod 0755 ImageMagick/animate.h || echo 'restore of ImageMagick/animate.h failed' Wc_c="`wc -c < 'ImageMagick/animate.h'`" test 487 -eq "$Wc_c" || echo 'ImageMagick/animate.h: original size 487, current size' "$Wc_c" rm -f _shar_wnt_.tmp fi # ============= ImageMagick/animate.c ============== if test -f 'ImageMagick/animate.c' -a X"$1" != X"-c"; then echo 'x - skipping ImageMagick/animate.c (File already exists)' rm -f _shar_wnt_.tmp else > _shar_wnt_.tmp echo 'x - extracting ImageMagick/animate.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'ImageMagick/animate.c' && /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % AAA N N IIIII M M AAA TTTTT EEEEE % % A A NN N I MM MM A A T E % % AAAAA N N N I M M M AAAAA T EEE % % A A N NN I M M A A T E % % A A N N IIIII M M A A T EEEEE % % % % % % Animate Machine Independent File Format Image via X11. % % % % % % % % Software Design % % John Cristy % % January 1991 % % % % % % Copyright 1991 E. I. Dupont 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. Dupont de Nemours % % & Company not be used in advertising or publicity pertaining to % % distribution of the software without specific, written prior % % permission. E. I. Dupont 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. Dupont 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. Dupont 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. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Display is a machine architecture independent image processing % and display program. It can display any image in the MIFF format on % any workstation display running X. Display first determines the % hardware capabilities of the workstation. If the number of unique % colors in the 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. % % This means that a continuous-tone 24 bits/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 can display on a continuous-tone 24 % bits/pixels device. % % The Display program command syntax is: % % Usage: display [options ...] file [ [options ...] file ...] % % Where options include: % -backdrop display image centered on a backdrop % -clip geometry preferred size and location of the clipped image % -colors value preferred number of colors in the image % -delay milliseconds display the next image after pausing % -display server display image to this X server % -dither apply Floyd/Steinberg error diffusion to image % -gamma value level of gamma correction % -geometry geometry preferred size and location of the image window % -gray transform image to gray scale colors % -map type display image using this Standard Colormap % -monochrome transform image to black and white % -reflect reverse image scanlines % -rotate degrees apply Paeth rotation to the image % -scale geometry preferred size factors of the image % -treedepth value depth of the color classification tree % -verbose print detailed information about the image % -visual type display image using this visual type % % In addition to those listed above, you can specify these standard X % resources as command line options: -background, -bordercolor, % -borderwidth, -font, -foreground, -iconGeometry, -iconic, -name, or % -title. % % Change '-' to '+' in any option above to reverse its effect. For % example, specify +compress to store the image as uncompressed. % % Specify 'file' as '-' for standard input or output. % % Buttons % 1 press and drag to select a command from a pop-up menu % % Keys % 0-9 press to change the level of delay % p press to animate the sequence of images % s press to display the next image in the sequence % . press to continually display the sequence of images % a press to automatically reverse the sequence of images % f press to animate in the forward direction % r press to animate in the reverse direction % i press to display information about the image % q press to discard all images and exit program % % */ X /* X Include declarations. */ #include "display.h" #include "image.h" #include "X.h" X /* X Define declarations. */ #define AutoReverseAnimationState 0x0001 #define ConfigureWindowState 0x0002 #define DefaultState 0x0004 #define ExitState 0x0008 #define ForwardAnimationState 0x0010 #define HighlightState 0x0020 #define InfoMappedState 0x0040 #define PlayAnimationState 0x0080 #define RepeatAnimationState 0x0100 #define StepAnimationState 0x0200 X /* X Forward declarations. */ static void X XMenuWindow(); X /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % D e l a y % % % % % % % SHAR_EOF true || echo 'restore of ImageMagick/animate.c failed' fi echo 'End of ImageMagick part 20' echo 'File ImageMagick/animate.c is continued in part 21' echo 21 > _shar_seq_.tmp 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