ic->image->header.height);
ic->image->header.height, 0, 0);
MKICON_GetImage(char *file){  static int counter = 0;  FILE *fp;  char *file_data;  int size;  struct stat st;  char *s;  XP_Bool wrote_header = FALSE;  il_container *ic;             /* Image container. */  IL_ImageReq *image_req;       /* The image request (client of container.) */  IL_GroupContext *img_cx;      /* Image context. */  IMGCB* img_cb;                /* JMC callback interface to FE. */  JMCException *exc = NULL;  IL_RGBBits rgb;  IL_DisplayData display_data;  URL_Struct *url;  NET_StreamClass *stream;  MWContext cx;  memset (&cx, 0, sizeof(cx));    /* Create a set of FE callbacks for the Image Library. */  img_cb = IMGCBFactory_Create(&exc); /* JMC Module */  if (exc) {      JMC_DELETE_EXCEPTION(&exc);/* XXXM12N Should really return exception */      return;  }  /* Create an Image Group Context.  IL_NewGroupContext augments the     reference count for the JMC callback interface.  The opaque argument     to IL_NewGroupContext is the Front End's display context, which will     be passed back to all the Image Library's FE callbacks. */  img_cx = IL_NewGroupContext((void*)&cx, (IMGCBIF *)img_cb);  /* Attach the IL_GroupContext to the FE's display context. */  cx.img_cx = img_cx;  /* Make a container. */  ic = XP_NEW_ZAP(il_container);  ic->state = IC_START;  ic->hash = 0;  ic->urlhash = 0;  ic->img_cx = img_cx;  ic->forced = 0;  ic->next = 0;  ic->background_color = NULL;  /* Indicates that a mask should be generated                                   if the source image is determined to be                                   transparent. */  /* The container needs to have a NetContext. */  ic->net_cx = IL_NewDummyNetContext(&cx, 0);  /* Allocate the source image header. */  ic->src_header = XP_NEW_ZAP(NI_PixmapHeader);  /* Allocate the source image's colorspace.  The fields will be filled in     by the image decoder. */  ic->src_header->color_space = XP_NEW_ZAP(IL_ColorSpace);  IL_AddRefToColorSpace(ic->src_header->color_space);  /* Hold on to the source image's colormap. */  src_cmap = &ic->src_header->color_space->cmap;  /* Allocate the destination image structure. */  ic->image = XP_NEW_ZAP(IL_Pixmap);  /* Create the destination image's colorspace.     XXXM12N We should really be decoding to the source image's colorspace,     i.e. indexed color for GIF.  However, this requires changes in the Image     Library which have yet to occur as of 11/18/96.  Hence we continue to use     the roundabout approach of decoding to a true colorspace and then     figuring out what the colormap indices are.  This should eventually     change. */  rgb.red_bits = 8;  rgb.green_bits = 8;  rgb.blue_bits = 8;#if defined(IS_LITTLE_ENDIAN)  rgb.red_shift = 24;  rgb.green_shift = 16;  rgb.blue_shift = 8;#elif defined(IS_BIG_ENDIAN)  rgb.red_shift = 0;  rgb.green_shift = 8;  rgb.blue_shift = 16;#else  ERROR!  Endianness unknown.#endif  ic->image->header.color_space = IL_CreateTrueColorSpace(&rgb, 32);  /* The container must have a valid client to be serviced. */  image_req = XP_NEW_ZAP(IL_ImageReq);  image_req->img_cx = img_cx;  XP_NewObserverList(image_req, &image_req->obs_list);  XP_AddObserver(image_req->obs_list, mkicon_ImageObserver, NULL);  ic->clients = image_req;  /* Set the display preferences. */  display_data.color_space = ic->image->header.color_space;  display_data.progressive_display = PR_FALSE;  display_data.dither_mode = IL_ClosestColor;  IL_SetDisplayMode(img_cx, IL_COLOR_SPACE | IL_PROGRESSIVE_DISPLAY |                    IL_DITHER_MODE, &display_data);  /* Create a URL structure. */  url = XP_NEW_ZAP (URL_Struct);  url->address = strdup("\000\000");  url->fe_data = ic;  /* Read in the file data. */  if (stat (file, &st))    return;  size = st.st_size;  file_data = (char *) malloc (size + 1);  if ((fp = fopen (file, "r")) == NULL)	{	  fprintf(stderr, "Unable to open file: %s\n", file);	  abort();	}  fread (file_data, 1, size, fp);  fclose (fp);  /* Start generating code. */  s = strrchr (file, '.');  if (s) *s = 0;  s = strrchr (file, '/');  if (s)    s++;  else    s = file;  if (in_anim && strncmp (s, "Anim", 4)) {    /* once you've started anim frames, don't stop. */    fprintf (stderr, "Incomplete animation\n");    abort ();  }  if ((!strcmp (s, "AnimSm00") || !strcmp (s, "AnimHuge00")) ||      ((!strcmp (s, "AnimSm01") || !strcmp (s, "AnimHuge01")) &&       (!in_anim ||	anim_frames[in_anim-1] > 1)))    {      char *s2;      if (in_anim)	{	  fprintf (stdout, "\"\n }\n};\n\n");	  fprintf (stdout, "#endif /* %s */\n\n", macro);	  if (sgi_p)	    {	      fprintf (stdout, "\n#endif /* __sgi */\n\n");	      sgi_p = FALSE;	    }	}      s2 = s - 2;      while (s2 > file && *s2 != '/')	s2--;      s[-1] = 0;      if (*s2 == '/')	s2++;      if (strstr (s2, "sgi"))	{	  fprintf (stdout, "#ifdef __sgi\n");	  sgi_p = TRUE;	}      fprintf (stdout, "#ifdef %s\n\n", macro);      fprintf (stdout, "struct fe_icon_data anim_%s_%s[] = {\n",	       s2, (!strncmp (s, "AnimHuge", 8) ? "large" : "small"));      wrote_header = TRUE;      in_anim++;    }  if (in_anim)    {      if (strncmp (s, "Anim", 4)) {		fprintf (stderr, "Expected animation frame\n");		abort ();	  }      if (!wrote_header)	fprintf (stdout, "\"\n },\n\n");      fprintf (stdout, "  /* %s */\n  { ", s);      anim_frames[in_anim-1]++;    }  else    {      char *s2 = s;      while (*s2)	{	  if (*s2 == '.') *s2 = '_';	  s2++;	}      fprintf (stdout, "#ifdef %s\n", macro);	  if (iconIsNotUsedInMozLite) fprintf (stdout, "#ifndef MOZ_LITE\n");      fprintf (stdout, "\nstruct fe_icon_data %s = {\n", s);    }  column = 0;  did_size = FALSE;  url->address[0] = counter++;  /* Create a stream and decode the image. */  stream = IL_NewStream (FO_PRESENT,			 (strstr (file, ".gif") ? (void *) IL_GIF :			  strstr (file, ".jpg") ? (void *) IL_JPEG :			  strstr (file, ".jpeg") ? (void *) IL_JPEG :			  strstr (file, ".xbm") ? (void *) IL_XBM :			  (void *) IL_GIF),			 url, &cx);  stream->put_block (stream, file_data, size);  stream->complete (stream);  inactive_icon_p = (strstr(file, ".i.gif") != NULL); /* keep track of this for debugging purposes */  currentIconName = s;  haveSeenTransparentColor = FALSE;  /* Write out the decoded image data. */  IMGCB_DisplayPixmap(img_cx->img_cb, img_cx->dpy_cx, ic->image, ic->mask,                      0, 0, 0, 0, ic->image->header.width,                      ic->image->header.height);  /* Clean up. */  free (file_data);  IMGCB_DestroyPixmap(img_cx->img_cb, img_cx->dpy_cx, ic->image);  if (ic->mask)      IMGCB_DestroyPixmap(img_cx->img_cb, img_cx->dpy_cx, ic->mask);  IL_DestroyGroupContext(img_cx);  IL_ReleaseColorSpace(ic->src_header->color_space);  IL_ReleaseColorSpace(ic->image->header.color_space);  XP_FREE(ic->src_header);  XP_FREE(ic->image);  XP_FREE(ic);  XP_RemoveObserver(image_req->obs_list, mkicon_ImageObserver, NULL);  XP_DisposeObserverList(image_req->obs_list);  XP_FREE(image_req);  XP_FREE(url);  XP_FREE(stream);  src_cmap = NULL;  src_cmap_num_colors = 0;  /* Move on to the next image icon. */  total_images++;}