param.setForceToBigTIFF(((GeoTiffWriteParams)gtParams).isForceToBigTIFF());
}
//
// GETTING READER AND METADATA
//
final TIFFImageWriter writer = (TIFFImageWriter) GeoTiffFormat.IMAGEIO_WRITER_FACTORY.createWriterInstance();
final IIOMetadata metadata = createGeoTiffIIOMetadata(writer,ImageTypeSpecifier.createFromRenderedImage(image),geoTIFFMetadata, params);
try{
//
// IMAGEWRITE
//
writer.setOutput(outputStream);
// listeners
if(listener!=null){
final GridCoverageWriterProgressAdapter progressAdapter = new GridCoverageWriterProgressAdapter(listener);
writer.addIIOWriteProgressListener(progressAdapter);
writer.addIIOWriteWarningListener(progressAdapter);
}
writer.write(writer.getDefaultStreamMetadata(params), new IIOImage(image, null, metadata), params);
outputStream.flush();
}finally{
try{
if (!(destination instanceof ImageOutputStream)&&outputStream!=null)
outputStream.close();
}catch (Throwable e) {
// eat me
if(LOGGER.isLoggable(Level.WARNING)){
LOGGER.log(Level.WARNING,e.getLocalizedMessage(),e);
}
}
try{
if (writer!=null)
writer.dispose();
}catch (Throwable e) {
// eat me
if(LOGGER.isLoggable(Level.WARNING)){
LOGGER.log(Level.WARNING,e.getLocalizedMessage(),e);
}