private int computeColorDepth(int colorcount)
      {
        // color depth = log-base-2 of maximum number of simultaneous colors, i.e.
        // bits per color-index pixel   
        if (colorcount <= 2)
          return 1;   
        if (colorcount <= 4)
          return 2;   
        if (colorcount <= 16)
          return 4;
        return 8;   
      }