private ImageDescriptor readImageDescriptor(GIFHeaderInfo ghi,
            int blockCode, InputStream is, boolean stopBeforeImageData,
            FormatCompliance formatCompliance) throws ImageReadException,
            IOException
    {
        int ImageLeftPosition = read2Bytes("Image Left Position", is,
                "Not a Valid GIF File");
        int ImageTopPosition = read2Bytes("Image Top Position", is,
                "Not a Valid GIF File");
        int imageWidth = read2Bytes("Image Width", is, "Not a Valid GIF File");
        int imageHeight = read2Bytes("Image Height", is, "Not a Valid GIF File");
        byte PackedFields = readByte("Packed Fields", is,
                "Not a Valid GIF File");

        if (formatCompliance != null)
        {
            formatCompliance.checkBounds("Width", 1, ghi.logicalScreenWidth,
                    imageWidth);
            formatCompliance.checkBounds("Height", 1, ghi.logicalScreenHeight,
                    imageHeight);
            formatCompliance.checkBounds("Left Position", 0,
                    ghi.logicalScreenWidth - imageWidth, ImageLeftPosition);
            formatCompliance.checkBounds("Top Position", 0,
                    ghi.logicalScreenHeight - imageHeight, ImageTopPosition);
        }

        if (debug)
            printByteBits("PackedFields bits", PackedFields);

        boolean LocalColorTableFlag = (((PackedFields >> 7) & 1) > 0);
        if (debug)
            System.out.println("LocalColorTableFlag: " + LocalColorTableFlag);
        boolean InterlaceFlag = (((PackedFields >> 6) & 1) > 0);
        if (debug)
            System.out.println("Interlace Flag: " + InterlaceFlag);
        boolean SortFlag = (((PackedFields >> 5) & 1) > 0);
        if (debug)
            System.out.println("Sort  Flag: " + SortFlag);

        byte SizeofLocalColorTable = (byte) (PackedFields & 7);
        if (debug)
            System.out.println("SizeofLocalColorTable: "
                    + SizeofLocalColorTable);

        byte LocalColorTable[] = null;
        if (LocalColorTableFlag)
            LocalColorTable = readColorTable(is, SizeofLocalColorTable,
                    formatCompliance);

        byte imageData[] = null;
        if (!stopBeforeImageData)
        {
            int LZWMinimumCodeSize = is.read();

            GenericGIFBlock block = readGenericGIFBlock(is, -1);
            byte bytes[] = block.appendSubBlocks();
            InputStream bais = new ByteArrayInputStream(bytes);

            int size = imageWidth * imageHeight;
            MyLZWDecompressor myLzwDecompressor = new MyLZWDecompressor(
                    LZWMinimumCodeSize, BYTE_ORDER_LSB);
            imageData = myLzwDecompressor.decompress(bais, size);
        } else
        {
            int LZWMinimumCodeSize = is.read();
            if (debug)
                System.out.println("LZWMinimumCodeSize: " + LZWMinimumCodeSize);

            readGenericGIFBlock(is, -1);
        }

        ImageDescriptor result = new ImageDescriptor(blockCode,
                ImageLeftPosition, ImageTopPosition, imageWidth, imageHeight,
                PackedFields, LocalColorTableFlag, InterlaceFlag, SortFlag,
                SizeofLocalColorTable, LocalColorTable, imageData);

        return result;
    }