*/
@SuppressWarnings("unused")
public void writeImage(int imageType, OutputStream os, String errorName)
throws Exception
{
AbstractTranscoder transcoder = determineTranscoder(imageType);
if (transcoder == null)
{
String msg = MsgFormat.format("Unsupported image type $0.", errorName);
throw new IOException(msg);
}
OutputStreamWriter writer = null;
try
{
Map transcodingHints = null;
TranscoderOutput to = null;
if (imageType == SupportedImageTypes.SVG)
{
writer = new OutputStreamWriter(os, SVGGraphics2D.DEFAULT_XML_ENCODING);
to = new TranscoderOutput(writer);
}
else
{
to = new TranscoderOutput(os);
}
if (transcodingHints != null)
{
Iterator hintKeys = transcodingHints.keySet().iterator();
while (hintKeys.hasNext())
{
TranscodingHints.Key key = (TranscodingHints.Key) hintKeys.next();
transcoder.addTranscodingHint(key, transcodingHints.get(key));
}
}
// Perform the transcoding
transcoder.transcode(new TranscoderInput(svgDocument), to);
os.flush();
}
finally
{