@Test
    void testAll5x2Images() {
        final int[] combinations = new int[10];
        final BufferedImage image = new BufferedImage(5, 2, BufferedImage.TYPE_INT_RGB);
        do {
            for (int x = 0; x < 5; x++) {
                if (combinations[x] == 0) {
                    image.setRGB(x, 0, 0xFFFFFF);
                } else {
                    image.setRGB(x, 0, 0);
                }
            }
            for (int x = 0; x < 5; x++) {
                if (combinations[5 + x] == 0) {
                    image.setRGB(x, 1, 0xFFFFFF);
                } else {
                    image.setRGB(x, 1, 0);
                }
            }

            try {
                final TiffImagingParameters params = new TiffImagingParameters();
                params.setCompression(TiffConstants.COMPRESSION_CCITT_1D);
                final TiffImageParser tiffImageParser = new TiffImageParser();
                final byte[] compressed;
                try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
                    tiffImageParser.writeImage(image, baos, params);
                    compressed = baos.toByteArray();
                }
                final BufferedImage result = Imaging.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (final IOException ex) {
                Debug.debug(ex);
                fail();
            }

            final TiffImageParser tiffImageParser = new TiffImageParser();

            try {
                final TiffImagingParameters params = new TiffImagingParameters();
                params.setCompression(TiffConstants.COMPRESSION_CCITT_GROUP_3);
                params.setT4Options(0);
                final byte[] compressed;
                try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
                    tiffImageParser.writeImage(image, baos, params);
                    compressed = baos.toByteArray();
                }
                final BufferedImage result = Imaging.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (final IOException ex) {
                Debug.debug(ex);
                fail();
            }

            try {
                final TiffImagingParameters params = new TiffImagingParameters();
                params.setCompression(TiffConstants.COMPRESSION_CCITT_GROUP_3);
                params.setT4Options(4);
                final byte[] compressed;
                try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
                    tiffImageParser.writeImage(image, baos, params);
                    compressed = baos.toByteArray();
                }
                final BufferedImage result = Imaging.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (final IOException ex) {
                Debug.debug(ex);
                fail();
            }

            try {
                final TiffImagingParameters params = new TiffImagingParameters();
                params.setCompression(TiffConstants.COMPRESSION_CCITT_GROUP_3);
                params.setT4Options(1);
                final byte[] compressed;
                try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
                    tiffImageParser.writeImage(image, baos, params);
                    compressed = baos.toByteArray();
                }
                final BufferedImage result = Imaging.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (final IOException ex) {
                Debug.debug(ex);
                fail();
            }

            try {
                final TiffImagingParameters params = new TiffImagingParameters();
                params.setCompression(TiffConstants.COMPRESSION_CCITT_GROUP_3);
                params.setT4Options(5);
                final byte[] compressed;
                try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
                    tiffImageParser.writeImage(image, baos, params);
                    compressed = baos.toByteArray();
                }
                final BufferedImage result = Imaging.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (final IOException ex) {
                Debug.debug(ex);
                fail();
            }

            try {
                final TiffImagingParameters params = new TiffImagingParameters();
                params.setCompression(TiffConstants.COMPRESSION_CCITT_GROUP_4);
                final byte[] compressed;
                try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
                    tiffImageParser.writeImage(image, baos, params);
                    compressed = baos.toByteArray();
                }
                final BufferedImage result = Imaging.getBufferedImage(compressed);
                compareImages(image, result);
            } catch (final IOException ex) {
                Debug.debug(ex);
                fail();
            }
        } while (nextCombination(combinations, 1));
    }
Generates the next combination of elements in the sequence array, with each element having a maximum value of max. Initially, the sequence should be set
to minimum values of each element.

@param sequence the array of elements to update
@param max      the maximum value of each element in the sequence
@return false if there is no more combinations (ie. nothing was done), true otherwise
src/test/java/org/apache/commons/imaging/formats/tiff/TiffCcittTest.java