1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-98 Artsoft Entertainment *
8 * phone: ++49 +521 290471 *
9 * email: aeglos@valinor.owl.de *
10 *----------------------------------------------------------*
12 ***********************************************************/
23 extern void Delay(long);
37 struct IFF_ILBM_FORM_big_endian
40 unsigned char chunk_size[4];
44 struct IFF_ILBM_BMHD_big_endian
46 char Width[2], Height[2];
47 char LeftEdge[2], TopEdge[2];
52 char transparentColor[2];
53 char xAspect, yAspect;
54 char pageWidth[2], pageHeight[2];
59 unsigned int Width, Height;
60 int LeftEdge, TopEdge;
63 unsigned int Compression;
65 unsigned int transparentColor;
66 unsigned int xAspect, yAspect;
67 int pageWidth, pageHeight;
70 static int ConvertXImageDepth(Display *, XImage **);
71 static int Read_GIF_to_Pixmap_or_Bitmap(Display *, char *, Pixmap *, int);
73 #define READ_GIF_TO_BITMAP 0
74 #define READ_GIF_TO_PIXMAP 1
76 int Read_GIF_to_Bitmap(Display *display, char *filename, Pixmap *pixmap)
78 return(Read_GIF_to_Pixmap_or_Bitmap(display, filename,
79 pixmap, READ_GIF_TO_BITMAP));
82 int Read_GIF_to_Pixmap(Display *display, char *filename, Pixmap *pixmap)
84 return(Read_GIF_to_Pixmap_or_Bitmap(display, filename,
85 pixmap, READ_GIF_TO_PIXMAP));
88 int Read_GIF_to_Pixmap_or_Bitmap(Display *display, char *filename,
89 Pixmap *pixmap, int mode)
92 Pixmap new_pixmap = 0;
96 return_code = Read_GIF_to_XImage(display, filename, &image);
97 if (return_code != GIF_Success)
102 int screen = DefaultScreen(display);
103 Drawable root = RootWindow(display,screen);
104 int depth = DefaultDepth(display, screen);
105 int width = image->width;
106 int height = image->height;
108 if (mode == READ_GIF_TO_BITMAP)
111 unsigned long black_pixel = BlackPixel(display,screen);
112 int bytes_per_line = (width+7) / 8;
113 int size = bytes_per_line * height;
116 data = (char *)malloc(size);
118 return(GIF_NoMemory);
124 for(y=0;y<height;y++)
128 if (XGetPixel(image,x,y) == black_pixel)
129 data[y * bytes_per_line + x/8] |= (1 << (x%8));
133 new_pixmap = XCreateBitmapFromData(display,root,data,width,height);
137 return(GIF_NoMemory);
144 if (ConvertXImageDepth(display, &image) != GIF_Success)
145 return(GIF_ColorFailed);
147 new_pixmap = XCreatePixmap(display,root,width,height,depth);
150 return(GIF_NoMemory);
152 gcv.foreground = BlackPixel(display,screen);
153 gcv.background = WhitePixel(display,screen);
154 gc = XCreateGC(display, root, GCForeground | GCBackground, &gcv);
155 XPutImage(display,new_pixmap,gc,image,0,0,0,0,width,height);
157 XFreeGC(display, gc);
160 XDestroyImage(image);
163 *pixmap = new_pixmap;
169 * Read_GIF_to_XImage() - based strongly on...
171 * xgifload.c - based strongly on...
173 * gif2ras.c - Converts from a Compuserve GIF (tm) image to a Sun Raster image.
175 * Copyright (c) 1988, 1989 by Patrick J. Naughton
177 * Author: Patrick J. Naughton
178 * naughton@wind.sun.com
180 * Permission to use, copy, modify, and distribute this software and its
181 * documentation for any purpose and without fee is hereby granted,
182 * provided that the above copyright notice appear in all copies and that
183 * both that copyright notice and this permission notice appear in
184 * supporting documentation.
186 * This file is provided AS IS with no warranties of any kind. The author
187 * shall have no liability with respect to the infringement of copyrights,
188 * trade secrets or any patents by this file or any part thereof. In no
189 * event will the author be liable for any lost revenue or profits or
190 * other special, indirect and consequential damages.
195 typedef unsigned char byte;
197 static int ReadCode(void);
198 static void AddToPixel(byte);
199 static int ColorDicking(Display *);
201 #define NEXTBYTE (*ptr++)
202 #define IMAGESEP 0x2c
203 #define INTERLACEMASK 0x40
204 #define COLORMAPMASK 0x80
207 int BitOffset, /* Bit Offset of next code */
208 XC, YC, /* Output X and Y coords of current pixel */
209 Pass, /* Used by output routine if interlaced pic */
210 OutCount, /* Decompressor output 'stack count' */
211 RWidth, RHeight, /* screen dimensions */
212 Width, Height, /* image dimensions */
213 LeftOfs, TopOfs, /* image offset */
214 BitsPerPixel, /* Bits per pixel, read from GIF header */
215 BytesPerScanline, /* bytes per scanline in output raster */
216 ColorMapSize, /* number of colors */
217 Background, /* background color */
218 CodeSize, /* Code size, read from GIF header */
219 InitCodeSize, /* Starting code size, used during Clear */
220 Code, /* Value returned by ReadCode */
221 MaxCode, /* limiting value for current code size */
222 ClearCode, /* GIF clear code */
223 EOFCode, /* GIF end-of-information code */
224 CurCode, OldCode, InCode, /* Decompressor variables */
225 FirstFree, /* First free code, generated per GIF spec */
226 FreeCode, /* Decompressor, next free slot in hash table*/
227 FinChar, /* Decompressor variable */
228 BitMask, /* AND mask for data size */
229 ReadMask; /* Code AND mask for current code size */
231 static boolean Interlace, HasColormap;
233 static byte *ImageData; /* The result array */
234 static byte *RawGIF; /* The heap array to hold it, raw */
235 static byte *Raster; /* The raster data stream, unblocked */
237 /* The color map, read from the GIF header */
238 static byte Red[256], Green[256], Blue[256], used[256];
241 extern char *progname;
244 static unsigned long cols[256];
245 static XColor defs[256];
247 int Read_GIF_to_XImage(Display *display, char *filename, XImage **image)
250 register byte ch, ch1;
251 register byte *ptr, *ptr1;
253 int screen = DefaultScreen(display);
254 Visual *visual = DefaultVisual(display,screen);
255 XImage *new_image = NULL;
258 int Prefix[4096]; /* The hash table used by the decompressor */
260 int OutCode[1025]; /* An output array used by the decompressor */
262 BitOffset = XC = YC = Pass = OutCount = 0;
265 if (strcmp(filename,"-")==0)
268 filename = "<stdin>";
271 file = fopen(filename,"r");
274 return(GIF_OpenFailed);
276 /* find the size of the file */
278 filesize = ftell(file);
281 if (!(ptr = RawGIF = (byte *) malloc(filesize)))
282 return(GIF_NoMemory);
284 if (!(Raster = (byte *) malloc(filesize)))
285 return(GIF_NoMemory);
287 if (fread(ptr, filesize, 1, file) != 1)
288 return(GIF_ReadFailed);
290 if (strncmp(ptr, id, 6))
291 return(GIF_FileInvalid);
295 /* Get variables from the GIF screen descriptor */
298 RWidth = ch + 0x100 * NEXTBYTE; /* screen dimensions... not used. */
300 RHeight = ch + 0x100 * NEXTBYTE;
303 HasColormap = ((ch & COLORMAPMASK) ? True : False);
305 BitsPerPixel = (ch & 7) + 1;
306 numcols = ColorMapSize = 1 << BitsPerPixel;
307 BitMask = ColorMapSize - 1;
309 Background = NEXTBYTE; /* background color... not used. */
311 if (NEXTBYTE) /* supposed to be NULL */
312 return(GIF_FileInvalid);
314 /* Read in global colormap. */
318 for (i = 0; i < ColorMapSize; i++)
329 /* no colormap in GIF file */
330 fprintf(stderr,"%s: warning! no colortable in this file. Winging it.\n",
334 for (i=0; i<numcols; i++)
335 cols[i] = (unsigned long) i;
338 /* Check for image seperator */
340 if (NEXTBYTE != IMAGESEP)
341 return(GIF_FileInvalid);
343 /* Now read in values from the image descriptor */
346 LeftOfs = ch + 0x100 * NEXTBYTE;
348 TopOfs = ch + 0x100 * NEXTBYTE;
350 Width = ch + 0x100 * NEXTBYTE;
352 Height = ch + 0x100 * NEXTBYTE;
353 Interlace = ((NEXTBYTE & INTERLACEMASK) ? True : False);
356 fprintf(stderr, "%s:\n", filename);
357 fprintf(stderr, " %dx%d, %d bpp / %d colors, %sinterlaced\n",
358 Width,Height, BitsPerPixel,ColorMapSize,(Interlace ? "" : "non-"));
359 fprintf(stderr, " Reading file... ");
362 /* Note that I ignore the possible existence of a local color map.
363 * I'm told there aren't many files around that use them, and the spec
364 * says it's defined for future use. This could lead to an error
365 * reading some files.
368 /* Start reading the raster data. First we get the intial code size
369 * and compute decompressor constant values, based on this code size.
373 ClearCode = (1 << CodeSize);
374 EOFCode = ClearCode + 1;
375 FreeCode = FirstFree = ClearCode + 2;
377 /* The GIF spec has it that the code size is the code size used to
378 * compute the above values is the code size given in the file, but the
379 * code size used in compression/decompression is the code size given in
380 * the file plus one. (thus the ++).
384 InitCodeSize = CodeSize;
385 MaxCode = (1 << CodeSize);
386 ReadMask = MaxCode - 1;
388 /* Read the raster data. Here we just transpose it from the GIF array
389 * to the Raster array, turning it from a series of blocks into one long
390 * data stream, which makes life much easier for ReadCode().
397 while (ch--) *ptr1++ = NEXTBYTE;
398 if ((Raster - ptr1) > filesize)
399 return(GIF_FileInvalid);
403 free(RawGIF); /* We're done with the raw data now... */
406 fprintf(stderr, "done\n");
407 fprintf(stderr, " Decompressing... ");
410 /* Allocate the X Image */
411 ImageData = (byte *) malloc(Width*Height);
413 return(GIF_NoMemory);
415 new_image = XCreateImage(display,visual,8,ZPixmap,0,ImageData,
416 Width,Height,8,Width);
418 return(GIF_NoMemory);
420 BytesPerScanline = Width;
423 /* Decompress the file, continuing until you see the GIF EOF code.
424 * One obvious enhancement is to add checking for corrupt files here.
428 while (Code != EOFCode)
430 /* Clear code sets everything back to its initial value, then reads the
431 * immediately subsequent code as uncompressed data.
434 if (Code == ClearCode)
436 CodeSize = InitCodeSize;
437 MaxCode = (1 << CodeSize);
438 ReadMask = MaxCode - 1;
439 FreeCode = FirstFree;
440 CurCode = OldCode = Code = ReadCode();
441 FinChar = CurCode & BitMask;
446 /* If not a clear code, then must be data:
447 * save same as CurCode and InCode
450 CurCode = InCode = Code;
452 /* If greater or equal to FreeCode, not in the hash table yet;
453 * repeat the last character decoded
456 if (CurCode >= FreeCode)
459 OutCode[OutCount++] = FinChar;
462 /* Unless this code is raw data, pursue the chain pointed to by CurCode
463 * through the hash table to its end; each code in the chain puts its
464 * associated output code on the output queue.
467 while (CurCode > BitMask)
470 return(GIF_FileInvalid);
472 OutCode[OutCount++] = Suffix[CurCode];
473 CurCode = Prefix[CurCode];
476 /* The last code in the chain is treated as raw data. */
478 FinChar = CurCode & BitMask;
479 OutCode[OutCount++] = FinChar;
481 /* Now we put the data out to the Output routine.
482 * It's been stacked LIFO, so deal with it that way...
485 for (i = OutCount - 1; i >= 0; i--)
486 AddToPixel(OutCode[i]);
489 /* Build the hash table on-the-fly. No table is stored in the file. */
491 Prefix[FreeCode] = OldCode;
492 Suffix[FreeCode] = FinChar;
495 /* Point to the next slot in the table. If we exceed the current
496 * MaxCode value, increment the code size unless it's already 12. If it
497 * is, do nothing: the next code decompressed better be CLEAR
501 if (FreeCode >= MaxCode)
507 ReadMask = (1 << CodeSize) - 1;
517 fprintf(stderr, "done\n");
518 fprintf(stderr," %d colors used\n",numused);
524 if (ColorDicking(display) != GIF_Success)
525 return(GIF_ColorFailed);
532 /* Fetch the next code from the raster data stream. The codes can be
533 * any length from 3 to 12 bits, packed into 8-bit bytes, so we have to
534 * maintain our location in the Raster array as a BIT Offset. We compute
535 * the byte Offset into the raster array by dividing this by 8, pick up
536 * three bytes, compute the bit Offset into our 24-bit chunk, shift to
537 * bring the desired code to the bottom, then mask it off and return it.
540 static int ReadCode()
542 int RawCode, ByteOffset;
544 ByteOffset = BitOffset / 8;
545 RawCode = Raster[ByteOffset] + (0x100 * Raster[ByteOffset + 1]);
547 RawCode += (0x10000 * Raster[ByteOffset + 2]);
548 RawCode >>= (BitOffset % 8);
549 BitOffset += CodeSize;
550 return(RawCode & ReadMask);
554 static void AddToPixel(byte Index)
557 *(ImageData + YC * BytesPerScanline + XC) = Index;
565 /* Update the X-coordinate, and if it overflows, update the Y-coordinate */
569 /* If a non-interlaced picture, just increment YC to the next scan line.
570 * If it's interlaced, deal with the interlace as described in the GIF
571 * spec. Put the decoded scan line out to the screen if we haven't gone
572 * past the bottom of it
621 static int ColorDicking(Display *display)
623 /* we've got the picture loaded, we know what colors are needed. get 'em */
626 static byte lmasks[8] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80};
628 int screen = DefaultScreen(display);
629 Colormap cmap = DefaultColormap(display,screen);
630 int dispcells = DisplayCells(display,screen);
637 /* no need to allocate any colors if no colormap in GIF file */
639 /* Allocate the X colors for this picture */
643 /* nostrip was set. try REAL hard to do it */
644 for (i=j=0; i<numcols; i++)
648 defs[i].red = Red[i]<<8;
649 defs[i].green = Green[i]<<8;
650 defs[i].blue = Blue[i]<<8;
651 defs[i].flags = DoRed | DoGreen | DoBlue;
652 if (!XAllocColor(display,cmap,&defs[i]))
655 defs[i].pixel = 0xffff;
657 cols[i] = defs[i].pixel;
663 /* failed to pull it off */
668 dc = (dispcells<256) ? dispcells : 256;
671 "failed to allocate %d out of %d colors. Trying extra hard.\n",
674 /* read in the color table */
677 XQueryColors(display,cmap,ctab,dc);
679 /* run through the used colors. any used color that has a pixel
680 value of 0xffff wasn't allocated. for such colors, run through
681 the entire X colormap and pick the closest color */
683 for (i=0; i<numcols; i++)
684 if (used[i] && cols[i]==0xffff)
686 /* an unallocated pixel */
691 mdist = 100000; close = -1;
697 d = abs(r - (ctab[j].red>>8)) +
698 abs(g - (ctab[j].green>>8)) +
699 abs(b - (ctab[j].blue>>8));
708 return(GIF_ColorFailed);
710 bcopy(&defs[close],&defs[i],sizeof(XColor));
711 cols[i] = ctab[close].pixel;
713 } /* end 'failed to pull it off' */
717 /* strip wasn't set, do the best auto-strip */
722 lmask = lmasks[strip];
723 for (i=0; i<numcols; i++)
727 defs[i].red = (Red[i] &lmask)<<8;
728 defs[i].green = (Green[i]&lmask)<<8;
729 defs[i].blue = (Blue[i] &lmask)<<8;
730 defs[i].flags = DoRed | DoGreen | DoBlue;
731 if (!XAllocColor(display,cmap,&defs[i]))
733 cols[i] = defs[i].pixel;
744 XFreeColors(display,cmap,cols+i,1,0L);
752 fprintf(stderr,"%s: stripped %d bits\n",progname,strip);
757 fprintf(stderr,"UTTERLY failed to allocate the desired colors.\n");
758 for (i=0; i<numcols; i++) cols[i]=i;
763 for (i=0; i<Height; i++)
764 for (j=0; j<Width; j++,ptr++)
765 *ptr = (byte) cols[*ptr];
771 /******************************************************************************
772 * This makes sure the display's depth is the same as the
773 * depth of the default 8 bit image. If not, we build a new image
774 * that has the correct depth. This works on the fact that
775 * the color mapper has already changed every pixel value in the
776 * image into the proper number of bits (to fit into the pallet)
777 * so we can just chop down the number of bits.
778 * This changes the global variable 'expImage' if necessary.
781 static int ConvertXImageDepth(Display *display, XImage **image)
783 int screen = DefaultScreen(display);
784 int depth = DefaultDepth(display, screen);
791 printf("ConvertXImageDepth:\n");
792 printf("(*image)->depth == %d\n",
794 printf("DefaultDepth(display, screen) == %d\n",
795 DefaultDepth(display, screen));
800 if ((*image)->depth != depth)
802 XImage *old_image, *new_image;
804 Visual *visual = DefaultVisual(display,screen);
806 int width = (*image)->width;
807 int height = (*image)->height;
808 register int dwx, dwy;
815 printf("ConvertXImageDepth: ---------> CONVERTING...\n");
822 data = (byte *)malloc(width * height * depth);
826 new_image = XCreateImage(display,visual,depth,
827 ZPixmap,0,data,width,height,8,0);
829 new_image = XGetImage(display,RootWindow(display,screen),
830 0,0,width,height,0xffffffff,ZPixmap);
834 return(GIF_NoMemory);
836 if (old_image->depth == 8 && new_image->depth == 4)
838 /* speedup for the most common format change */
840 register byte *sptr = (byte *)old_image->data;
841 register byte *dptr = (byte *)new_image->data;
843 for (dwy=1; dwy<=height; dwy++)
845 for (dwx=1; dwx<width; dwx+=2)
847 *dptr = (*sptr) | (*(sptr+1)<<4);
853 /* if extra pixal at end of line, just move it */
859 else /* other format change than 8 bit -> 4 bit */
861 unsigned long pixel_value;
863 for (dwx=0; dwx<width; dwx++)
865 for (dwy=0; dwy<height; dwy++)
867 pixel_value = XGetPixel(old_image, dwx, dwy);
869 if (pixel_value > 0xff)
870 printf("pixel = %lx", pixel_value);
872 XPutPixel(new_image, dwx, dwy, pixel_value);
877 free(old_image->data);
878 old_image->data = NULL;
879 XDestroyImage(old_image);
888 static unsigned long be2long(unsigned char *be) /* big-endian -> long int */
890 return((be[0]<<24) | (be[1]<<16) | (be[2]<<8) | be[3]);
893 static unsigned short be2short(unsigned char *be) /* big-endian -> short int */
895 return((be[0]<<8) | be[1]);
898 static struct IFF_ILBM_BMHD *ConvertBMHD(unsigned char *header_data)
900 struct IFF_ILBM_BMHD_big_endian *bmhd_be;
901 struct IFF_ILBM_BMHD *bmhd;
903 bmhd_be = (struct IFF_ILBM_BMHD_big_endian *)header_data;
904 bmhd = (struct IFF_ILBM_BMHD *)malloc(sizeof(struct IFF_ILBM_BMHD));
908 bmhd->Width = be2short(bmhd_be->Width);
909 bmhd->Height = be2short(bmhd_be->Height);
910 bmhd->LeftEdge = be2short(bmhd_be->LeftEdge);
911 bmhd->TopEdge = be2short(bmhd_be->TopEdge);
912 bmhd->Depth = (int)bmhd_be->Depth;
913 bmhd->Mask = (int)bmhd_be->Mask;
914 bmhd->Compression = (int)bmhd_be->Compression;
915 bmhd->pad1 = bmhd_be->pad1;
916 bmhd->transparentColor = be2short(bmhd_be->transparentColor);
917 bmhd->xAspect = (int)bmhd_be->xAspect;
918 bmhd->yAspect = (int)bmhd_be->yAspect;
919 bmhd->pageWidth = be2short(bmhd_be->pageWidth);
920 bmhd->pageHeight = be2short(bmhd_be->pageHeight);
925 static unsigned char MSBitFirst2LSBitFirst(unsigned char msb_byte)
927 unsigned char lsb_byte = 0;
932 lsb_byte |= (msb_byte & 1) << i;
939 int Read_ILBM_to_Bitmap(Display *display, char *filename, Pixmap *pixmap)
941 Pixmap new_pixmap = 0;
942 int screen = DefaultScreen(display);
943 Drawable root = RootWindow(display,screen);
944 struct IFF_ILBM_FORM_big_endian *form_header;
945 struct IFF_ILBM_BMHD *bitmap_header;
946 unsigned long file_len, body_len;
947 unsigned char *file_data, *bitmap_data;
948 unsigned char *file_ptr, *bitmap_ptr, *body_ptr;
949 unsigned char byte_count, byte_value;
951 int width, height, depth;
952 int bytes_per_line, bitmap_size;
955 if (!(file = fopen(filename,"r")))
956 return(ILBM_OpenFailed);
958 if (fseek(file,0,SEEK_END) < 0)
961 return(ILBM_ReadFailed);
964 file_len = ftell(file);
967 if (!(file_data = (unsigned char *)malloc(file_len)))
970 return(ILBM_NoMemory);
973 if (fread(file_data,1,file_len,file) != file_len)
977 return(ILBM_ReadFailed);
982 form_header = (struct IFF_ILBM_FORM_big_endian *)file_data;
984 if (strncmp(form_header->magic_FORM,"FORM",4) ||
985 file_len != be2long(form_header->chunk_size)+8 ||
986 strncmp(form_header->magic_ILBM,"ILBM",4))
989 printf("%s: IFF chunk 'FORM' and/or 'ILBM' not found.\n",filename);
992 return(ILBM_FileInvalid);
995 bitmap_header = NULL;
997 file_ptr = file_data + 12;
999 while(file_ptr < (unsigned char *)(file_data + file_len))
1001 if (!strncmp(file_ptr,"BMHD",4))
1004 printf("%s: IFF chunk 'BMHD' found.\n",filename);
1006 bitmap_header = ConvertBMHD(file_ptr + 8);
1007 file_ptr += be2long(file_ptr + 4) + 8;
1010 else if (!strncmp(file_ptr,"BODY",4))
1013 printf("%s: IFF chunk 'BODY' found.\n",filename);
1015 body_ptr = file_ptr + 8;
1016 body_len = be2long(file_ptr + 4);
1017 file_ptr += be2long(file_ptr + 4) + 8;
1023 printf("%s: IFF chunk '%c%c%c%c' found (but not used).\n",filename,
1024 file_ptr[0],file_ptr[1],file_ptr[2],file_ptr[3]);
1026 /* other chunk not recognized here */
1027 file_ptr += be2long(file_ptr + 4) + 8;
1032 if (!bitmap_header || !body_ptr)
1035 printf("%s: IFF chunk 'BMHD' and/or 'BODY' not found.\n",filename);
1038 return(ILBM_FileInvalid);
1041 width = bitmap_header->Width;
1042 height = bitmap_header->Height;
1043 depth = bitmap_header->Depth;
1047 printf("%s: %d bitplanes found; using only the first plane.\n",
1051 bytes_per_line = ((width + 15) / 16) * 2;
1052 bitmap_size = bytes_per_line * height;
1054 bitmap_data = (char *)malloc(bitmap_size);
1058 free(bitmap_header);
1059 return(ILBM_NoMemory);
1062 bitmap_ptr = bitmap_data;
1063 for(i=0;i<bitmap_size;i++)
1066 for(y=0;y<height;y++)
1068 /* we only read the first bitplane here to create a black/white bitmap */
1070 for(z=0;z<depth;z++)
1072 bitmap_ptr = bitmap_data + y * bytes_per_line;
1075 if (!bitmap_header->Compression)
1077 while(x++ < bytes_per_line)
1078 *bitmap_ptr++ |= MSBitFirst2LSBitFirst(*body_ptr++);
1082 while(x < bytes_per_line)
1084 byte_count = *body_ptr++;
1086 if (byte_count <= 128)
1088 for(i=0;i<byte_count+1;i++)
1089 *bitmap_ptr++ |= MSBitFirst2LSBitFirst(*body_ptr++);
1090 x += byte_count + 1;
1094 byte_value = *body_ptr++;
1095 for(i=0;i<257-byte_count;i++)
1096 *bitmap_ptr++ |= MSBitFirst2LSBitFirst(byte_value);
1097 x += 257 - byte_count;
1104 bitmap_ptr = bitmap_data;
1105 for(i=0;i<bitmap_size;i++)
1106 *bitmap_ptr++ ^= 0xff;
1108 new_pixmap = XCreateBitmapFromData(display,root,bitmap_data,width,height);
1112 free(bitmap_header);
1115 return(ILBM_NoMemory);
1117 *pixmap = new_pixmap;
1118 return(ILBM_Success);