@Test
    void testWriteWithPredictor() throws IOException {
        final int[] argb = populateARGB();

        // Test the RGB (no alpha) case
        BufferedImage bImage = new BufferedImage(256, 256, BufferedImage.TYPE_INT_RGB);
        bImage.setRGB(0, 0, 256, 256, argb, 0, 256);

        byte[] tempFile = null;

        final PngImagingParameters params = new PngImagingParameters();
        params.setPredictorEnabled(true);
        final PngImageParser parser = new PngImageParser();
        try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
            parser.writeImage(bImage, bos, params);
            tempFile = bos.toByteArray();
        }

        int[] brgb = new int[256 * 256];
        bImage = ImageIO.read(new ByteArrayInputStream(tempFile));
        bImage.getRGB(0, 0, 256, 256, brgb, 0, 256);
        assertArrayEquals(argb, brgb, "Round trip for RGB failed");

        // Test the ARGB (some semi-transparent alpha) case
        for (int i = 0; i < 256; i++) {
            argb[i * 256 + i] &= 0x88ffffff;
        }
        bImage = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);
        bImage.setRGB(0, 0, 256, 256, argb, 0, 256);
        try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
            parser.writeImage(bImage, bos, params);
            tempFile = bos.toByteArray();
        }
        brgb = new int[256 * 256];
        bImage = ImageIO.read(new ByteArrayInputStream(tempFile));
        bImage.getRGB(0, 0, 256, 256, brgb, 0, 256);
        assertArrayEquals(argb, brgb, "Round trip for ARGB failed");

    }
Populate an integer pixel array for a 256-by-256 image with varied colors across the image area and a white and black line down the main diagonal.

@return a valid array of integers.
src/test/java/org/apache/commons/imaging/formats/png/PngWritePredictorTest.java