public static byte[] decompressT4_1D(final byte[] compressed, final int width, final int height, final boolean hasFill) throws ImagingException {
        final BitInputStreamFlexible inputStream = new BitInputStreamFlexible(new ByteArrayInputStream(compressed));
        try (BitArrayOutputStream outputStream = new BitArrayOutputStream()) {
            for (int y = 0; y < height; y++) {
                int rowLength;
                try {
                    final T4_T6_Tables.Entry entry = CONTROL_CODES.decode(inputStream);
                    if (!isEol(entry, hasFill)) {
                        throw new ImagingException("Expected EOL not found");
                    }
                    int color = WHITE;
                    for (rowLength = 0; rowLength < width;) {
                        final int runLength = readTotalRunLength(inputStream, color);
                        for (int i = 0; i < runLength; i++) {
                            outputStream.writeBit(color);
                        }
                        color = 1 - color;
                        rowLength += runLength;
                    }
                } catch (final ImagingException huffmanException) {
                    throw new ImagingException("Decompression error", huffmanException);
                }

                if (rowLength == width) {
                    outputStream.flush();
                } else if (rowLength > width) {
                    throw new ImagingException("Unrecoverable row length error in image row " + y);
                }
            }
            return outputStream.toByteArray();
        }
    }
Decompresses T.4 1D encoded data. EOL at the beginning and after each row, can be preceded by fill bits to fit on a byte boundary, no RTC.

@param compressed compressed byte data
@param width      image width
@param height     image height
@param hasFill    used to check the end of line
@return the decompressed data
@throws ImagingException if it fails to read the compressed data
src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/T4AndT6Compression.java