protected static Image readMap8(FileInputStream fs,BitmapHeader bh) throws IOException
  {
    Image image;
    // Have to determine the number of colors, the clrsused
    // parameter is dominant if it is greater than zero.  If
    // zero, calculate colors based on bitsperpixel.
    int nNumColors = 0;
    if (bh.nclrused > 0)
    {
      nNumColors = bh.nclrused;
    }
    else
    {
      nNumColors = (1&0xff)<< bh.nbitcount;
    }

    if (bh.nsizeimage == 0)
    {
      bh.nsizeimage = ((((bh.nwidth* bh.nbitcount)+31) & ~31 ) >> 3);
      bh.nsizeimage *= bh.nheight;
    }

    // Read the palatte colors.
    int  npalette[] = new int [nNumColors];
    byte bpalette[] = new byte [nNumColors*4];
    fs.read (bpalette, 0, nNumColors*4);
    int nindex8 = 0;
    for (int n = 0; n < nNumColors; n++)
    {
      npalette[n] = constructInt3(bpalette,nindex8);
      nindex8 += 4;
    }

    // Read the image data (actually indices into the palette)
    // Scan lines are still padded out to even 4-byte
    // boundaries.
    int npad8 = (bh.nsizeimage / bh.nheight) - bh.nwidth;
    //    System.out.println("nPad is:"+npad8);

    int  ndata8[] = new int [bh.nwidth * bh.nheight];
    byte bdata[] = new byte [(bh.nwidth+npad8)* bh.nheight];
    fs.read (bdata, 0, (bh.nwidth+npad8)*bh.nheight);
    nindex8 = 0;
    for (int j8 = 0; j8 < bh.nheight; j8++)
    {
      for (int i8 = 0; i8 < bh.nwidth; i8++)
      {
        ndata8 [bh.nwidth*(bh.nheight-j8-1)+i8] =
        npalette [((int)bdata[nindex8]&0xff)];
        nindex8++;
      }
      nindex8 += npad8;
    }

    image = Toolkit.getDefaultToolkit().createImage
            ( new MemoryImageSource (bh.nwidth, bh.nheight, ndata8, 0, bh.nwidth));

    return(image);
  }