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 ***********************************************************/
15 #include "gfxloader.h"
24 struct IFF_ILBM_FORM_big_endian
27 unsigned char chunk_size[4];
31 struct IFF_ILBM_BMHD_big_endian
33 char Width[2], Height[2];
34 char LeftEdge[2], TopEdge[2];
39 char transparentColor[2];
40 char xAspect, yAspect;
41 char pageWidth[2], pageHeight[2];
46 unsigned int Width, Height;
47 int LeftEdge, TopEdge;
50 unsigned int Compression;
52 unsigned int transparentColor;
53 unsigned int xAspect, yAspect;
54 int pageWidth, pageHeight;
57 static int ConvertXImageDepth(Display *, XImage **);
58 static int Read_GIF_to_Pixmap_or_Bitmap(Display *, char *, Pixmap *, int);
60 #define READ_GIF_TO_BITMAP 0
61 #define READ_GIF_TO_PIXMAP 1
64 int Read_GIF_to_Bitmap(Display *display, char *filename, Pixmap *pixmap)
66 return(Read_GIF_to_Pixmap_or_Bitmap(display, filename,
67 pixmap, READ_GIF_TO_BITMAP));
70 int Read_GIF_to_Pixmap(Display *display, char *filename, Pixmap *pixmap)
72 return(Read_GIF_to_Pixmap_or_Bitmap(display, filename,
73 pixmap, READ_GIF_TO_PIXMAP));
76 int Read_GIF_to_Pixmap_or_Bitmap(Display *display, char *filename,
77 Pixmap *pixmap, int mode)
80 Pixmap new_pixmap = 0;
84 return_code = Read_GIF_to_XImage(display, filename, &image);
85 if (return_code != GIF_Success)
90 int screen = DefaultScreen(display);
91 Drawable root = RootWindow(display,screen);
92 int depth = DefaultDepth(display, screen);
93 int width = image->width;
94 int height = image->height;
96 if (mode == READ_GIF_TO_BITMAP)
99 unsigned long black_pixel = BlackPixel(display,screen);
100 int bytes_per_line = (width+7) / 8;
101 int size = bytes_per_line * height;
104 data = (char *)malloc(size);
106 return(GIF_NoMemory);
112 for(y=0;y<height;y++)
116 if (XGetPixel(image,x,y) == black_pixel)
117 data[y * bytes_per_line + x/8] |= (1 << (x%8));
121 new_pixmap = XCreateBitmapFromData(display,root,data,width,height);
125 return(GIF_NoMemory);
132 if (ConvertXImageDepth(display, &image) != GIF_Success)
133 return(GIF_ColorFailed);
135 new_pixmap = XCreatePixmap(display,root,width,height,depth);
138 return(GIF_NoMemory);
140 gcv.foreground = BlackPixel(display,screen);
141 gcv.background = WhitePixel(display,screen);
142 gc = XCreateGC(display, root, GCForeground | GCBackground, &gcv);
143 XPutImage(display,new_pixmap,gc,image,0,0,0,0,width,height);
144 XFreeGC(display, gc);
147 XDestroyImage(image);
150 *pixmap = new_pixmap;
156 * Read_GIF_to_XImage() - based strongly on...
158 * xgifload.c - based strongly on...
160 * gif2ras.c - Converts from a Compuserve GIF (tm) image to a Sun Raster image.
162 * Copyright (c) 1988, 1989 by Patrick J. Naughton
164 * Author: Patrick J. Naughton
165 * naughton@wind.sun.com
167 * Permission to use, copy, modify, and distribute this software and its
168 * documentation for any purpose and without fee is hereby granted,
169 * provided that the above copyright notice appear in all copies and that
170 * both that copyright notice and this permission notice appear in
171 * supporting documentation.
173 * This file is provided AS IS with no warranties of any kind. The author
174 * shall have no liability with respect to the infringement of copyrights,
175 * trade secrets or any patents by this file or any part thereof. In no
176 * event will the author be liable for any lost revenue or profits or
177 * other special, indirect and consequential damages.
182 typedef unsigned char byte;
184 static int ReadCode(void);
185 static void AddToPixel(byte);
186 static int ColorDicking(Display *);
188 #define NEXTBYTE (*ptr++)
189 #define IMAGESEP 0x2c
190 #define INTERLACEMASK 0x40
191 #define COLORMAPMASK 0x80
194 int BitOffset, /* Bit Offset of next code */
195 XC, YC, /* Output X and Y coords of current pixel */
196 Pass, /* Used by output routine if interlaced pic */
197 OutCount, /* Decompressor output 'stack count' */
198 RWidth, RHeight, /* screen dimensions */
199 Width, Height, /* image dimensions */
200 LeftOfs, TopOfs, /* image offset */
201 BitsPerPixel, /* Bits per pixel, read from GIF header */
202 BytesPerScanline, /* bytes per scanline in output raster */
203 ColorMapSize, /* number of colors */
204 Background, /* background color */
205 CodeSize, /* Code size, read from GIF header */
206 InitCodeSize, /* Starting code size, used during Clear */
207 Code, /* Value returned by ReadCode */
208 MaxCode, /* limiting value for current code size */
209 ClearCode, /* GIF clear code */
210 EOFCode, /* GIF end-of-information code */
211 CurCode, OldCode, InCode, /* Decompressor variables */
212 FirstFree, /* First free code, generated per GIF spec */
213 FreeCode, /* Decompressor, next free slot in hash table*/
214 FinChar, /* Decompressor variable */
215 BitMask, /* AND mask for data size */
216 ReadMask; /* Code AND mask for current code size */
218 static boolean Interlace, HasColormap;
220 static byte *ImageData; /* The result array */
221 static byte *RawGIF; /* The heap array to hold it, raw */
222 static byte *Raster; /* The raster data stream, unblocked */
224 /* The color map, read from the GIF header */
225 static byte Red[256], Green[256], Blue[256], used[256];
228 extern char *progname;
231 static unsigned long cols[256];
232 static XColor defs[256];
234 int Read_GIF_to_XImage(Display *display, char *filename, XImage **image)
237 register byte ch, ch1;
238 register byte *ptr, *ptr1;
240 int screen = DefaultScreen(display);
241 Visual *visual = DefaultVisual(display,screen);
242 XImage *new_image = NULL;
245 int Prefix[4096]; /* The hash table used by the decompressor */
247 int OutCode[1025]; /* An output array used by the decompressor */
249 BitOffset = XC = YC = Pass = OutCount = 0;
252 if (strcmp(filename,"-")==0)
255 filename = "<stdin>";
258 file = fopen(filename,"r");
261 return(GIF_OpenFailed);
263 /* find the size of the file */
265 filesize = ftell(file);
268 if (!(ptr = RawGIF = (byte *) malloc(filesize)))
269 return(GIF_NoMemory);
271 if (!(Raster = (byte *) malloc(filesize)))
272 return(GIF_NoMemory);
274 if (fread(ptr, filesize, 1, file) != 1)
275 return(GIF_ReadFailed);
277 if (strncmp(ptr, id, 6))
278 return(GIF_FileInvalid);
282 /* Get variables from the GIF screen descriptor */
285 RWidth = ch + 0x100 * NEXTBYTE; /* screen dimensions... not used. */
287 RHeight = ch + 0x100 * NEXTBYTE;
290 HasColormap = ((ch & COLORMAPMASK) ? True : False);
292 BitsPerPixel = (ch & 7) + 1;
293 numcols = ColorMapSize = 1 << BitsPerPixel;
294 BitMask = ColorMapSize - 1;
296 Background = NEXTBYTE; /* background color... not used. */
298 if (NEXTBYTE) /* supposed to be NULL */
299 return(GIF_FileInvalid);
301 /* Read in global colormap. */
305 for (i = 0; i < ColorMapSize; i++)
316 /* no colormap in GIF file */
317 fprintf(stderr,"%s: warning! no colortable in this file. Winging it.\n",
321 for (i=0; i<numcols; i++)
322 cols[i] = (unsigned long) i;
325 /* Check for image seperator */
327 if (NEXTBYTE != IMAGESEP)
328 return(GIF_FileInvalid);
330 /* Now read in values from the image descriptor */
333 LeftOfs = ch + 0x100 * NEXTBYTE;
335 TopOfs = ch + 0x100 * NEXTBYTE;
337 Width = ch + 0x100 * NEXTBYTE;
339 Height = ch + 0x100 * NEXTBYTE;
340 Interlace = ((NEXTBYTE & INTERLACEMASK) ? True : False);
343 fprintf(stderr, "%s:\n", filename);
344 fprintf(stderr, " %dx%d, %d bpp / %d colors, %sinterlaced\n",
345 Width,Height, BitsPerPixel,ColorMapSize,(Interlace ? "" : "non-"));
346 fprintf(stderr, " Reading file... ");
349 /* Note that I ignore the possible existence of a local color map.
350 * I'm told there aren't many files around that use them, and the spec
351 * says it's defined for future use. This could lead to an error
352 * reading some files.
355 /* Start reading the raster data. First we get the intial code size
356 * and compute decompressor constant values, based on this code size.
360 ClearCode = (1 << CodeSize);
361 EOFCode = ClearCode + 1;
362 FreeCode = FirstFree = ClearCode + 2;
364 /* The GIF spec has it that the code size is the code size used to
365 * compute the above values is the code size given in the file, but the
366 * code size used in compression/decompression is the code size given in
367 * the file plus one. (thus the ++).
371 InitCodeSize = CodeSize;
372 MaxCode = (1 << CodeSize);
373 ReadMask = MaxCode - 1;
375 /* Read the raster data. Here we just transpose it from the GIF array
376 * to the Raster array, turning it from a series of blocks into one long
377 * data stream, which makes life much easier for ReadCode().
384 while (ch--) *ptr1++ = NEXTBYTE;
385 if ((Raster - ptr1) > filesize)
386 return(GIF_FileInvalid);
390 free(RawGIF); /* We're done with the raw data now... */
393 fprintf(stderr, "done\n");
394 fprintf(stderr, " Decompressing... ");
397 /* Allocate the X Image */
398 ImageData = (byte *) malloc(Width*Height);
400 return(GIF_NoMemory);
402 new_image = XCreateImage(display,visual,8,ZPixmap,0,ImageData,
403 Width,Height,8,Width);
405 return(GIF_NoMemory);
407 BytesPerScanline = Width;
410 /* Decompress the file, continuing until you see the GIF EOF code.
411 * One obvious enhancement is to add checking for corrupt files here.
415 while (Code != EOFCode)
417 /* Clear code sets everything back to its initial value, then reads the
418 * immediately subsequent code as uncompressed data.
421 if (Code == ClearCode)
423 CodeSize = InitCodeSize;
424 MaxCode = (1 << CodeSize);
425 ReadMask = MaxCode - 1;
426 FreeCode = FirstFree;
427 CurCode = OldCode = Code = ReadCode();
428 FinChar = CurCode & BitMask;
433 /* If not a clear code, then must be data:
434 * save same as CurCode and InCode
437 CurCode = InCode = Code;
439 /* If greater or equal to FreeCode, not in the hash table yet;
440 * repeat the last character decoded
443 if (CurCode >= FreeCode)
446 OutCode[OutCount++] = FinChar;
449 /* Unless this code is raw data, pursue the chain pointed to by CurCode
450 * through the hash table to its end; each code in the chain puts its
451 * associated output code on the output queue.
454 while (CurCode > BitMask)
457 return(GIF_FileInvalid);
459 OutCode[OutCount++] = Suffix[CurCode];
460 CurCode = Prefix[CurCode];
463 /* The last code in the chain is treated as raw data. */
465 FinChar = CurCode & BitMask;
466 OutCode[OutCount++] = FinChar;
468 /* Now we put the data out to the Output routine.
469 * It's been stacked LIFO, so deal with it that way...
472 for (i = OutCount - 1; i >= 0; i--)
473 AddToPixel(OutCode[i]);
476 /* Build the hash table on-the-fly. No table is stored in the file. */
478 Prefix[FreeCode] = OldCode;
479 Suffix[FreeCode] = FinChar;
482 /* Point to the next slot in the table. If we exceed the current
483 * MaxCode value, increment the code size unless it's already 12. If it
484 * is, do nothing: the next code decompressed better be CLEAR
488 if (FreeCode >= MaxCode)
494 ReadMask = (1 << CodeSize) - 1;
504 fprintf(stderr, "done\n");
505 fprintf(stderr," %d colors used\n",numused);
511 if (ColorDicking(display) != GIF_Success)
512 return(GIF_ColorFailed);
519 /* Fetch the next code from the raster data stream. The codes can be
520 * any length from 3 to 12 bits, packed into 8-bit bytes, so we have to
521 * maintain our location in the Raster array as a BIT Offset. We compute
522 * the byte Offset into the raster array by dividing this by 8, pick up
523 * three bytes, compute the bit Offset into our 24-bit chunk, shift to
524 * bring the desired code to the bottom, then mask it off and return it.
527 static int ReadCode()
529 int RawCode, ByteOffset;
531 ByteOffset = BitOffset / 8;
532 RawCode = Raster[ByteOffset] + (0x100 * Raster[ByteOffset + 1]);
534 RawCode += (0x10000 * Raster[ByteOffset + 2]);
535 RawCode >>= (BitOffset % 8);
536 BitOffset += CodeSize;
537 return(RawCode & ReadMask);
541 static void AddToPixel(byte Index)
544 *(ImageData + YC * BytesPerScanline + XC) = Index;
552 /* Update the X-coordinate, and if it overflows, update the Y-coordinate */
556 /* If a non-interlaced picture, just increment YC to the next scan line.
557 * If it's interlaced, deal with the interlace as described in the GIF
558 * spec. Put the decoded scan line out to the screen if we haven't gone
559 * past the bottom of it
608 static int ColorDicking(Display *display)
610 /* we've got the picture loaded, we know what colors are needed. get 'em */
613 static byte lmasks[8] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80};
615 int screen = DefaultScreen(display);
616 Colormap cmap = DefaultColormap(display,screen);
617 int dispcells = DisplayCells(display,screen);
624 /* no need to allocate any colors if no colormap in GIF file */
626 /* Allocate the X colors for this picture */
630 /* nostrip was set. try REAL hard to do it */
631 for (i=j=0; i<numcols; i++)
635 defs[i].red = Red[i]<<8;
636 defs[i].green = Green[i]<<8;
637 defs[i].blue = Blue[i]<<8;
638 defs[i].flags = DoRed | DoGreen | DoBlue;
639 if (!XAllocColor(display,cmap,&defs[i]))
642 defs[i].pixel = 0xffff;
644 cols[i] = defs[i].pixel;
650 /* failed to pull it off */
655 dc = (dispcells<256) ? dispcells : 256;
658 "failed to allocate %d out of %d colors. Trying extra hard.\n",
661 /* read in the color table */
664 XQueryColors(display,cmap,ctab,dc);
666 /* run through the used colors. any used color that has a pixel
667 value of 0xffff wasn't allocated. for such colors, run through
668 the entire X colormap and pick the closest color */
670 for (i=0; i<numcols; i++)
671 if (used[i] && cols[i]==0xffff)
673 /* an unallocated pixel */
678 mdist = 100000; close = -1;
684 d = abs(r - (ctab[j].red>>8)) +
685 abs(g - (ctab[j].green>>8)) +
686 abs(b - (ctab[j].blue>>8));
695 return(GIF_ColorFailed);
697 bcopy(&defs[close],&defs[i],sizeof(XColor));
698 cols[i] = ctab[close].pixel;
700 } /* end 'failed to pull it off' */
704 /* strip wasn't set, do the best auto-strip */
709 lmask = lmasks[strip];
710 for (i=0; i<numcols; i++)
714 defs[i].red = (Red[i] &lmask)<<8;
715 defs[i].green = (Green[i]&lmask)<<8;
716 defs[i].blue = (Blue[i] &lmask)<<8;
717 defs[i].flags = DoRed | DoGreen | DoBlue;
718 if (!XAllocColor(display,cmap,&defs[i]))
720 cols[i] = defs[i].pixel;
731 XFreeColors(display,cmap,cols+i,1,0L);
739 fprintf(stderr,"%s: stripped %d bits\n",progname,strip);
744 fprintf(stderr,"UTTERLY failed to allocate the desired colors.\n");
745 for (i=0; i<numcols; i++) cols[i]=i;
750 for (i=0; i<Height; i++)
751 for (j=0; j<Width; j++,ptr++)
752 *ptr = (byte) cols[*ptr];
758 /******************************************************************************
759 * This makes sure the display's depth is the same as the
760 * depth of the default 8 bit image. If not, we build a new image
761 * that has the correct depth. This works on the fact that
762 * the color mapper has already changed every pixel value in the
763 * image into the proper number of bits (to fit into the pallet)
764 * so we can just chop down the number of bits.
765 * This changes the global variable 'expImage' if necessary.
768 static int ConvertXImageDepth(Display *display, XImage **image)
770 int screen = DefaultScreen(display);
771 int depth = DefaultDepth(display, screen);
773 if ((*image)->depth != depth)
775 XImage *old_image, *new_image;
776 Visual *visual = DefaultVisual(display,screen);
777 int width = (*image)->width;
778 int height = (*image)->height;
779 register int dwx, dwy;
782 data = (byte *)malloc(width * height);
784 new_image = XCreateImage(display,visual,depth,
785 ZPixmap,0,data,width,height,8,0);
787 return(GIF_NoMemory);
789 if (old_image->depth == 8 && new_image->depth == 4)
791 /* speedup for the most common format change */
793 register byte *sptr = (byte *)old_image->data;
794 register byte *dptr = (byte *)new_image->data;
796 for (dwy=1; dwy<=height; dwy++)
798 for (dwx=1; dwx<width; dwx+=2)
800 *dptr = (*sptr) | (*(sptr+1)<<4);
806 /* if extra pixal at end of line, just move it */
812 else /* other format change than 8 bit -> 4 bit */
814 register unsigned long pixel_value;
816 for (dwx=0; dwx<width; dwx++)
818 for (dwy=0; dwy<height; dwy++)
820 pixel_value = XGetPixel(old_image, dwx, dwy);
821 XPutPixel(new_image, dwx, dwy, pixel_value);
826 free(old_image->data);
827 old_image->data = NULL;
828 XDestroyImage(old_image);
837 static unsigned long be2long(unsigned char *be) /* big-endian -> long int */
839 return((be[0]<<24) | (be[1]<<16) | (be[2]<<8) | be[3]);
842 static unsigned short be2short(unsigned char *be) /* big-endian -> short int */
844 return((be[0]<<8) | be[1]);
847 static struct IFF_ILBM_BMHD *ConvertBMHD(unsigned char *header_data)
849 struct IFF_ILBM_BMHD_big_endian *bmhd_be;
850 struct IFF_ILBM_BMHD *bmhd;
852 bmhd_be = (struct IFF_ILBM_BMHD_big_endian *)header_data;
853 bmhd = (struct IFF_ILBM_BMHD *)malloc(sizeof(struct IFF_ILBM_BMHD));
857 bmhd->Width = be2short(bmhd_be->Width);
858 bmhd->Height = be2short(bmhd_be->Height);
859 bmhd->LeftEdge = be2short(bmhd_be->LeftEdge);
860 bmhd->TopEdge = be2short(bmhd_be->TopEdge);
861 bmhd->Depth = (int)bmhd_be->Depth;
862 bmhd->Mask = (int)bmhd_be->Mask;
863 bmhd->Compression = (int)bmhd_be->Compression;
864 bmhd->pad1 = bmhd_be->pad1;
865 bmhd->transparentColor = be2short(bmhd_be->transparentColor);
866 bmhd->xAspect = (int)bmhd_be->xAspect;
867 bmhd->yAspect = (int)bmhd_be->yAspect;
868 bmhd->pageWidth = be2short(bmhd_be->pageWidth);
869 bmhd->pageHeight = be2short(bmhd_be->pageHeight);
874 static unsigned char MSBitFirst2LSBitFirst(unsigned char msb_byte)
876 unsigned char lsb_byte = 0;
881 lsb_byte |= (msb_byte & 1) << i;
888 int Read_ILBM_to_Bitmap(Display *display, char *filename, Pixmap *pixmap)
890 Pixmap new_pixmap = 0;
891 int screen = DefaultScreen(display);
892 Drawable root = RootWindow(display,screen);
893 struct IFF_ILBM_FORM_big_endian *form_header;
894 struct IFF_ILBM_BMHD *bitmap_header;
895 unsigned long file_len, body_len;
896 unsigned char *file_data, *bitmap_data;
897 unsigned char *file_ptr, *bitmap_ptr, *body_ptr;
898 unsigned char byte_count, byte_value;
900 int width, height, depth;
901 int bytes_per_line, bitmap_size;
904 if (!(file = fopen(filename,"r")))
905 return(ILBM_OpenFailed);
907 if (fseek(file,0,SEEK_END) < 0)
910 return(ILBM_ReadFailed);
913 file_len = ftell(file);
916 if (!(file_data = (unsigned char *)malloc(file_len)))
919 return(ILBM_NoMemory);
922 if (fread(file_data,1,file_len,file) != file_len)
926 return(ILBM_ReadFailed);
931 form_header = (struct IFF_ILBM_FORM_big_endian *)file_data;
933 if (strncmp(form_header->magic_FORM,"FORM",4) ||
934 file_len != be2long(form_header->chunk_size)+8 ||
935 strncmp(form_header->magic_ILBM,"ILBM",4))
938 printf("%s: IFF chunk 'FORM' and/or 'ILBM' not found.\n",filename);
941 return(ILBM_FileInvalid);
944 bitmap_header = NULL;
946 file_ptr = file_data + 12;
948 while(file_ptr < (unsigned char *)(file_data + file_len))
950 if (!strncmp(file_ptr,"BMHD",4))
953 printf("%s: IFF chunk 'BMHD' found.\n",filename);
955 bitmap_header = ConvertBMHD(file_ptr + 8);
956 file_ptr += be2long(file_ptr + 4) + 8;
959 else if (!strncmp(file_ptr,"BODY",4))
962 printf("%s: IFF chunk 'BODY' found.\n",filename);
964 body_ptr = file_ptr + 8;
965 body_len = be2long(file_ptr + 4);
966 file_ptr += be2long(file_ptr + 4) + 8;
972 printf("%s: IFF chunk '%c%c%c%c' found (but not used).\n",filename,
973 file_ptr[0],file_ptr[1],file_ptr[2],file_ptr[3]);
975 /* other chunk not recognized here */
976 file_ptr += be2long(file_ptr + 4) + 8;
981 if (!bitmap_header || !body_ptr)
984 printf("%s: IFF chunk 'BMHD' and/or 'BODY' not found.\n",filename);
987 return(ILBM_FileInvalid);
990 width = bitmap_header->Width;
991 height = bitmap_header->Height;
992 depth = bitmap_header->Depth;
996 printf("%s: %d bitplanes found; using only the first plane.\n",
1000 bytes_per_line = ((width + 15) / 16) * 2;
1001 bitmap_size = bytes_per_line * height;
1003 bitmap_data = (char *)malloc(bitmap_size);
1007 free(bitmap_header);
1008 return(ILBM_NoMemory);
1011 bitmap_ptr = bitmap_data;
1012 for(i=0;i<bitmap_size;i++)
1015 for(y=0;y<height;y++)
1017 /* we only read the first bitplane here to create a black/white bitmap */
1019 for(z=0;z<depth;z++)
1021 bitmap_ptr = bitmap_data + y * bytes_per_line;
1024 if (!bitmap_header->Compression)
1026 while(x++ < bytes_per_line)
1027 *bitmap_ptr++ |= MSBitFirst2LSBitFirst(*body_ptr++);
1031 while(x < bytes_per_line)
1033 byte_count = *body_ptr++;
1035 if (byte_count <= 128)
1037 for(i=0;i<byte_count+1;i++)
1038 *bitmap_ptr++ |= MSBitFirst2LSBitFirst(*body_ptr++);
1039 x += byte_count + 1;
1043 byte_value = *body_ptr++;
1044 for(i=0;i<257-byte_count;i++)
1045 *bitmap_ptr++ |= MSBitFirst2LSBitFirst(byte_value);
1046 x += 257 - byte_count;
1053 bitmap_ptr = bitmap_data;
1054 for(i=0;i<bitmap_size;i++)
1055 *bitmap_ptr++ ^= 0xff;
1057 new_pixmap = XCreateBitmapFromData(display,root,bitmap_data,width,height);
1061 free(bitmap_header);
1064 return(ILBM_NoMemory);
1066 *pixmap = new_pixmap;
1067 return(ILBM_Success);