ImageManager { public RenderedImage createColoredBandImage(RasterDataNode[] rasterDataNodes, ImageInfo imageInfo, int level) { Assert.notNull(rasterDataNodes, "rasterDataNodes"); Assert.state(rasterDataNodes.length == 1 || rasterDataNodes.length == 3 || rasterDataNodes.length == 4, "invalid number of bands"); prepareImageInfos(rasterDataNodes, ProgressMonitor.NULL); if (rasterDataNodes.length == 1) { return createColored1BandImage(rasterDataNodes[0], imageInfo, level); } else { return createColored3BandImage(rasterDataNodes, imageInfo, level); } } ImageManager(); static ImageManager getInstance(); synchronized void dispose(); static MultiLevelModel getMultiLevelModel(RasterDataNode rasterDataNode); static AffineTransform getImageToModelTransform(GeoCoding geoCoding); static CoordinateReferenceSystem getModelCrs(GeoCoding geoCoding); PlanarImage getSourceImage(RasterDataNode rasterDataNode, int level); PlanarImage getValidMaskImage(final RasterDataNode rasterDataNode, int level); PlanarImage getGeophysicalImage(RasterDataNode rasterDataNode, int level); static ImageLayout createSingleBandedImageLayout(RasterDataNode rasterDataNode); static ImageLayout createSingleBandedImageLayout(RasterDataNode rasterDataNode, int dataBufferType); static ImageLayout createSingleBandedImageLayout(int dataBufferType,
                                                            int width,
                                                            int height,
                                                            int tileWidth,
                                                            int tileHeight); static ImageLayout createSingleBandedImageLayout(int dataBufferType,
                                                            int sourceWidth,
                                                            int sourceHeight,
                                                            Dimension tileSize,
                                                            ResolutionLevel level); static ImageLayout createSingleBandedImageLayout(int dataBufferType,
                                                            Point sourcePos,
                                                            int sourceWidth,
                                                            int sourceHeight,
                                                            Dimension tileSize,
                                                            ResolutionLevel level); static int getDataBufferType(int productDataType); static int getProductDataType(int dataBufferType); static Dimension getPreferredTileSize(Product product); RenderedImage createColoredBandImage(RasterDataNode[] rasterDataNodes,
                                                ImageInfo imageInfo,
                                                int level); static MultiLevelModel createMultiLevelModel(ProductNode productNode); RenderedImage getMaskImage(final Product product, final String expression, int level); MultiLevelImage getMaskImage(final String expression, final Product product); void clearMaskImageCache(Product product); ImageInfo getImageInfo(RasterDataNode[] rasters); void prepareImageInfos(RasterDataNode[] rasterDataNodes, ProgressMonitor pm); int getStatisticsLevel(RasterDataNode raster, int levelCount); PlanarImage createColoredMaskImage(Product product, String expression, Color color, boolean invertMask,
                                              int level); static PlanarImage createColoredMaskImage(Color color, RenderedImage alphaImage, boolean invertAlpha); static PlanarImage createColoredMaskImage(RenderedImage maskImage, Color color, double opacity); static PlanarImage createColoredMaskImage(Color color, RenderedImage alphaImage, RenderingHints hints); static MultiLevelImage createMaskedGeophysicalImage(final RasterDataNode node, Number maskValue); static RenderedImage createFormatOp(RenderedImage image, int dataType); static Color[] createColorPalette(ImageInfo imageInfo); static Color computeColor(ImageInfo imageInfo, Double rasterValue); static final ImageCRS DEFAULT_IMAGE_CRS; }
@Test public void testCreateColoredBandImage() throws Exception { int[] pixel00 = new int[3]; int[] pixel10 = new int[3]; int[] pixel01 = new int[3]; int[] pixel11 = new int[3]; Product product = new Product("A", "B", 2, 2); Band band1 = product.addBand("b1", "X + Y"); Band band2 = product.addBand("b2", "X + Y"); Band band3 = product.addBand("b3", "X + Y"); ImageInfo imageInfo = new ImageInfo(new ColorPaletteDef(new ColorPaletteDef.Point[]{ new ColorPaletteDef.Point(1.0, Color.YELLOW), new ColorPaletteDef.Point(2.0, Color.RED), new ColorPaletteDef.Point(3.0, Color.BLUE), })); RenderedImage image; band1.getStx(true, ProgressMonitor.NULL); band1.getImageInfo(ProgressMonitor.NULL); image = ImageManager.getInstance().createColoredBandImage(new RasterDataNode[]{band1}, null, 0); image.getData().getPixel(0, 0, pixel00); image.getData().getPixel(1, 0, pixel10); image.getData().getPixel(0, 1, pixel01); image.getData().getPixel(1, 1, pixel11); assertArrayEquals(new int[]{0, 0, 0}, pixel00); assertArrayEquals(new int[]{0, 0, 0}, pixel10); assertArrayEquals(new int[]{0, 0, 0}, pixel01); assertArrayEquals(new int[]{255, 255, 255}, pixel11); band2.setImageInfo(imageInfo); image = ImageManager.getInstance().createColoredBandImage(new RasterDataNode[]{band2}, null, 0); image.getData().getPixel(0, 0, pixel00); image.getData().getPixel(1, 0, pixel10); image.getData().getPixel(0, 1, pixel01); image.getData().getPixel(1, 1, pixel11); assertArrayEquals(new int[]{255, 255, 0}, pixel00); assertArrayEquals(new int[]{255, 1, 0}, pixel10); assertArrayEquals(new int[]{255, 1, 0}, pixel01); assertArrayEquals(new int[]{0, 0, 255}, pixel11); image = ImageManager.getInstance().createColoredBandImage(new RasterDataNode[]{band3}, imageInfo, 0); image.getData().getPixel(0, 0, pixel00); image.getData().getPixel(1, 0, pixel10); image.getData().getPixel(0, 1, pixel01); image.getData().getPixel(1, 1, pixel11); assertArrayEquals(new int[]{255, 255, 0}, pixel00); assertArrayEquals(new int[]{255, 1, 0}, pixel10); assertArrayEquals(new int[]{255, 1, 0}, pixel01); assertArrayEquals(new int[]{0, 0, 255}, pixel11); }