public void writeImage(BufferedImage img, TranscoderOutput output)
throws TranscoderException {
OutputStream ostream = output.getOutputStream();
if (ostream == null) {
throw new TranscoderException(
Messages.formatMessage("png.badoutput", null));
}
//
// This is a trick so that viewers which do not support the alpha
// channel will see a white background (and not a black one).
//
boolean forceTransparentWhite = false;
if (hints.containsKey(PNGTranscoder.KEY_FORCE_TRANSPARENT_WHITE)) {
forceTransparentWhite =
((Boolean)hints.get
(PNGTranscoder.KEY_FORCE_TRANSPARENT_WHITE)).booleanValue();
}
if (forceTransparentWhite) {
SinglePixelPackedSampleModel sppsm;
sppsm = (SinglePixelPackedSampleModel)img.getSampleModel();
forceTransparentWhite(img, sppsm);
}
WriteAdapter adapter = getWriteAdapter(
"org.apache.flex.forks.batik.ext.awt.image.codec.png.PNGTranscoderInternalCodecWriteAdapter");
if (adapter == null) {
adapter = getWriteAdapter(
"org.apache.flex.forks.batik.transcoder.image.PNGTranscoderImageIOWriteAdapter");
}
if (adapter == null) {
throw new TranscoderException(
"Could not write PNG file because no WriteAdapter is availble");
}
adapter.writeImage(this, img, output);
}