Search code examples
javaimagingjai

Java JAI - Error: One factory fails for the operation "Mosaic"


i'm using Java Advanced Imaging. I already have the tiles and want to put all the tiles together in one PlanarImage. The code below returns the following error message:

Error: One factory fails for the operation "Mosaic" Exception in thread "main" javax.media.jai.util.ImagingException: All factories fail for the operation "Mosaic"

public static void loadTiles() {
    RenderedImage[] source = new RenderedImage[new File("C:\\Users\\user\\workspace\\tiles\\67").listFiles().length-1];

    System.out.println(source.length);

    ImageLayout il = new ImageLayout(0, 0, 3306, 2336);
    RenderingHints rh = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il);
    RenderedOp ro = MosaicDescriptor.create(source, MosaicDescriptor.MOSAIC_TYPE_OVERLAY, null, null, null, null, rh);

    System.out.println(ro.getData());        // <<<< Throws Exception

    PlanarImage pi = ro.createInstance();
    File outputFile = new File("C:\\Users\\dgrimm\\workspace\\tiles\\output");
    System.out.println(outputFile.getAbsolutePath());

    JAI.create("filestore", pi, outputFile.getAbsolutePath(), "png");

}

Can you help me to fix the error ?


Solution

  • You only have declared your array that stores the tiles. You haven't actually loaded the tiles into the array.