final AbstractGridFormat format = new GeoTiffFormat();
File file = TestData.file(GeoTiffReaderTest.class,"002025_0100_010722_l7_01_utm2.tiff");
if (format.accepts(file)) {
// getting a reader
GeoTiffReader reader = new GeoTiffReader(file, new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE));
if (reader != null) {
// reading the coverage
GridCoverage2D coverage = (GridCoverage2D) reader.read(null);
assertNotNull(coverage);
assertTrue(coverage.getRenderedImage().getSampleModel().getNumBands() == 1);
final ParameterValue<Color> colorPV = AbstractGridFormat.INPUT_TRANSPARENT_COLOR.createValue();
colorPV.setValue(Color.BLACK);
coverage = (GridCoverage2D) reader.read(new GeneralParameterValue[] { colorPV });
assertNotNull(coverage);
assertTrue(coverage.getRenderedImage().getSampleModel().getNumBands() == 2);
// showing it
if (TestData.isInteractiveTest())
coverage.show();
else
PlanarImage.wrapRenderedImage(coverage.getRenderedImage()).getTiles();
}
} else
assertFalse(true); // we should not get here
file = TestData.file(GeoTiffReaderTest.class,"gaarc_subset.tiff");
if (format.accepts(file)) {
// getting a reader
GeoTiffReader reader = new GeoTiffReader(file, new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE));
if (reader != null) {
// reading the coverage
GridCoverage2D coverage = (GridCoverage2D) reader.read(null);
assertNotNull(coverage);
assertTrue(coverage.getRenderedImage().getSampleModel().getNumBands() == 3);
final ParameterValue<Color> colorPV = AbstractGridFormat.INPUT_TRANSPARENT_COLOR.createValue();
colorPV.setValue(new Color(34,53,87));
coverage = (GridCoverage2D) reader.read(new GeneralParameterValue[] { colorPV });
assertNotNull(coverage);
assertTrue(coverage.getRenderedImage().getSampleModel().getNumBands() == 4);
// showing it
if (TestData.isInteractiveTest())
coverage.show();
else
PlanarImage.wrapRenderedImage(coverage.getRenderedImage()).getTiles();
}
} else
assertFalse(true); // we should not get here
// now we test that we cannot do colormasking on a non-rendered output
file = TestData.file(GeoTiffReaderTest.class,"wind.tiff");
if (format.accepts(file)) {
// getting a reader
GeoTiffReader reader = new GeoTiffReader(file, new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE));
if (reader != null) {
// reading the coverage
GridCoverage2D coverage = (GridCoverage2D) reader.read(null);
assertNotNull(coverage);
assertTrue(coverage.getRenderedImage().getSampleModel().getNumBands() == 2);