*** drawing.c.orig	Mon Mar 15 10:11:03 1999
--- drawing.c	Mon Mar 15 10:11:03 1999
***************
*** 2363,2366 ****
--- 2363,2374 ----
        } else if (strcmp(name, "EditPageFileNames()") == 0) {
           EditPageFileNames();
+       } else if (strcmp(name, "ExportHalfToneBitmap()") == 0) {
+          ExportHalfToneBitmap();
+       } else if (strcmp(name, "ExportThresholdBitmap()") == 0) {
+          ExportThresholdBitmap();
+       } else if (strcmp(name, "SetExportBitmapThreshold()") == 0) {
+          if (args != NULL) {
+             SetExportBitmapThreshold(NULL);
+          }
        }
     }
*** edit.c.orig	Mon Mar 15 10:11:05 1999
--- edit.c	Mon Mar 15 10:11:05 1999
***************
*** 3697,3702 ****
     for (sel_ptr=botSel; sel_ptr != NULL; sel_ptr=sel_ptr->prev) {
        obj_ptr = sel_ptr->obj;
!       if (obj_ptr->type != OBJ_ICON || obj_ptr->type != OBJ_PIN ||
!             obj_ptr->locked) {
           continue;
        }
--- 3697,3701 ----
     for (sel_ptr=botSel; sel_ptr != NULL; sel_ptr=sel_ptr->prev) {
        obj_ptr = sel_ptr->obj;
!       if (obj_ptr->type != OBJ_ICON && obj_ptr->type != OBJ_PIN) {
           continue;
        }
*** file.c.orig	Mon Mar 15 10:11:07 1999
--- file.c	Mon Mar 15 10:11:07 1999
***************
*** 622,634 ****
        if ((psz=strstr(file_name, ".obj")) != NULL &&
              strcmp(psz, ".obj") == 0) {
!          if (pn_no_name != NULL) *pn_no_name == (psz == file_name);
           return TRUE;
        } else if ((psz=strstr(file_name, ".tgo")) != NULL &&
              strcmp(psz, ".tgo") == 0) {
!          if (pn_no_name != NULL) *pn_no_name == (psz == file_name);
           return TRUE;
        } else if ((psz=strstr(file_name, stszObjFileExt)) != NULL &&
              strcmp(psz, stszObjFileExt) == 0) {
!          if (pn_no_name != NULL) *pn_no_name == (psz == file_name);
           return TRUE;
        }
--- 622,634 ----
        if ((psz=strstr(file_name, ".obj")) != NULL &&
              strcmp(psz, ".obj") == 0) {
!          if (pn_no_name != NULL) *pn_no_name = (psz == file_name);
           return TRUE;
        } else if ((psz=strstr(file_name, ".tgo")) != NULL &&
              strcmp(psz, ".tgo") == 0) {
!          if (pn_no_name != NULL) *pn_no_name = (psz == file_name);
           return TRUE;
        } else if ((psz=strstr(file_name, stszObjFileExt)) != NULL &&
              strcmp(psz, stszObjFileExt) == 0) {
!          if (pn_no_name != NULL) *pn_no_name = (psz == file_name);
           return TRUE;
        }
***************
*** 637,649 ****
        if ((psz=strstr(file_name, ".sym")) != NULL &&
              strcmp(psz, ".sym") == 0) {
!          if (pn_no_name != NULL) *pn_no_name == (psz == file_name);
           return TRUE;
        } else if ((psz=strstr(file_name, ".tgs")) != NULL &&
              strcmp(psz, ".tgs") == 0) {
!          if (pn_no_name != NULL) *pn_no_name == (psz == file_name);
           return TRUE;
        } else if ((psz=strstr(file_name, stszSymFileExt)) != NULL &&
              strcmp(psz, stszSymFileExt) == 0) {
!          if (pn_no_name != NULL) *pn_no_name == (psz == file_name);
           return TRUE;
        }
--- 637,649 ----
        if ((psz=strstr(file_name, ".sym")) != NULL &&
              strcmp(psz, ".sym") == 0) {
!          if (pn_no_name != NULL) *pn_no_name = (psz == file_name);
           return TRUE;
        } else if ((psz=strstr(file_name, ".tgs")) != NULL &&
              strcmp(psz, ".tgs") == 0) {
!          if (pn_no_name != NULL) *pn_no_name = (psz == file_name);
           return TRUE;
        } else if ((psz=strstr(file_name, stszSymFileExt)) != NULL &&
              strcmp(psz, stszSymFileExt) == 0) {
!          if (pn_no_name != NULL) *pn_no_name = (psz == file_name);
           return TRUE;
        }
***************
*** 652,664 ****
        if ((psz=strstr(file_name, ".pin")) != NULL &&
              strcmp(psz, ".pin") == 0) {
!          if (pn_no_name != NULL) *pn_no_name == (psz == file_name);
           return TRUE;
        } else if ((psz=strstr(file_name, ".tgp")) != NULL &&
              strcmp(psz, ".tgp") == 0) {
!          if (pn_no_name != NULL) *pn_no_name == (psz == file_name);
           return TRUE;
        } else if ((psz=strstr(file_name, stszPinFileExt)) != NULL &&
              strcmp(psz, stszPinFileExt) == 0) {
!          if (pn_no_name != NULL) *pn_no_name == (psz == file_name);
           return TRUE;
        }
--- 652,664 ----
        if ((psz=strstr(file_name, ".pin")) != NULL &&
              strcmp(psz, ".pin") == 0) {
!          if (pn_no_name != NULL) *pn_no_name = (psz == file_name);
           return TRUE;
        } else if ((psz=strstr(file_name, ".tgp")) != NULL &&
              strcmp(psz, ".tgp") == 0) {
!          if (pn_no_name != NULL) *pn_no_name = (psz == file_name);
           return TRUE;
        } else if ((psz=strstr(file_name, stszPinFileExt)) != NULL &&
              strcmp(psz, stszPinFileExt) == 0) {
!          if (pn_no_name != NULL) *pn_no_name = (psz == file_name);
           return TRUE;
        }
***************
*** 665,669 ****
        break;
     }
!    if (pn_no_name != NULL) *pn_no_name == (*file_name == '\0');
  
     return FALSE;
--- 665,669 ----
        break;
     }
!    if (pn_no_name != NULL) *pn_no_name = (*file_name == '\0');
  
     return FALSE;
*** mainloop.c.orig	Mon Mar 15 10:11:10 1999
--- mainloop.c	Mon Mar 15 10:11:10 1999
***************
*** 45,50 ****
  #ifndef _NO_LOCALE_SUPPORT
  #include <X11/Xlocale.h>
- #else /* _NO_LOCALE_SUPPORT */
- #include <locale.h>
  #endif /* ~_NO_LOCALE_SUPPORT */
  
--- 45,48 ----
***************
*** 584,587 ****
--- 582,595 ----
     rootWindow = RootWindow(mainDisplay, mainScreen);
  
+ #ifdef NOT_DEFINED
+    fprintf(stderr,"mainDepth               =%d\n",mainDepth);
+    fprintf(stderr,"mainVisual->class       =%d\n",mainVisual->class);
+    fprintf(stderr,"mainVisual->red_mask    =0x%08lx\n",mainVisual->red_mask);
+    fprintf(stderr,"mainVisual->green_mask  =0x%08lx\n",mainVisual->green_mask);
+    fprintf(stderr,"mainVisual->blue_mask   =0x%08lx\n",mainVisual->blue_mask);
+    fprintf(stderr,"mainVisual->bits_per_rgb=%d\n",mainVisual->bits_per_rgb);
+    fprintf(stderr,"mainVisual->map_entries =%d\n",mainVisual->map_entries);
+ #endif /* NOT_DEFINED */
+ 
     XSetErrorHandler(EmergencySaveForX);
     XSetIOErrorHandler(IOEmergencySaveForX);
*** mainmenu.c.orig	Mon Mar 15 10:11:11 1999
--- mainmenu.c	Mon Mar 15 10:11:11 1999
***************
*** 1012,1015 ****
--- 1012,1016 ----
           gaPopupCoords[MAXMENUS+1].x, gaPopupCoords[MAXMENUS+1].y,
           gaPopupCoords[MAXMENUS+2].x, gaPopupCoords[MAXMENUS+2].y);
+    InitWinSizes();
     for (menu_index=0; menu_index <= MAXMENUS; menu_index++) {
        if (subMenuInfo[menu_index].win != None) {
*** menu.c.orig	Mon Mar 15 10:11:12 1999
--- menu.c	Mon Mar 15 10:11:12 1999
***************
*** 170,176 ****
  {
     int i, x=0, w=0, h=0, len=0, gap=0, padding=(windowPadding>>1);
  
     if (noMenubar ||
!          Y < 0 || Y >= menubarWindowH || X < 0 || X >= menubarWindowW) {
        return INVALID;
     }
--- 170,177 ----
  {
     int i, x=0, w=0, h=0, len=0, gap=0, padding=(windowPadding>>1);
+    int min_x=(menuFontPtr==NULL ? 2 : menuFontWidth);
  
     if (noMenubar ||
!          Y < 0 || Y >= menubarWindowH || X < min_x || X >= menubarWindowW) {
        return INVALID;
     }
*** menuinfo.c.orig	Mon Mar 15 10:11:14 1999
--- menuinfo.c	Mon Mar 15 10:11:14 1999
***************
*** 54,57 ****
--- 54,58 ----
  #include "stream.e"
  #include "text.e"
+ #include "xbitmap.e"
  
  #ifdef _TANGRAM_II
***************
*** 592,595 ****
--- 593,607 ----
       CMDID_BREAKUPBITPIXMAP },
     { TGMUITEM_SEPARATOR, NULL, NULL, NULL, INVALID },
+    { "ExportHalfToneBitmap", NULL,
+      "Use Floyd-Steinberg half-tone method when exporting an X11 bitmap file",
+      NULL, CMDID_EXPORTHALFTONEBITMAP },
+    { "ExportThresholdBitmap", NULL,
+      "Use simple thresholding method when exporting an X11 bitmap file",
+      NULL, CMDID_EXPORTTHRESHOLDBITMAP },
+    { TGMUITEM_SEPARATOR, NULL, NULL, NULL, INVALID },
+    { "SetExportBitmapThreshold...", NULL,
+      "Set bitmap threshold value for the simple thresholding method",
+      NULL, CMDID_SETEXPORTBITMAPTHRESHOLD },
+    { TGMUITEM_SEPARATOR, NULL, NULL, NULL, INVALID },
     { "UpdateEPS", NULL, "Refresh a selected EPS object", NULL,
       CMDID_UPDATEEPS },
***************
*** 597,601 ****
  };
  static TgMenuInfo bitPixmapMenuInfo={ TGMUTYPE_TEXT, bitPixmapMenuItemInfo,
!                                       TgCreateMenuFromMenuInfo };
  
  static TgMenuItemInfo polyMenuItemInfo[] = {
--- 609,613 ----
  };
  static TgMenuInfo bitPixmapMenuInfo={ TGMUTYPE_TEXT, bitPixmapMenuItemInfo,
!                                       CreateBitPixmapMenu };
  
  static TgMenuItemInfo polyMenuItemInfo[] = {
*** miniline.c.orig	Mon Mar 15 10:11:16 1999
--- miniline.c	Mon Mar 15 10:11:16 1999
***************
*** 3407,3411 ****
     case SB_SIMPLE:
        return SingleFontStrSeg(pStrBlock->seg, pnSzUnit, pnDoubleByte, pnFont,
!             pnStyle);
        break;
     case SB_CHAR_SPACE: return TRUE;
--- 3407,3411 ----
     case SB_SIMPLE:
        return SingleFontStrSeg(pStrBlock->seg, pnSzUnit, pnDoubleByte, pnFont,
!             pnStyle, pnUnderlineOn);
        break;
     case SB_CHAR_SPACE: return TRUE;
*** setup.c.orig	Mon Mar 15 10:11:18 1999
--- setup.c	Mon Mar 15 10:11:18 1999
***************
*** 503,506 ****
--- 503,507 ----
        int new_x=slideShowXOffset+x_off;
        int new_y=slideShowYOffset+y_off;
+       int changed=FALSE;
  
        XMoveResizeWindow(mainDisplay, drawWindow,
***************
*** 507,510 ****
--- 508,522 ----
              new_x+draw_win_x_offset, new_y+draw_win_y_offset,
              ZOOMED_SIZE(onePageWidth), ZOOMED_SIZE(onePageHeight));
+       if (ZOOMED_SIZE(onePageWidth) > drawWinW) {
+          drawWinW = ZOOMED_SIZE(onePageWidth);
+          changed = TRUE;
+       }
+       if (ZOOMED_SIZE(onePageHeight) > drawWinH) {
+          drawWinH = ZOOMED_SIZE(onePageHeight);
+          changed = TRUE;
+       }
+       if (changed) {
+          InitWinSizes();
+       }
     }
  }
*** shortcut.c.orig	Mon Mar 15 10:11:20 1999
--- shortcut.c	Mon Mar 15 10:11:20 1999
***************
*** 361,364 ****
--- 361,367 ----
     { '\0', 0, "ChangeAllSelFontUnderline()",0,CMDID_CHANGEALLSELFONTUNDERLINE },
     { '\0', 0, "EditPageFileNames()", 0, CMDID_EDITPAGEFILENAMES },
+    { '\0', 0, "ExportHalfToneBitmap()", 0, CMDID_EXPORTHALFTONEBITMAP },
+    { '\0', 0, "ExportThresholdBitmap()", 0, CMDID_EXPORTTHRESHOLDBITMAP },
+    { '\0', 0, "SetExportBitmapThreshold()", 1, CMDID_SETEXPORTBITMAPTHRESHOLD },
     { '\0', 0, "", 0, 0 }
  };
*** xbitmap.c.orig	Mon Mar 15 10:11:21 1999
--- xbitmap.c	Mon Mar 15 10:11:21 1999
***************
*** 36,39 ****
--- 36,40 ----
  #include "tgifdefs.h"
  #include "expfdefs.h"
+ #include "cmdids.h"
  
  #include "attr.e"
***************
*** 100,104 ****
  static int xpmInXGrabSCFormat=FALSE;
  
! static int halfToneBitmap=FALSE;
  static int thresholdBitmap=FALSE;
  static float bitmapThreshold=0.5;
--- 101,105 ----
  static int xpmInXGrabSCFormat=FALSE;
  
! static int halfToneBitmap=FALSE; /* has precedence over thresholdBitmap */
  static int thresholdBitmap=FALSE;
  static float bitmapThreshold=0.5;
***************
*** 107,110 ****
--- 108,112 ----
  static int unsignedInXBmExport=FALSE;
  static int commentInBitmapExport=FALSE;
+ static int useImagePixelsForTrueColorExport=FALSE;
  
  #define IMF_FORMAT_NCSA 0
***************
*** 296,302 ****
--- 298,413 ----
        commentInBitmapExport = TRUE;
     }
+    useImagePixelsForTrueColorExport = FALSE;
+    if ((c_ptr=XGetDefault(mainDisplay, TOOL_NAME,
+          "UseImagePixelsForTrueColorExport")) != NULL &&
+          UtilStrICmp(c_ptr, "true") == 0) {
+       useImagePixelsForTrueColorExport = TRUE;
+    }
     InitEPS();
  }
  
+ void ExportHalfToneBitmap()
+ {
+    halfToneBitmap = !halfToneBitmap;
+    sprintf(gszMsgBox, "Will %s%s %s.",
+          halfToneBitmap ? "" : "not ", "use Floyd-Steinberg half-tone method",
+          "when exporting an X11 bitmap file");
+    Msg(gszMsgBox);
+ }
+ 
+ void ExportThresholdBitmap()
+ {
+    thresholdBitmap = !thresholdBitmap;
+    if (thresholdBitmap) {
+       sprintf(gszMsgBox, "%s '%s' %s.",
+             "Will use simple thresholding method with a threshold of",
+             bitmapThresholdStr, "when exporting an X11 bitmap file");
+    } else {
+       sprintf(gszMsgBox, "%s %s.",
+             "Will not use simple thresholding method",
+             "when exporting an X11 bitmap file");
+    }
+    Msg(gszMsgBox);
+ }
+ 
+ void SetExportBitmapThreshold(buf)
+    char *buf;
+ {
+    float threshold=(float)0;
+    char spec[MAXSTRING<<1];
+ 
+    *spec = '\0';
+    if (buf != NULL && strcmp(buf, "-1") != 0) {
+       int len=0;
+       UtilStrCpyN(spec, sizeof(spec), buf);
+       UtilTrimBlanks(spec);
+       len = strlen(spec);
+       if (len > 0 && spec[len-1] == ')') spec[len-1] = '\0';
+    } else {
+       sprintf(gszMsgBox, "%s %s (current value is '%s'.",
+             "Please specify bitmap threshold when",
+             "exporting an X11 bitmap file", bitmapThresholdStr);
+       *spec = '\0';
+       if (Dialog(gszMsgBox, NULL, spec) == INVALID) {
+          return;
+       }
+    }
+    UtilTrimBlanks(spec);
+    if (sscanf(spec, "%f", &threshold) != 1) {
+       sprintf(gszMsgBox, "%s: '%s' specified.  Threshold remains at '%s'.",
+             "Invalid threshold", spec, bitmapThresholdStr);
+       MsgBox(gszMsgBox, TOOL_NAME, INFO_MB);
+    } else if (threshold < (float)0 || threshold > (float)1) {
+       sprintf(gszMsgBox, "%s: '%s' specified.  Threshold remains at '%s'.",
+             "Invalid threshold", spec, bitmapThresholdStr);
+       MsgBox(gszMsgBox, TOOL_NAME, INFO_MB);
+    } else {
+       strcpy(bitmapThresholdStr, spec);
+       bitmapThreshold = threshold;
+       sprintf(gszMsgBox, "Will use '%s' %s.",
+             bitmapThresholdStr,
+             "as bitmap threshold when exporting an X11 bitmap file");
+       Msg(gszMsgBox);
+    }
+ }
+ 
+ int RefreshBitPixmapMenu(menu)
+    TgMenu *menu;
+ {
+    int ok=TRUE;
+ 
+    /* ExportHalfToneBitmap */
+    ok &= TgSetMenuItemCheckById(menu, CMDID_EXPORTHALFTONEBITMAP,
+          halfToneBitmap);
+    /* ExportThresholdBitmap */
+    ok &= TgSetMenuItemCheckById(menu, CMDID_EXPORTTHRESHOLDBITMAP,
+          thresholdBitmap);
+ 
+    ok &= TgEnableMenuItemById(menu, CMDID_EXPORTHALFTONEBITMAP,
+          (whereToPrint == XBM_FILE && !colorDump));
+    ok &= TgEnableMenuItemById(menu, CMDID_EXPORTTHRESHOLDBITMAP,
+          (whereToPrint == XBM_FILE && !colorDump));
+    ok &= TgEnableMenuItemById(menu, CMDID_SETEXPORTBITMAPTHRESHOLD,
+          (whereToPrint == XBM_FILE && !colorDump) && thresholdBitmap);
+ 
+    return ok;
+ }
+ 
+ TgMenu *CreateBitPixmapMenu(parent_menu, x, y, menu_info)
+    TgMenu *parent_menu;
+    int x, y;
+    TgMenuInfo *menu_info;
+ {
+    TgMenu *menu=TgCreateMenuFromMenuInfo(parent_menu, x, y, menu_info);
+ 
+    if (menu != NULL) {
+       menu->track_menubar = TRUE;
+       if (!RefreshBitPixmapMenu(menu)) {
+          return TgDestroyMenu(menu, TRUE);
+       }
+    }
+    return menu;
+ }
+ 
  static int transparentIndex=INVALID;
  
***************
*** 1100,1103 ****
--- 1211,1215 ----
  
     case OBJ_TEXT:
+       UpdateColorsLookupTable(ObjPtr->color);
        DoFuncOnStrSegForMiniLines(&ObjPtr->detail.t->minilines,
              BuildStrSegColors, NULL);
***************
*** 1146,1155 ****
  }
  
  static
! void BuildXPmColors()
  {
!    register int i;
!    register struct ObjRec *obj_ptr;
  
     FreeCachedStrings();
     if (colorChar == NULL) {
--- 1258,1428 ----
  }
  
+ typedef struct tagTmpBucketInfo {
+    int pixel;
+    struct tagTmpBucketInfo *next;
+ } TmpBucketInfo;
+ 
+ static int numTmpBuckets=0;
+ static TmpBucketInfo **ppTmpBuckets=NULL;
+ static int tmpRedShift=0, tmpGreenShift=0, tmpBlueShift=0;
+ 
  static
! void CleanUpTmpBuckets()
  {
!    int i=0;
  
+    if (ppTmpBuckets != NULL) {
+       for (i=0; i < numTmpBuckets; i++) {
+          TmpBucketInfo *ptbi=NULL, *ptbi_next=NULL;
+ 
+          for (ptbi=ppTmpBuckets[i]; ptbi != NULL; ptbi=ptbi_next) {
+             ptbi_next = ptbi->next;
+             free(ptbi);
+          }
+       }
+       free(ppTmpBuckets);
+    }
+    tmpRedShift = tmpGreenShift = tmpBlueShift = 0;
+    numTmpBuckets = 0;
+    ppTmpBuckets = NULL;
+ }
+ 
+ static
+ int SetTmpShift(mask, pn_shifts)
+    unsigned long mask;
+    int *pn_shifts;
+ {
+    int i=0;
+ 
+    if (mask == 0L) return FALSE;
+ 
+    while ((mask & 0x1) == 0) {
+       i++;
+       mask >>= 1;
+    }
+    *pn_shifts = i;
+ 
+    return TRUE;
+ }
+ 
+ static
+ int BadMask(mask_str, mask)
+    char *mask_str;
+    unsigned long mask;
+ {
+    sprintf(gszMsgBox, "%s %s %s 0x%06lx.  %s %s.%s %s.",
+          "Unexpected", mask_str, "value of", (long)mask,
+          "Please set", TOOL_NAME, "UseImagePixelsForTrueColorExport",
+          "to FALSE for this visual");
+    if (PRTGIF) {
+       fprintf(stderr, "%s\n", gszMsgBox);
+    } else {
+       MsgBox(gszMsgBox, TOOL_NAME, INFO_MB);
+    }
+    CleanUpTmpBuckets();
+ 
+    return FALSE;
+ }
+ 
+ static
+ int InitTmpBuckets()
+ {
+    if ((maxColors & 0x0ff) == 0) {
+       numTmpBuckets = maxColors+3;
+    } else {
+       numTmpBuckets = (((maxColors>>8)+1)<<8)+3;
+    }
+    ppTmpBuckets = (TmpBucketInfo**)malloc(numTmpBuckets*sizeof(TmpBucketInfo*));
+    if (ppTmpBuckets == NULL) FailAllocMessage();
+    memset(ppTmpBuckets, 0, numTmpBuckets*sizeof(TmpBucketInfo*));
+ 
+    if (!SetTmpShift(mainVisual->red_mask, &tmpRedShift)) {
+       return BadMask("red_mask", mainVisual->red_mask);
+    }
+    if (!SetTmpShift(mainVisual->green_mask, &tmpGreenShift)) {
+       return BadMask("green_mask", mainVisual->green_mask);
+    }
+    if (!SetTmpShift(mainVisual->blue_mask, &tmpBlueShift)) {
+       return BadMask("blue_mask", mainVisual->blue_mask);
+    }
+    return TRUE;
+ }
+ 
+ static
+ int TmpPixelHash(pixel)
+    int pixel;
+ {
+    return (((pixel)==(-1)) ? (numTmpBuckets-1) : (pixel % numTmpBuckets));
+ }
+ 
+ static
+ void GetTmpValue(pixel, mask, shift, pn_value)
+    int pixel, shift, *pn_value;
+    unsigned long mask;
+ {
+    double d_val=(double)0;
+    int value=0;
+ 
+    pixel = (int)(pixel & mask);
+    pixel >>= shift;
+    mask >>= shift;
+    d_val = ((double)pixel) / ((double)mask) * ((double)0x0ff);
+    value = round(d_val);
+    if (value > 0x0ff) value = 0x0ff;
+    if (value < 0) value = 0;
+    *pn_value = value;
+ }
+ 
+ static
+ void GetTmpColorStr(pixel, color_str)
+    int pixel;
+    char *color_str;
+ {
+    int red_value=0, green_value=0, blue_value=0;
+ 
+    GetTmpValue(pixel, mainVisual->red_mask, tmpRedShift, &red_value);
+    GetTmpValue(pixel, mainVisual->green_mask, tmpGreenShift, &green_value);
+    GetTmpValue(pixel, mainVisual->blue_mask, tmpBlueShift, &blue_value);
+    sprintf(color_str, "#%c%c%c%c%c%c",
+          hexValue[(red_value>>4)&0x0f], hexValue[red_value&0x0f],
+          hexValue[(green_value>>4)&0x0f], hexValue[green_value&0x0f],
+          hexValue[(blue_value>>4)&0x0f], hexValue[blue_value&0x0f]);
+ }
+ 
+ static
+ void UpdateColorsLookupTableForPixel(pixel)
+    int pixel;
+ {
+    char color_str[COLORSTRLEN];
+    int bucket=TmpPixelHash(pixel);
+    TmpBucketInfo *ptbi=NULL;
+    
+    for (ptbi=ppTmpBuckets[bucket]; ptbi != NULL; ptbi=ptbi->next) {
+       if (ptbi->pixel == pixel) {
+          return;
+       }
+    }
+    ptbi = (TmpBucketInfo*)malloc(sizeof(TmpBucketInfo));
+    if (ptbi == NULL) FailAllocMessage();
+    memset(ptbi, 0, sizeof(TmpBucketInfo));
+    ptbi->next = ppTmpBuckets[bucket];
+    ppTmpBuckets[bucket] = ptbi;
+    ptbi->pixel = pixel;
+ 
+    UtilFree(colorStr[numColorsToDump]);
+    pixelValue[numColorsToDump] = pixel;
+    *color_str = '\0';
+    GetTmpColorStr(pixel, color_str);
+    colorStr[numColorsToDump] = UtilStrDup(color_str);
+    numColorsToDump++;
+ }
+ 
+ static
+ void BuildXPmColors(image, w, h, left, top, right, bottom)
+    XImage *image;
+    int w, h, left, top, right, bottom;
+ {
+    int i;
+ 
     FreeCachedStrings();
     if (colorChar == NULL) {
***************
*** 1186,1191 ****
     numColorsToDump = 1;
  
!    for (obj_ptr=botObj; obj_ptr != NULL; obj_ptr=obj_ptr->prev) {
!       BuildObjXPmColors(obj_ptr);
     }
     colorChar[0] = '`';
--- 1459,1481 ----
     numColorsToDump = 1;
  
!    if (mainVisual->class == TrueColor && useImagePixelsForTrueColorExport &&
!          InitTmpBuckets()) {
!       SetStringStatus("Building color table from pixels...");
!       for (i=top; i < h-bottom; i++) {
!          int j=0;
! 
!          for (j=left; j < w-right; j++) {
!             int pixel=XGetPixel(image,j-left,i-top);
! 
!             UpdateColorsLookupTableForPixel(pixel);
!          }
!       }
!       CleanUpTmpBuckets();
!    } else {
!       struct ObjRec *obj_ptr=NULL;
! 
!       for (obj_ptr=botObj; obj_ptr != NULL; obj_ptr=obj_ptr->prev) {
!          BuildObjXPmColors(obj_ptr);
!       }
     }
     colorChar[0] = '`';
***************
*** 2036,2039 ****
--- 2326,2404 ----
  }
  
+ static
+ void DebugXPmColors()
+ {
+    int i=0;
+ 
+    fprintf(stderr, "\nnumColorsToDump = %1d\n", numColorsToDump);
+    fprintf(stderr, "maxColors = %1d\n", maxColors);
+    fprintf(stderr, "\nThe following indices ranges from 0 to maxColors-1:\n");
+    for (i=0; i < maxColors; i++) {
+       if (mainVisual->class == TrueColor) {
+          fprintf(stderr, "%s[%3d]=%3d, %s[%3d]=0x%06lx\n",
+                "colorIndexToDumpIndex", i, colorIndexToDumpIndex[i],
+                "colorPixels", i, (long)colorPixels[i]);
+       } else {
+          fprintf(stderr, "%s[%3d]=%3d, %s[%3d]=%3d\n",
+                "colorIndexToDumpIndex", i, colorIndexToDumpIndex[i],
+                "colorPixels", i, colorPixels[i]);
+       }
+    }
+    fprintf(stderr, "\n%s 0 to numColorsToDump-1:\n",
+          "The following indices ranges from");
+    for (i=0; i < numColorsToDump; i++) {
+       int j=0;
+ 
+       if (mainVisual->class == TrueColor) {
+          fprintf(stderr, "%s[%3d]=0x%06lx, %s[%3d]=",
+                "pixelValue", i, (long)pixelValue[i], "colorChar", i);
+       } else {
+          fprintf(stderr, "%s[%3d]=%3d, %s[%3d]=",
+                "pixelValue", i, pixelValue[i], "colorChar", i);
+       }
+       for (j = 0; j < charsPerPixel; j++) {
+          fprintf(stderr, "%c", colorChar[i*charsPerPixel+j]);
+       }
+       fprintf(stderr, ", %s[%3d]=%s\n", "colorStr", i, colorStr[i]);
+    }
+ }
+ 
+ static
+ void DebugXPmColorsAndExportImage(image, w, h, left, top, right, bottom)
+    XImage *image;
+    int w, h, left, top, right, bottom;
+ {
+    int i=0;
+ 
+    DebugXPmColors();
+ 
+    fprintf(stderr, "\nHere is the image:\n");
+    fprintf(stderr, "    (%s\n    %s\n    %s)\n",
+          "recall that if colorIndexToDumpIndex[color_index] = index",
+          "then pixelValue[index] == pixel, where pixel is a value seen below",
+          "and color_index indexes colorPixels and colorMenuItems");
+    for (i=top; i < h-bottom; i++) {
+       int j=0;
+ 
+       for (j=left; j < w-right; j++) {
+          int data=XGetPixel(image,j-left,i-top);
+ 
+          if (j+1 == w-right) {
+             if (mainVisual->class == TrueColor) {
+                fprintf(stderr, "%06lx\n", (long)data);
+             } else {
+                fprintf(stderr, "%3d\n", data);
+             }
+          } else {
+             if (mainVisual->class == TrueColor) {
+                fprintf(stderr, "%06lx ", (long)data);
+             } else {
+                fprintf(stderr, "%3d ", data);
+             }
+          }
+       }
+    }
+ }
+ 
  #define FS_SCALE 0x400
  #define HALF_FS_SCALE 0x200
***************
*** 2196,2200 ****
           }
        }
!       BuildXPmColors();
        if (xpmOutputVersion == 1) {
           DumpCommentInBitmapExport(fp);
--- 2561,2566 ----
           }
        }
!       BuildXPmColors(image, w, h, left, top, right, bottom);
! 
        if (xpmOutputVersion == 1) {
           DumpCommentInBitmapExport(fp);
***************
*** 2237,2240 ****
--- 2603,2609 ----
     if (colorDump && nInImageProc && gnConvolving) {
     } else if (colorDump) {
+ #ifdef NOT_DEFINED
+       DebugXPmColorsAndExportImage(image, w, h, left, top, right, bottom);
+ #endif /* NOT_DEFINED */
        BuildXPmBuckets(numColorsToDump, pixelValue, INVALID, NULL);
        target_percent = 5;
*** xbitmap.e.orig	Mon Mar 15 10:11:23 1999
--- xbitmap.e	Mon Mar 15 10:11:23 1999
***************
*** 54,57 ****
--- 54,63 ----
  extern void	SetXpmOutputVersion ARGS_DECL((int));
  extern void	InitXBm ARGS_DECL((void));
+ extern void	ExportHalfToneBitmap ARGS_DECL((void));
+ extern void	ExportThresholdBitmap ARGS_DECL((void));
+ extern void	SetExportBitmapThreshold ARGS_DECL((char*));
+ extern int	RefreshBitPixmapMenu ARGS_DECL((TgMenu*));
+ extern TgMenu	*CreateBitPixmapMenu ARGS_DECL((TgMenu*, int X, int Y,
+                                                 TgMenuInfo*));
  extern void	CleanUpXBm ARGS_DECL((void));
  extern void	CalcTransform ARGS_DECL((struct MtrxRec *));
*** cmdids.h.orig	Mon Mar 15 10:11:24 1999
--- cmdids.h	Mon Mar 15 10:11:24 1999
***************
*** 356,361 ****
  #define CMDID_CHANGEALLSELFONTUNDERLINE    403
  #define CMDID_EDITPAGEFILENAMES            404
  
! #define MAXCMDIDS 405
  
  #endif /*_CMDIDS_H_*/
--- 356,364 ----
  #define CMDID_CHANGEALLSELFONTUNDERLINE    403
  #define CMDID_EDITPAGEFILENAMES            404
+ #define CMDID_EXPORTHALFTONEBITMAP         405
+ #define CMDID_EXPORTTHRESHOLDBITMAP        406
+ #define CMDID_SETEXPORTBITMAPTHRESHOLD     407
  
! #define MAXCMDIDS 408
  
  #endif /*_CMDIDS_H_*/
*** patchlvl.h.orig	Mon Mar 15 10:11:25 1999
--- patchlvl.h	Mon Mar 15 10:11:25 1999
***************
*** 35,39 ****
  #define _TGIF_PATCHLEVEL_H_
  
! #define TGIF_PATCHLEVEL 1
  
  #endif /*_TGIF_PATCHLEVEL_H_*/
--- 35,39 ----
  #define _TGIF_PATCHLEVEL_H_
  
! #define TGIF_PATCHLEVEL 2
  
  #endif /*_TGIF_PATCHLEVEL_H_*/
*** Imakefile.orig	Mon Mar 15 10:11:26 1999
--- Imakefile	Mon Mar 15 10:11:26 1999
***************
*** 53,57 ****
                    $(MOREDEFINES)
  
! TGIFVERSION	= 4.1.1
  
  XCOMM Things to try to add to the DEFINES line above:
--- 53,57 ----
                    $(MOREDEFINES)
  
! TGIFVERSION	= 4.1.2
  
  XCOMM Things to try to add to the DEFINES line above:
*** tgif.man.orig	Mon Mar 15 10:11:27 1999
--- tgif.man	Mon Mar 15 10:11:28 1999
***************
*** 9,13 ****
  .\"
  .\"
! .TH tgif n "Version 4.0 Patchlevel 15 and Above" "Tgif"
  .\"
  .SH NAME
--- 9,13 ----
  .\"
  .\"
! .TH tgif n "Version 4.1 Patchlevel 2 and Above" "Tgif"
  .\"
  .SH NAME
***************
*** 4057,4060 ****
--- 4057,4065 ----
  This specifies the color to be used for the background of objects.
  By default, the default background color is used.
+ .TP
+ .I Tgif.UseImagePixelsForTrueColorExport: [true,false]
+ If set to ``true'', the color table of an exported XPM/GIF file
+ will be obtained from the actual image pixels for a TrueColor visual.
+ The default is false.
  .\"
  .SH ENVIRONMENT VARIABLE
*** HISTORY.orig	Mon Mar 15 10:11:30 1999
--- HISTORY	Mon Mar 15 10:11:30 1999
***************
*** 1,2 ****
--- 1,25 ----
+ -----------------------> tgif-4.1.1 => tgif-4.1.2 <-----------------------
+ Here's a short list of added features/bug fixes.
+ 
+ 1)  Fix another bug with the File Menu flashing.  Thanks to Andrew Sapuntzakis
+     <andrewsa@cc701.comm.mot.com> for pointing out the problem.
+ 2)  Fix a bug with CopyProperties().  Thanks to Kouya SHIMURA
+     <kouya@flab.fujitsu.co.jp> for the patch.
+ 3)  Fix bugs when no file name and only a file extension is specified as
+     an input file name.  Thanks to Holger Huesing <H.Huesing@tu-bs.de>
+     for the patch.
+ 4)  Fix a locale bug.  Should not #include <local.h> if _NO_LOCALE_SUPPORT
+     is defined.  Thanks to Ralphe Neill <ran@oberon.sub.net.au> for
+     pointing out the problem.
+ 5)  Fix a problem with exporting XPM/GIF files under certain TrueColor visuals
+     of Hummingbird's eXceed server.  The fix is to compute the color table
+     for the exported XPM/GIF file from the pixels in the actual image for
+     TrueColor visuals if the new X default,
+     Tgif.UseImagePixelsForTrueColorExport, is set to true.  Thanks to
+     Jurgen Rusch <rusch@natlab.research.philips.com> for pointing out
+     the problem.
+ 6)  Fix a bug with UpdateSymbols().  Thanks to sven wilhelmsson
+     <sven.wilhelmsson@swipnet.se> for the patch.
+ 
  -----------------------> tgif-4.1 => tgif-4.1.1 <-----------------------
  Here's a short list of added features/bug fixes.
*** tgif.Xdefaults.orig	Mon Mar 15 10:11:31 1999
--- tgif.Xdefaults	Mon Mar 15 10:11:31 1999
***************
*** 398,399 ****
--- 398,400 ----
  Tgif.DarkGrayColor:		gray50
  !Tgif.DefaultObjectBackground:	white
+ Tgif.UseImagePixelsForTrueColorExport:	false
*** make.comdep.orig	Mon Mar 15 10:11:32 1999
--- make.comdep	Mon Mar 15 10:11:32 1999
***************
*** 185,189 ****
  		color.e edit.e file.e font.e grid.e help.e menu.e menuinfo.e \
  		navigate.e page.e pattern.e raster.e scroll.e shape.e \
! 		stream.e text.e 
  miniline$(O) :	tgifdefs.h const.h tgif_dbg.h types.h auxtext.e choice.e \
  		color.e dialog.e drawing.e dup.e file.e font.e inmethod.e \
--- 185,189 ----
  		color.e edit.e file.e font.e grid.e help.e menu.e menuinfo.e \
  		navigate.e page.e pattern.e raster.e scroll.e shape.e \
! 		stream.e text.e xbitmap.e 
  miniline$(O) :	tgifdefs.h const.h tgif_dbg.h types.h auxtext.e choice.e \
  		color.e dialog.e drawing.e dup.e file.e font.e inmethod.e \
***************
*** 398,407 ****
  wb2$(O) :	tgifdefs.h const.h tgif_dbg.h types.h 
  wb3$(O) :	tgifdefs.h const.h tgif_dbg.h types.h 
! xbitmap$(O) :	tgifdefs.h const.h tgif_dbg.h types.h expfdefs.h attr.e \
! 		auxtext.e choice.e cmd.e color.e cursor.e cutpaste.e dialog.e \
! 		drawing.e dup.e eps.e file.e font.e grid.e imgproc.e mark.e \
! 		menu.e miniline.e move.e msg.e names.e obj.e page.e pattern.e \
! 		ps.e raster.e rect.e remote.e select.e setup.e stretch.e \
! 		util.e version.e xbitmap.e xpixmap.e xprtfltr.e 
  xpixmap$(O) :	tgifdefs.h const.h tgif_dbg.h types.h attr.e choice.e cmd.e \
  		color.e cursor.e cutpaste.e dialog.e drawing.e dup.e file.e \
--- 398,407 ----
  wb2$(O) :	tgifdefs.h const.h tgif_dbg.h types.h 
  wb3$(O) :	tgifdefs.h const.h tgif_dbg.h types.h 
! xbitmap$(O) :	tgifdefs.h const.h tgif_dbg.h types.h expfdefs.h cmdids.h \
! 		attr.e auxtext.e choice.e cmd.e color.e cursor.e cutpaste.e \
! 		dialog.e drawing.e dup.e eps.e file.e font.e grid.e imgproc.e \
! 		mark.e menu.e miniline.e move.e msg.e names.e obj.e page.e \
! 		pattern.e ps.e raster.e rect.e remote.e select.e setup.e \
! 		stretch.e util.e version.e xbitmap.e xpixmap.e xprtfltr.e 
  xpixmap$(O) :	tgifdefs.h const.h tgif_dbg.h types.h attr.e choice.e cmd.e \
  		color.e cursor.e cutpaste.e dialog.e drawing.e dup.e file.e \
*** Tgif.tmpl-hpux.orig	Mon Mar 15 10:11:33 1999
--- Tgif.tmpl-hpux	Mon Mar 15 10:11:33 1999
***************
*** 72,74 ****
--- 72,75 ----
  XCOMM This file has been tested under (uname -s -r -m):	XCOMM
  XCOMM		HP-UX A.09.07 9000/735			XCOMM
+ XCOMM		HP-UX B.10.20 9000/735			XCOMM
  XCOMM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^	XCOMM
*** Tgif.tmpl-irix.orig	Mon Mar 15 10:11:34 1999
--- Tgif.tmpl-irix	Mon Mar 15 10:11:34 1999
***************
*** 75,77 ****
--- 75,78 ----
  XCOMM This file has been tested under (uname -s -r):	XCOMM
  XCOMM		IRIX 5.3				XCOMM
+ XCOMM		IRIX 6.2				XCOMM
  XCOMM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^	XCOMM
*** Tgif.tmpl-solaris.orig	Mon Mar 15 10:11:35 1999
--- Tgif.tmpl-solaris	Mon Mar 15 10:11:35 1999
***************
*** 78,80 ****
--- 78,81 ----
  XCOMM This file has been tested under (uname -s -r):	XCOMM
  XCOMM		SunOS 5.5				XCOMM
+ XCOMM		SunOS 5.6				XCOMM
  XCOMM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^	XCOMM
