private void extractColorMap(DataInputStream is, int numColors)
        throws IOException, AWTException
    {
        int blues[], reds[], greens[];

        // if passed count is zero, then determine the
        // number of entries from bits per pixel.
        if ( numColors == 0 )
        {
            switch ( biBitCount )
            {
            case 1:  numColors =   2; break;
            case 4:  numColors =  16; break;
            case 8:  numColors = 256; break;
            default: numColors =  -1; break;
            }
        }
        if ( numColors == -1)
            throw new AWTException("Invalid bits per pixel: " + biBitCount);
        else
        {
            reds = new int[numColors];
            blues = new int[numColors];
            greens = new int[numColors];
            
            for ( int x = 0; x < numColors; x++ )
            {
                blues[x] = is.readUnsignedByte();
                greens[x] = is.readUnsignedByte();
                reds[x] = is.readUnsignedByte();
                if ( windowsStyle )
                    is.skipBytes(1);
     
                colorTable.add(new BmpColor(reds[x], greens[x], blues[x]));
            }
        }
    }