@Test public void testSdeColormapToJavaColorModel() { testSdeColormapToJavaColorModel(8, 256, 3, DataBuffer.TYPE_BYTE); testSdeColormapToJavaColorModel(8, 10, 3, DataBuffer.TYPE_BYTE); testSdeColormapToJavaColorModel(8, 256, 4, DataBuffer.TYPE_BYTE); testSdeColormapToJavaColorModel(8, 10, 4, DataBuffer.TYPE_BYTE); testSdeColormapToJavaColorModel(16, 65536, 3, DataBuffer.TYPE_USHORT); testSdeColormapToJavaColorModel(16, 10, 3, DataBuffer.TYPE_USHORT); testSdeColormapToJavaColorModel(16, 65536, 4, DataBuffer.TYPE_USHORT); testSdeColormapToJavaColorModel(16, 10, 4, DataBuffer.TYPE_USHORT); testSdeColormapToJavaColorModel(16, 530, 3, DataBuffer.TYPE_BYTE); }
public static IndexColorModel sdeColorMapToJavaColorModel(final DataBuffer colorMapData, final int bitsPerSample) { if (colorMapData == null) { throw new NullPointerException("colorMapData"); } if (colorMapData.getNumBanks() < 3 || colorMapData.getNumBanks() > 4) { throw new IllegalArgumentException("colorMapData shall have 3 or 4 banks: " + colorMapData.getNumBanks()); } if (bitsPerSample != 8 && bitsPerSample != 16) { throw new IllegalAccessError("bits per sample shall be either 8 or 16. Got " + bitsPerSample); } final int numBanks = colorMapData.getNumBanks(); final int mapSize = colorMapData.getSize(); byte[] r = new byte[mapSize]; byte[] g = new byte[mapSize]; byte[] b = new byte[mapSize]; byte[] a = new byte[mapSize]; for (int i = 0; i < mapSize; i++) { r[i] = (byte) (colorMapData.getElem(0, i) & 0xFF); g[i] = (byte) (colorMapData.getElem(1, i) & 0xFF); b[i] = (byte) (colorMapData.getElem(2, i) & 0xFF); a[i] = (byte) ((numBanks == 3 ? 255 : colorMapData.getElem(3, i)) & 0xFF); } IndexColorModel colorModel = new IndexColorModel(bitsPerSample, mapSize, r, g, b, a); return colorModel; }
RasterUtils { public static IndexColorModel sdeColorMapToJavaColorModel(final DataBuffer colorMapData, final int bitsPerSample) { if (colorMapData == null) { throw new NullPointerException("colorMapData"); } if (colorMapData.getNumBanks() < 3 || colorMapData.getNumBanks() > 4) { throw new IllegalArgumentException("colorMapData shall have 3 or 4 banks: " + colorMapData.getNumBanks()); } if (bitsPerSample != 8 && bitsPerSample != 16) { throw new IllegalAccessError("bits per sample shall be either 8 or 16. Got " + bitsPerSample); } final int numBanks = colorMapData.getNumBanks(); final int mapSize = colorMapData.getSize(); byte[] r = new byte[mapSize]; byte[] g = new byte[mapSize]; byte[] b = new byte[mapSize]; byte[] a = new byte[mapSize]; for (int i = 0; i < mapSize; i++) { r[i] = (byte) (colorMapData.getElem(0, i) & 0xFF); g[i] = (byte) (colorMapData.getElem(1, i) & 0xFF); b[i] = (byte) (colorMapData.getElem(2, i) & 0xFF); a[i] = (byte) ((numBanks == 3 ? 255 : colorMapData.getElem(3, i)) & 0xFF); } IndexColorModel colorModel = new IndexColorModel(bitsPerSample, mapSize, r, g, b, a); return colorModel; } }
RasterUtils { public static IndexColorModel sdeColorMapToJavaColorModel(final DataBuffer colorMapData, final int bitsPerSample) { if (colorMapData == null) { throw new NullPointerException("colorMapData"); } if (colorMapData.getNumBanks() < 3 || colorMapData.getNumBanks() > 4) { throw new IllegalArgumentException("colorMapData shall have 3 or 4 banks: " + colorMapData.getNumBanks()); } if (bitsPerSample != 8 && bitsPerSample != 16) { throw new IllegalAccessError("bits per sample shall be either 8 or 16. Got " + bitsPerSample); } final int numBanks = colorMapData.getNumBanks(); final int mapSize = colorMapData.getSize(); byte[] r = new byte[mapSize]; byte[] g = new byte[mapSize]; byte[] b = new byte[mapSize]; byte[] a = new byte[mapSize]; for (int i = 0; i < mapSize; i++) { r[i] = (byte) (colorMapData.getElem(0, i) & 0xFF); g[i] = (byte) (colorMapData.getElem(1, i) & 0xFF); b[i] = (byte) (colorMapData.getElem(2, i) & 0xFF); a[i] = (byte) ((numBanks == 3 ? 255 : colorMapData.getElem(3, i)) & 0xFF); } IndexColorModel colorModel = new IndexColorModel(bitsPerSample, mapSize, r, g, b, a); return colorModel; } private  RasterUtils(); }
RasterUtils { public static IndexColorModel sdeColorMapToJavaColorModel(final DataBuffer colorMapData, final int bitsPerSample) { if (colorMapData == null) { throw new NullPointerException("colorMapData"); } if (colorMapData.getNumBanks() < 3 || colorMapData.getNumBanks() > 4) { throw new IllegalArgumentException("colorMapData shall have 3 or 4 banks: " + colorMapData.getNumBanks()); } if (bitsPerSample != 8 && bitsPerSample != 16) { throw new IllegalAccessError("bits per sample shall be either 8 or 16. Got " + bitsPerSample); } final int numBanks = colorMapData.getNumBanks(); final int mapSize = colorMapData.getSize(); byte[] r = new byte[mapSize]; byte[] g = new byte[mapSize]; byte[] b = new byte[mapSize]; byte[] a = new byte[mapSize]; for (int i = 0; i < mapSize; i++) { r[i] = (byte) (colorMapData.getElem(0, i) & 0xFF); g[i] = (byte) (colorMapData.getElem(1, i) & 0xFF); b[i] = (byte) (colorMapData.getElem(2, i) & 0xFF); a[i] = (byte) ((numBanks == 3 ? 255 : colorMapData.getElem(3, i)) & 0xFF); } IndexColorModel colorModel = new IndexColorModel(bitsPerSample, mapSize, r, g, b, a); return colorModel; } private  RasterUtils(); static IndexColorModel sdeColorMapToJavaColorModel(final DataBuffer colorMapData,
            final int bitsPerSample); static ImageTypeSpecifier createFullImageTypeSpecifier(
            final RasterDatasetInfo rasterInfo, final int rasterIndex); static GridEnvelope setMosaicLocations(final RasterDatasetInfo rasterInfo,
            final List<RasterQueryInfo> results); static RasterQueryInfo findLowestResolution(List<RasterQueryInfo> results); static List<RasterQueryInfo> findMatchingRasters(final RasterDatasetInfo rasterInfo,
            final GeneralEnvelope requestedEnvelope, final GridEnvelope requestedDim,
            final OverviewPolicy overviewPolicy); static void fitRequestToRaster(final GeneralEnvelope requestedEnvelope,
            final RasterDatasetInfo rasterInfo, final RasterQueryInfo query); static IndexColorModel ensureNoDataPixelIsAvailable(final IndexColorModel colorMap); static Number determineNoDataValue(IndexColorModel colorMap); static Number determineNoDataValue(final int numBands, final double statsMin,
            final double statsMax, final RasterCellType nativeCellType); static boolean isGeoPhysics(final int numBands, final RasterCellType nativeCellType); static RasterCellType determineTargetCellType(final RasterCellType nativeCellType,
            final List<Number> noDataValues); }
RasterUtils { public static IndexColorModel sdeColorMapToJavaColorModel(final DataBuffer colorMapData, final int bitsPerSample) { if (colorMapData == null) { throw new NullPointerException("colorMapData"); } if (colorMapData.getNumBanks() < 3 || colorMapData.getNumBanks() > 4) { throw new IllegalArgumentException("colorMapData shall have 3 or 4 banks: " + colorMapData.getNumBanks()); } if (bitsPerSample != 8 && bitsPerSample != 16) { throw new IllegalAccessError("bits per sample shall be either 8 or 16. Got " + bitsPerSample); } final int numBanks = colorMapData.getNumBanks(); final int mapSize = colorMapData.getSize(); byte[] r = new byte[mapSize]; byte[] g = new byte[mapSize]; byte[] b = new byte[mapSize]; byte[] a = new byte[mapSize]; for (int i = 0; i < mapSize; i++) { r[i] = (byte) (colorMapData.getElem(0, i) & 0xFF); g[i] = (byte) (colorMapData.getElem(1, i) & 0xFF); b[i] = (byte) (colorMapData.getElem(2, i) & 0xFF); a[i] = (byte) ((numBanks == 3 ? 255 : colorMapData.getElem(3, i)) & 0xFF); } IndexColorModel colorModel = new IndexColorModel(bitsPerSample, mapSize, r, g, b, a); return colorModel; } private  RasterUtils(); static IndexColorModel sdeColorMapToJavaColorModel(final DataBuffer colorMapData,
            final int bitsPerSample); static ImageTypeSpecifier createFullImageTypeSpecifier(
            final RasterDatasetInfo rasterInfo, final int rasterIndex); static GridEnvelope setMosaicLocations(final RasterDatasetInfo rasterInfo,
            final List<RasterQueryInfo> results); static RasterQueryInfo findLowestResolution(List<RasterQueryInfo> results); static List<RasterQueryInfo> findMatchingRasters(final RasterDatasetInfo rasterInfo,
            final GeneralEnvelope requestedEnvelope, final GridEnvelope requestedDim,
            final OverviewPolicy overviewPolicy); static void fitRequestToRaster(final GeneralEnvelope requestedEnvelope,
            final RasterDatasetInfo rasterInfo, final RasterQueryInfo query); static IndexColorModel ensureNoDataPixelIsAvailable(final IndexColorModel colorMap); static Number determineNoDataValue(IndexColorModel colorMap); static Number determineNoDataValue(final int numBands, final double statsMin,
            final double statsMax, final RasterCellType nativeCellType); static boolean isGeoPhysics(final int numBands, final RasterCellType nativeCellType); static RasterCellType determineTargetCellType(final RasterCellType nativeCellType,
            final List<Number> noDataValues);  }