1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * ©1995 Artsoft Development *
6 * 33659 Bielefeld-Senne *
7 * Telefon: (0521) 493245 *
8 * eMail: aeglos@valinor.owl.de *
9 * aeglos@uni-paderborn.de *
10 * q99492@pbhrzx.uni-paderborn.de *
11 *----------------------------------------------------------*
13 ***********************************************************/
24 extern void Delay(long);
38 struct IFF_ILBM_FORM_big_endian
41 unsigned char chunk_size[4];
45 struct IFF_ILBM_BMHD_big_endian
47 char Width[2], Height[2];
48 char LeftEdge[2], TopEdge[2];
53 char transparentColor[2];
54 char xAspect, yAspect;
55 char pageWidth[2], pageHeight[2];
60 unsigned int Width, Height;
61 int LeftEdge, TopEdge;
64 unsigned int Compression;
66 unsigned int transparentColor;
67 unsigned int xAspect, yAspect;
68 int pageWidth, pageHeight;
71 static int ConvertXImageDepth(Display *, XImage **);
72 static int Read_GIF_to_Pixmap_or_Bitmap(Display *, char *, Pixmap *, int);
74 #define READ_GIF_TO_BITMAP 0
75 #define READ_GIF_TO_PIXMAP 1
77 int Read_GIF_to_Bitmap(Display *display, char *filename, Pixmap *pixmap)
79 return(Read_GIF_to_Pixmap_or_Bitmap(display, filename,
80 pixmap, READ_GIF_TO_BITMAP));
83 int Read_GIF_to_Pixmap(Display *display, char *filename, Pixmap *pixmap)
85 return(Read_GIF_to_Pixmap_or_Bitmap(display, filename,
86 pixmap, READ_GIF_TO_PIXMAP));
89 int Read_GIF_to_Pixmap_or_Bitmap(Display *display, char *filename,
90 Pixmap *pixmap, int mode)
93 Pixmap new_pixmap = 0;
97 return_code = Read_GIF_to_XImage(display, filename, &image);
98 if (return_code != GIF_Success)
103 int screen = DefaultScreen(display);
104 Drawable root = RootWindow(display,screen);
105 int depth = DefaultDepth(display, screen);
106 int width = image->width;
107 int height = image->height;
109 if (mode == READ_GIF_TO_BITMAP)
112 unsigned long black_pixel = BlackPixel(display,screen);
113 int bytes_per_line = (width+7) / 8;
114 int size = bytes_per_line * height;
117 data = (char *)malloc(size);
119 return(GIF_NoMemory);
125 for(y=0;y<height;y++)
129 if (XGetPixel(image,x,y) == black_pixel)
130 data[y * bytes_per_line + x/8] |= (1 << (x%8));
134 new_pixmap = XCreateBitmapFromData(display,root,data,width,height);
138 return(GIF_NoMemory);
145 if (ConvertXImageDepth(display, &image) != GIF_Success)
146 return(GIF_ColorFailed);
148 new_pixmap = XCreatePixmap(display,root,width,height,depth);
151 return(GIF_NoMemory);
153 gcv.foreground = BlackPixel(display,screen);
154 gcv.background = WhitePixel(display,screen);
155 gc = XCreateGC(display, root, GCForeground | GCBackground, &gcv);
156 XPutImage(display,new_pixmap,gc,image,0,0,0,0,width,height);
158 XFreeGC(display, gc);
161 XDestroyImage(image);
164 *pixmap = new_pixmap;
170 * Read_GIF_to_XImage() - based strongly on...
172 * xgifload.c - based strongly on...
174 * gif2ras.c - Converts from a Compuserve GIF (tm) image to a Sun Raster image.
176 * Copyright (c) 1988, 1989 by Patrick J. Naughton
178 * Author: Patrick J. Naughton
179 * naughton@wind.sun.com
181 * Permission to use, copy, modify, and distribute this software and its
182 * documentation for any purpose and without fee is hereby granted,
183 * provided that the above copyright notice appear in all copies and that
184 * both that copyright notice and this permission notice appear in
185 * supporting documentation.
187 * This file is provided AS IS with no warranties of any kind. The author
188 * shall have no liability with respect to the infringement of copyrights,
189 * trade secrets or any patents by this file or any part thereof. In no
190 * event will the author be liable for any lost revenue or profits or
191 * other special, indirect and consequential damages.
196 typedef unsigned char byte;
198 static int ReadCode(void);
199 static void AddToPixel(byte);
200 static int ColorDicking(Display *);
202 #define NEXTBYTE (*ptr++)
203 #define IMAGESEP 0x2c
204 #define INTERLACEMASK 0x40
205 #define COLORMAPMASK 0x80
208 int BitOffset, /* Bit Offset of next code */
209 XC, YC, /* Output X and Y coords of current pixel */
210 Pass, /* Used by output routine if interlaced pic */
211 OutCount, /* Decompressor output 'stack count' */
212 RWidth, RHeight, /* screen dimensions */
213 Width, Height, /* image dimensions */
214 LeftOfs, TopOfs, /* image offset */
215 BitsPerPixel, /* Bits per pixel, read from GIF header */
216 BytesPerScanline, /* bytes per scanline in output raster */
217 ColorMapSize, /* number of colors */
218 Background, /* background color */
219 CodeSize, /* Code size, read from GIF header */
220 InitCodeSize, /* Starting code size, used during Clear */
221 Code, /* Value returned by ReadCode */
222 MaxCode, /* limiting value for current code size */
223 ClearCode, /* GIF clear code */
224 EOFCode, /* GIF end-of-information code */
225 CurCode, OldCode, InCode, /* Decompressor variables */
226 FirstFree, /* First free code, generated per GIF spec */
227 FreeCode, /* Decompressor, next free slot in hash table*/
228 FinChar, /* Decompressor variable */
229 BitMask, /* AND mask for data size */
230 ReadMask; /* Code AND mask for current code size */
232 static boolean Interlace, HasColormap;
234 static byte *ImageData; /* The result array */
235 static byte *RawGIF; /* The heap array to hold it, raw */
236 static byte *Raster; /* The raster data stream, unblocked */
238 /* The color map, read from the GIF header */
239 static byte Red[256], Green[256], Blue[256], used[256];
242 extern char *progname;
245 static unsigned long cols[256];
246 static XColor defs[256];
248 int Read_GIF_to_XImage(Display *display, char *filename, XImage **image)
251 register byte ch, ch1;
252 register byte *ptr, *ptr1;
254 int screen = DefaultScreen(display);
255 Visual *visual = DefaultVisual(display,screen);
256 XImage *new_image = NULL;
259 int Prefix[4096]; /* The hash table used by the decompressor */
261 int OutCode[1025]; /* An output array used by the decompressor */
263 BitOffset = XC = YC = Pass = OutCount = 0;
266 if (strcmp(filename,"-")==0)
269 filename = "<stdin>";
272 file = fopen(filename,"r");
275 return(GIF_OpenFailed);
277 /* find the size of the file */
279 filesize = ftell(file);
282 if (!(ptr = RawGIF = (byte *) malloc(filesize)))
283 return(GIF_NoMemory);
285 if (!(Raster = (byte *) malloc(filesize)))
286 return(GIF_NoMemory);
288 if (fread(ptr, filesize, 1, file) != 1)
289 return(GIF_ReadFailed);
291 if (strncmp(ptr, id, 6))
292 return(GIF_FileInvalid);
296 /* Get variables from the GIF screen descriptor */
299 RWidth = ch + 0x100 * NEXTBYTE; /* screen dimensions... not used. */
301 RHeight = ch + 0x100 * NEXTBYTE;
304 HasColormap = ((ch & COLORMAPMASK) ? True : False);
306 BitsPerPixel = (ch & 7) + 1;
307 numcols = ColorMapSize = 1 << BitsPerPixel;
308 BitMask = ColorMapSize - 1;
310 Background = NEXTBYTE; /* background color... not used. */
312 if (NEXTBYTE) /* supposed to be NULL */
313 return(GIF_FileInvalid);
315 /* Read in global colormap. */
319 for (i = 0; i < ColorMapSize; i++)
330 /* no colormap in GIF file */
331 fprintf(stderr,"%s: warning! no colortable in this file. Winging it.\n",
335 for (i=0; i<numcols; i++)
336 cols[i] = (unsigned long) i;
339 /* Check for image seperator */
341 if (NEXTBYTE != IMAGESEP)
342 return(GIF_FileInvalid);
344 /* Now read in values from the image descriptor */
347 LeftOfs = ch + 0x100 * NEXTBYTE;
349 TopOfs = ch + 0x100 * NEXTBYTE;
351 Width = ch + 0x100 * NEXTBYTE;
353 Height = ch + 0x100 * NEXTBYTE;
354 Interlace = ((NEXTBYTE & INTERLACEMASK) ? True : False);
357 fprintf(stderr, "%s:\n", filename);
358 fprintf(stderr, " %dx%d, %d bpp / %d colors, %sinterlaced\n",
359 Width,Height, BitsPerPixel,ColorMapSize,(Interlace ? "" : "non-"));
360 fprintf(stderr, " Reading file... ");
363 /* Note that I ignore the possible existence of a local color map.
364 * I'm told there aren't many files around that use them, and the spec
365 * says it's defined for future use. This could lead to an error
366 * reading some files.
369 /* Start reading the raster data. First we get the intial code size
370 * and compute decompressor constant values, based on this code size.
374 ClearCode = (1 << CodeSize);
375 EOFCode = ClearCode + 1;
376 FreeCode = FirstFree = ClearCode + 2;
378 /* The GIF spec has it that the code size is the code size used to
379 * compute the above values is the code size given in the file, but the
380 * code size used in compression/decompression is the code size given in
381 * the file plus one. (thus the ++).
385 InitCodeSize = CodeSize;
386 MaxCode = (1 << CodeSize);
387 ReadMask = MaxCode - 1;
389 /* Read the raster data. Here we just transpose it from the GIF array
390 * to the Raster array, turning it from a series of blocks into one long
391 * data stream, which makes life much easier for ReadCode().
398 while (ch--) *ptr1++ = NEXTBYTE;
399 if ((Raster - ptr1) > filesize)
400 return(GIF_FileInvalid);
404 free(RawGIF); /* We're done with the raw data now... */
407 fprintf(stderr, "done\n");
408 fprintf(stderr, " Decompressing... ");
411 /* Allocate the X Image */
412 ImageData = (byte *) malloc(Width*Height);
414 return(GIF_NoMemory);
416 new_image = XCreateImage(display,visual,8,ZPixmap,0,ImageData,
417 Width,Height,8,Width);
419 return(GIF_NoMemory);
421 BytesPerScanline = Width;
424 /* Decompress the file, continuing until you see the GIF EOF code.
425 * One obvious enhancement is to add checking for corrupt files here.
429 while (Code != EOFCode)
431 /* Clear code sets everything back to its initial value, then reads the
432 * immediately subsequent code as uncompressed data.
435 if (Code == ClearCode)
437 CodeSize = InitCodeSize;
438 MaxCode = (1 << CodeSize);
439 ReadMask = MaxCode - 1;
440 FreeCode = FirstFree;
441 CurCode = OldCode = Code = ReadCode();
442 FinChar = CurCode & BitMask;
447 /* If not a clear code, then must be data:
448 * save same as CurCode and InCode
451 CurCode = InCode = Code;
453 /* If greater or equal to FreeCode, not in the hash table yet;
454 * repeat the last character decoded
457 if (CurCode >= FreeCode)
460 OutCode[OutCount++] = FinChar;
463 /* Unless this code is raw data, pursue the chain pointed to by CurCode
464 * through the hash table to its end; each code in the chain puts its
465 * associated output code on the output queue.
468 while (CurCode > BitMask)
471 return(GIF_FileInvalid);
473 OutCode[OutCount++] = Suffix[CurCode];
474 CurCode = Prefix[CurCode];
477 /* The last code in the chain is treated as raw data. */
479 FinChar = CurCode & BitMask;
480 OutCode[OutCount++] = FinChar;
482 /* Now we put the data out to the Output routine.
483 * It's been stacked LIFO, so deal with it that way...
486 for (i = OutCount - 1; i >= 0; i--)
487 AddToPixel(OutCode[i]);
490 /* Build the hash table on-the-fly. No table is stored in the file. */
492 Prefix[FreeCode] = OldCode;
493 Suffix[FreeCode] = FinChar;
496 /* Point to the next slot in the table. If we exceed the current
497 * MaxCode value, increment the code size unless it's already 12. If it
498 * is, do nothing: the next code decompressed better be CLEAR
502 if (FreeCode >= MaxCode)
508 ReadMask = (1 << CodeSize) - 1;
518 fprintf(stderr, "done\n");
519 fprintf(stderr," %d colors used\n",numused);
525 if (ColorDicking(display) != GIF_Success)
526 return(GIF_ColorFailed);
533 /* Fetch the next code from the raster data stream. The codes can be
534 * any length from 3 to 12 bits, packed into 8-bit bytes, so we have to
535 * maintain our location in the Raster array as a BIT Offset. We compute
536 * the byte Offset into the raster array by dividing this by 8, pick up
537 * three bytes, compute the bit Offset into our 24-bit chunk, shift to
538 * bring the desired code to the bottom, then mask it off and return it.
541 static int ReadCode()
543 int RawCode, ByteOffset;
545 ByteOffset = BitOffset / 8;
546 RawCode = Raster[ByteOffset] + (0x100 * Raster[ByteOffset + 1]);
548 RawCode += (0x10000 * Raster[ByteOffset + 2]);
549 RawCode >>= (BitOffset % 8);
550 BitOffset += CodeSize;
551 return(RawCode & ReadMask);
555 static void AddToPixel(byte Index)
558 *(ImageData + YC * BytesPerScanline + XC) = Index;
566 /* Update the X-coordinate, and if it overflows, update the Y-coordinate */
570 /* If a non-interlaced picture, just increment YC to the next scan line.
571 * If it's interlaced, deal with the interlace as described in the GIF
572 * spec. Put the decoded scan line out to the screen if we haven't gone
573 * past the bottom of it
622 static int ColorDicking(Display *display)
624 /* we've got the picture loaded, we know what colors are needed. get 'em */
627 static byte lmasks[8] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80};
629 int screen = DefaultScreen(display);
630 Colormap cmap = DefaultColormap(display,screen);
631 int dispcells = DisplayCells(display,screen);
638 /* no need to allocate any colors if no colormap in GIF file */
640 /* Allocate the X colors for this picture */
644 /* nostrip was set. try REAL hard to do it */
645 for (i=j=0; i<numcols; i++)
649 defs[i].red = Red[i]<<8;
650 defs[i].green = Green[i]<<8;
651 defs[i].blue = Blue[i]<<8;
652 defs[i].flags = DoRed | DoGreen | DoBlue;
653 if (!XAllocColor(display,cmap,&defs[i]))
656 defs[i].pixel = 0xffff;
658 cols[i] = defs[i].pixel;
664 /* failed to pull it off */
669 dc = (dispcells<256) ? dispcells : 256;
672 "failed to allocate %d out of %d colors. Trying extra hard.\n",
675 /* read in the color table */
678 XQueryColors(display,cmap,ctab,dc);
680 /* run through the used colors. any used color that has a pixel
681 value of 0xffff wasn't allocated. for such colors, run through
682 the entire X colormap and pick the closest color */
684 for (i=0; i<numcols; i++)
685 if (used[i] && cols[i]==0xffff)
687 /* an unallocated pixel */
692 mdist = 100000; close = -1;
698 d = abs(r - (ctab[j].red>>8)) +
699 abs(g - (ctab[j].green>>8)) +
700 abs(b - (ctab[j].blue>>8));
709 return(GIF_ColorFailed);
711 bcopy(&defs[close],&defs[i],sizeof(XColor));
712 cols[i] = ctab[close].pixel;
714 } /* end 'failed to pull it off' */
718 /* strip wasn't set, do the best auto-strip */
723 lmask = lmasks[strip];
724 for (i=0; i<numcols; i++)
728 defs[i].red = (Red[i] &lmask)<<8;
729 defs[i].green = (Green[i]&lmask)<<8;
730 defs[i].blue = (Blue[i] &lmask)<<8;
731 defs[i].flags = DoRed | DoGreen | DoBlue;
732 if (!XAllocColor(display,cmap,&defs[i]))
734 cols[i] = defs[i].pixel;
745 XFreeColors(display,cmap,cols+i,1,0L);
753 fprintf(stderr,"%s: stripped %d bits\n",progname,strip);
758 fprintf(stderr,"UTTERLY failed to allocate the desired colors.\n");
759 for (i=0; i<numcols; i++) cols[i]=i;
764 for (i=0; i<Height; i++)
765 for (j=0; j<Width; j++,ptr++)
766 *ptr = (byte) cols[*ptr];
772 /******************************************************************************
773 * This makes sure the display's depth is the same as the
774 * depth of the default 8 bit image. If not, we build a new image
775 * that has the correct depth. This works on the fact that
776 * the color mapper has already changed every pixel value in the
777 * image into the proper number of bits (to fit into the pallet)
778 * so we can just chop down the number of bits.
779 * This changes the global variable 'expImage' if necessary.
782 static int ConvertXImageDepth(Display *display, XImage **image)
784 int screen = DefaultScreen(display);
785 int depth = DefaultDepth(display, screen);
792 printf("ConvertXImageDepth:\n");
793 printf("(*image)->depth == %d\n",
795 printf("DefaultDepth(display, screen) == %d\n",
796 DefaultDepth(display, screen));
801 if ((*image)->depth != depth)
803 XImage *old_image, *new_image;
805 Visual *visual = DefaultVisual(display,screen);
807 int width = (*image)->width;
808 int height = (*image)->height;
809 register int dwx, dwy;
816 printf("ConvertXImageDepth: ---------> CONVERTING...\n");
823 data = (byte *)malloc(width * height * depth);
827 new_image = XCreateImage(display,visual,depth,
828 ZPixmap,0,data,width,height,8,0);
830 new_image = XGetImage(display,RootWindow(display,screen),
831 0,0,width,height,0xffffffff,ZPixmap);
835 return(GIF_NoMemory);
837 if (old_image->depth == 8 && new_image->depth == 4)
839 /* speedup for the most common format change */
841 register byte *sptr = (byte *)old_image->data;
842 register byte *dptr = (byte *)new_image->data;
844 for (dwy=1; dwy<=height; dwy++)
846 for (dwx=1; dwx<width; dwx+=2)
848 *dptr = (*sptr) | (*(sptr+1)<<4);
854 /* if extra pixal at end of line, just move it */
860 else /* other format change than 8 bit -> 4 bit */
862 unsigned long pixel_value;
864 for (dwx=0; dwx<width; dwx++)
866 for (dwy=0; dwy<height; dwy++)
868 pixel_value = XGetPixel(old_image, dwx, dwy);
870 if (pixel_value > 0xff)
871 printf("pixel = %lx", pixel_value);
873 XPutPixel(new_image, dwx, dwy, pixel_value);
878 free(old_image->data);
879 old_image->data = NULL;
880 XDestroyImage(old_image);
889 static unsigned long be2long(unsigned char *be) /* big-endian -> long int */
891 return((be[0]<<24) | (be[1]<<16) | (be[2]<<8) | be[3]);
894 static unsigned short be2short(unsigned char *be) /* big-endian -> short int */
896 return((be[0]<<8) | be[1]);
899 static struct IFF_ILBM_BMHD *ConvertBMHD(unsigned char *header_data)
901 struct IFF_ILBM_BMHD_big_endian *bmhd_be;
902 struct IFF_ILBM_BMHD *bmhd;
904 bmhd_be = (struct IFF_ILBM_BMHD_big_endian *)header_data;
905 bmhd = (struct IFF_ILBM_BMHD *)malloc(sizeof(struct IFF_ILBM_BMHD));
909 bmhd->Width = be2short(bmhd_be->Width);
910 bmhd->Height = be2short(bmhd_be->Height);
911 bmhd->LeftEdge = be2short(bmhd_be->LeftEdge);
912 bmhd->TopEdge = be2short(bmhd_be->TopEdge);
913 bmhd->Depth = (int)bmhd_be->Depth;
914 bmhd->Mask = (int)bmhd_be->Mask;
915 bmhd->Compression = (int)bmhd_be->Compression;
916 bmhd->pad1 = bmhd_be->pad1;
917 bmhd->transparentColor = be2short(bmhd_be->transparentColor);
918 bmhd->xAspect = (int)bmhd_be->xAspect;
919 bmhd->yAspect = (int)bmhd_be->yAspect;
920 bmhd->pageWidth = be2short(bmhd_be->pageWidth);
921 bmhd->pageHeight = be2short(bmhd_be->pageHeight);
926 static unsigned char MSBitFirst2LSBitFirst(unsigned char msb_byte)
928 unsigned char lsb_byte = 0;
933 lsb_byte |= (msb_byte & 1) << i;
940 int Read_ILBM_to_Bitmap(Display *display, char *filename, Pixmap *pixmap)
942 Pixmap new_pixmap = 0;
943 int screen = DefaultScreen(display);
944 Drawable root = RootWindow(display,screen);
945 struct IFF_ILBM_FORM_big_endian *form_header;
946 struct IFF_ILBM_BMHD *bitmap_header;
947 unsigned long file_len, body_len;
948 unsigned char *file_data, *bitmap_data;
949 unsigned char *file_ptr, *bitmap_ptr, *body_ptr;
950 unsigned char byte_count, byte_value;
952 int width, height, depth;
953 int bytes_per_line, bitmap_size;
956 if (!(file = fopen(filename,"r")))
957 return(ILBM_OpenFailed);
959 if (fseek(file,0,SEEK_END) < 0)
962 return(ILBM_ReadFailed);
965 file_len = ftell(file);
968 if (!(file_data = (unsigned char *)malloc(file_len)))
971 return(ILBM_NoMemory);
974 if (fread(file_data,1,file_len,file) != file_len)
978 return(ILBM_ReadFailed);
983 form_header = (struct IFF_ILBM_FORM_big_endian *)file_data;
985 if (strncmp(form_header->magic_FORM,"FORM",4) ||
986 file_len != be2long(form_header->chunk_size)+8 ||
987 strncmp(form_header->magic_ILBM,"ILBM",4))
990 printf("%s: IFF chunk 'FORM' and/or 'ILBM' not found.\n",filename);
993 return(ILBM_FileInvalid);
996 bitmap_header = NULL;
998 file_ptr = file_data + 12;
1000 while(file_ptr < (unsigned char *)(file_data + file_len))
1002 if (!strncmp(file_ptr,"BMHD",4))
1005 printf("%s: IFF chunk 'BMHD' found.\n",filename);
1007 bitmap_header = ConvertBMHD(file_ptr + 8);
1008 file_ptr += be2long(file_ptr + 4) + 8;
1011 else if (!strncmp(file_ptr,"BODY",4))
1014 printf("%s: IFF chunk 'BODY' found.\n",filename);
1016 body_ptr = file_ptr + 8;
1017 body_len = be2long(file_ptr + 4);
1018 file_ptr += be2long(file_ptr + 4) + 8;
1024 printf("%s: IFF chunk '%c%c%c%c' found (but not used).\n",filename,
1025 file_ptr[0],file_ptr[1],file_ptr[2],file_ptr[3]);
1027 /* other chunk not recognized here */
1028 file_ptr += be2long(file_ptr + 4) + 8;
1033 if (!bitmap_header || !body_ptr)
1036 printf("%s: IFF chunk 'BMHD' and/or 'BODY' not found.\n",filename);
1039 return(ILBM_FileInvalid);
1042 width = bitmap_header->Width;
1043 height = bitmap_header->Height;
1044 depth = bitmap_header->Depth;
1048 printf("%s: %d bitplanes found; using only the first plane.\n",
1052 bytes_per_line = ((width + 15) / 16) * 2;
1053 bitmap_size = bytes_per_line * height;
1055 bitmap_data = (char *)malloc(bitmap_size);
1059 free(bitmap_header);
1060 return(ILBM_NoMemory);
1063 bitmap_ptr = bitmap_data;
1064 for(i=0;i<bitmap_size;i++)
1067 for(y=0;y<height;y++)
1069 /* we only read the first bitplane here to create a black/white bitmap */
1071 for(z=0;z<depth;z++)
1073 bitmap_ptr = bitmap_data + y * bytes_per_line;
1076 if (!bitmap_header->Compression)
1078 while(x++ < bytes_per_line)
1079 *bitmap_ptr++ |= MSBitFirst2LSBitFirst(*body_ptr++);
1083 while(x < bytes_per_line)
1085 byte_count = *body_ptr++;
1087 if (byte_count <= 128)
1089 for(i=0;i<byte_count+1;i++)
1090 *bitmap_ptr++ |= MSBitFirst2LSBitFirst(*body_ptr++);
1091 x += byte_count + 1;
1095 byte_value = *body_ptr++;
1096 for(i=0;i<257-byte_count;i++)
1097 *bitmap_ptr++ |= MSBitFirst2LSBitFirst(byte_value);
1098 x += 257 - byte_count;
1105 bitmap_ptr = bitmap_data;
1106 for(i=0;i<bitmap_size;i++)
1107 *bitmap_ptr++ ^= 0xff;
1109 new_pixmap = XCreateBitmapFromData(display,root,bitmap_data,width,height);
1113 free(bitmap_header);
1116 return(ILBM_NoMemory);
1118 *pixmap = new_pixmap;
1119 return(ILBM_Success);