public Color[] getColors() { return colorPaletteDef != null ? colorPaletteDef.getColors() : new Color[0]; }
/** * Gets the number of color components the image shall have using an instance of this {@code ImageInfo}. * * @return {@code 3} for RGB images, {@code 4} for RGB images with an alpha channel (transparency) */ public int getColorComponentCount() { if (noDataColor.getAlpha() < 255) { return 4; } if (colorPaletteDef != null) { final Color[] colors = colorPaletteDef.getColors(); for (Color color : colors) { if (color.getAlpha() < 255) { return 4; } } } if (rgbChannelDef != null) { if (rgbChannelDef.isAlphaUsed()) { return 4; } } return 3; }
private void testIndexCoding(Band indexBand, final int expectedIndices) { assertTrue(indexBand.isIndexBand()); assertEquals(expectedIndices, indexBand.getIndexCoding().getNumAttributes()); final ColorPaletteDef paletteDef = indexBand.getImageInfo(ProgressMonitor.NULL).getColorPaletteDef(); assertEquals(expectedIndices, paletteDef.getNumColors()); final Color[] colors = paletteDef.getColors(); assertNotSame(0, colors[0].getRed() | colors[0].getGreen() | colors[0].getBlue()); assertNotSame(0, colors[1].getRed() | colors[1].getGreen() | colors[1].getBlue()); assertNotSame(0, colors[2].getRed() | colors[2].getGreen() | colors[2].getBlue()); assertNotSame(0, colors[3].getRed() | colors[3].getGreen() | colors[3].getBlue()); }
ColorPaletteDef colorPaletteDef = imageInfo.getColorPaletteDef(); if (isClassificationBand(rasterDataNode)) { Color[] origPalette = colorPaletteDef.getColors(); palette = Arrays.copyOf(origPalette, origPalette.length + 1); palette[palette.length - 1] = imageInfo.getNoDataColor();
private void applyColorPaletteDef(ColorPaletteDef colorPaletteDef, RasterDataNode targetRaster, ImageInfo targetImageInfo) { if (isIndexCoded(targetRaster)) { targetImageInfo.setColors(colorPaletteDef.getColors()); } else { Stx stx = targetRaster.getStx(false, ProgressMonitor.NULL); Boolean autoDistribute = getAutoDistribute(colorPaletteDef); if (autoDistribute == null) { return; } targetImageInfo.setColorPaletteDef(colorPaletteDef, stx.getMinimum(), stx.getMaximum(), autoDistribute); } }
if (colorPaletteDef != null) { if (band.getIndexCoding() != null) { band.getImageInfo().setColors(colorPaletteDef.getColors()); } else { Stx stx = band.getStx();