// Export an image rendering to a file
public void write( ProgressThread thread,
ImageExportOptions exportOptions ) throws IOException {
final ImageFileExportOptions fileOptions =
(ImageFileExportOptions)exportOptions;
final ImageType exportType = exportOptions.getImageType();
final int exportWidth = fileOptions.resizeWidth.getValue();
final int exportHeight = fileOptions.resizeHeight.getValue();
final String exportProfileName = fileOptions.colorProfile.getValue();
ICC_Profile profile =
ColorProfileInfo.getExportICCProfileFor( exportProfileName );
if ( profile == null )
profile = JAIContext.sRGBExportColorProfile;
// LZN editor state data
final byte[] lzn = exportOptions.getAuxData();
PlanarImage exportImage = getRendering(
new Dimension( exportWidth, exportHeight ), profile,
exportType instanceof JPEGImageType ||
exportOptions.getIntValueOf(BitsPerChannelOption.NAME) == 8
);
// Never uprez output images. See bug 1443.
// double scale = Math.min(exportWidth / (double) exportImage.getWidth(),
// exportHeight / (double) exportImage.getHeight());
//
// if (scale > 1) {
// AffineTransform xform = AffineTransform.getScaleInstance(scale, scale);
//
// RenderingHints formatHints = new RenderingHints(JAI.KEY_BORDER_EXTENDER, BorderExtender.createInstance(BorderExtender.BORDER_COPY));
//
// Interpolation interp = Interpolation.getInstance(Interpolation.INTERP_BICUBIC_2);
// ParameterBlock params = new ParameterBlock();
// params.addSource(exportImage);
// params.add(xform);
// params.add(interp);
// exportImage = JAI.create("Affine", params, formatHints);
// }
// Make sure that if uprezzing was requested and denied, the metadata
// reflect the actual output image size
if (fileOptions.resizeWidth.getValue() > exportImage.getWidth()) {
fileOptions.resizeWidth.setValue(exportImage.getWidth());
}
if (fileOptions.resizeHeight.getValue() > exportImage.getHeight()) {
fileOptions.resizeHeight.setValue(exportImage.getHeight());
}
if ( exportImage instanceof RenderedOp ) {
final RenderedOp rop = (RenderedOp) exportImage;
rop.setProperty(JAIContext.PERSISTENT_CACHE_TAG, Boolean.TRUE);
}
if (m_exportInfo != null) {
exportType.putImage(
m_exportInfo, exportImage, exportOptions, lzn, thread
);
}
else {
exportType.putImage(
m_imageInfo, exportImage, exportOptions, lzn, thread
);
}
}