List of usage examples for java.awt.image DataBuffer TYPE_INT
int TYPE_INT
To view the source code for java.awt.image DataBuffer TYPE_INT.
Click Source Link
From source file:org.mrgeo.image.MrsImagePyramidMetadata.java
public static int toBytes(final int tiletype) { switch (tiletype) { case DataBuffer.TYPE_BYTE: { return 1; }/*w w w . j av a 2s . c o m*/ case DataBuffer.TYPE_FLOAT: { return RasterUtils.FLOAT_BYTES; } case DataBuffer.TYPE_DOUBLE: { return RasterUtils.DOUBLE_BYTES; } case DataBuffer.TYPE_INT: { return RasterUtils.INT_BYTES; } case DataBuffer.TYPE_SHORT: { return RasterUtils.SHORT_BYTES; } case DataBuffer.TYPE_USHORT: { return RasterUtils.USHORT_BYTES; } } return 0; }
From source file:org.mrgeo.image.MrsImagePyramidMetadata.java
public static int toTileType(final String tiletype) { if (tiletype == "Byte") { return DataBuffer.TYPE_BYTE; }/*w w w. j a v a2 s . c o m*/ if (tiletype == "Float") { return DataBuffer.TYPE_FLOAT; } if (tiletype == "Double") { return DataBuffer.TYPE_DOUBLE; } if (tiletype == "Int") { return DataBuffer.TYPE_INT; } if (tiletype == "Short") { return DataBuffer.TYPE_SHORT; } if (tiletype == "UShort") { return DataBuffer.TYPE_USHORT; } return DataBuffer.TYPE_UNDEFINED; }
From source file:org.mrgeo.image.MrsImagePyramidMetadata.java
public static String toTileTypeText(final int tiletype) { switch (tiletype) { case DataBuffer.TYPE_BYTE: { return "Byte"; }/*from www.jav a 2s. co m*/ case DataBuffer.TYPE_FLOAT: { return "Float"; } case DataBuffer.TYPE_DOUBLE: { return "Double"; } case DataBuffer.TYPE_INT: { return "Int"; } case DataBuffer.TYPE_SHORT: { return "Short"; } case DataBuffer.TYPE_USHORT: { return "UShort"; } } return "Undefined"; }
From source file:org.mrgeo.image.MrsPyramidMetadata.java
public static int toTileType(final String tiletype) { if (tiletype.equals("Byte")) { return DataBuffer.TYPE_BYTE; }//from www. j av a 2 s . com if (tiletype.equals("Float")) { return DataBuffer.TYPE_FLOAT; } if (tiletype.equals("Double")) { return DataBuffer.TYPE_DOUBLE; } if (tiletype.equals("Int")) { return DataBuffer.TYPE_INT; } if (tiletype.equals("Short")) { return DataBuffer.TYPE_SHORT; } if (tiletype.equals("UShort")) { return DataBuffer.TYPE_USHORT; } return DataBuffer.TYPE_UNDEFINED; }
From source file:org.mrgeo.rasterops.GeoTiffExporter.java
public static void export(final RenderedImage image, final Bounds bounds, final OutputStream os, final boolean replaceNan, final String xmp, final Number nodata) throws IOException { OpImageRegistrar.registerMrGeoOps(); final TIFFEncodeParam param = new TIFFEncodeParam(); // The version of GDAL that Legion is using requires a tile size > 1 param.setTileSize(image.getTileWidth(), image.getTileHeight()); param.setWriteTiled(true);//from w ww .java2 s. co m // if the image only has 1 pixel, the value of this pixel changes after compressing (especially // if this pixel is no data value. e.g -9999 changes to -8192 when read the image back). // So don't do compress if the image has only 1 pixel. if (image.getWidth() > 1 && image.getHeight() > 1) { // Deflate lossless compression (also known as "Zip-in-TIFF") param.setCompression(TIFFEncodeParam.COMPRESSION_DEFLATE); param.setDeflateLevel(Deflater.BEST_COMPRESSION); } final GeoTIFFDirectory dir = new GeoTIFFDirectory(); // GTModelTypeGeoKey : using geographic coordinate system. dir.addGeoKey(new XTIFFField(1024, XTIFFField.TIFF_SHORT, 1, new char[] { 2 })); // GTRasterTypeGeoKey : pixel is point dir.addGeoKey(new XTIFFField(1025, XTIFFField.TIFF_SHORT, 1, new char[] { 1 })); // GeographicTypeGeoKey : 4326 WGS84 dir.addGeoKey(new XTIFFField(2048, XTIFFField.TIFF_SHORT, 1, new char[] { 4326 })); dir.addGeoKey(new XTIFFField(2049, XTIFFField.TIFF_ASCII, 7, new String[] { "WGS 84" })); // GeogAngularUnitsGeoKey : Angular Degree dir.addGeoKey(new XTIFFField(2054, XTIFFField.TIFF_SHORT, 1, new char[] { 9102 })); if (xmp != null) { final byte[] b = xmp.getBytes("UTF8"); dir.addField(new XTIFFField(700, XTIFFField.TIFF_BYTE, b.length, b)); } dir.getFields(); final double[] tiePoints = new double[6]; tiePoints[0] = 0.0; tiePoints[1] = 0.0; tiePoints[2] = 0.0; tiePoints[3] = bounds.getMinX(); tiePoints[4] = bounds.getMaxY(); tiePoints[5] = 0.0; dir.setTiepoints(tiePoints); final double[] pixelScale = new double[3]; pixelScale[0] = bounds.getWidth() / image.getWidth(); pixelScale[1] = bounds.getHeight() / image.getHeight(); pixelScale[2] = 0; dir.setPixelScale(pixelScale); final Vector<TIFFField> fields = toTiffField(dir.getFields()); RenderedImage output = image; final String[] nullValues = new String[1]; switch (image.getSampleModel().getDataType()) { case DataBuffer.TYPE_DOUBLE: nullValues[0] = Double.toString(nodata.doubleValue()); if (replaceNan) { output = ReplaceNanDescriptor.create(image, nodata.doubleValue()); } // Tiff exporter doesn't handle doubles. Yuck! output = ConvertToFloatDescriptor.create(output); // Double.NaN (our default nodata on ingest) should not be written out as nodata on export // (i.e. GeoTiffs imported without NODATA metadata field should be exported as such) if (!Double.isNaN(nodata.doubleValue())) { fields.add(new TIFFField(NULL_TAG, XTIFFField.TIFF_ASCII, 1, nullValues)); } break; case DataBuffer.TYPE_FLOAT: nullValues[0] = Double.toString(nodata.floatValue()); if (replaceNan) { output = ReplaceNanDescriptor.create(image, nodata.floatValue()); } // Float.NaN (our default nodata on ingest) should not be written out as nodata on export // (i.e. GeoTiffs imported without NODATA metadata field should be exported as such) if (!Float.isNaN(nodata.floatValue())) { fields.add(new TIFFField(NULL_TAG, XTIFFField.TIFF_ASCII, 1, nullValues)); } break; case DataBuffer.TYPE_INT: case DataBuffer.TYPE_USHORT: case DataBuffer.TYPE_SHORT: case DataBuffer.TYPE_BYTE: nullValues[0] = Integer.toString(nodata.intValue()); fields.add(new TIFFField(NULL_TAG, XTIFFField.TIFF_ASCII, 1, nullValues)); break; } param.setExtraFields(fields.toArray(new TIFFField[0])); EncodeDescriptor.create(output, os, "TIFF", param, null); }