Package org.apache.batik.transcoder

Examples of org.apache.batik.transcoder.AbstractTranscoder


   */
  @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
    {
View Full Code Here


   *
   * @return The transoder or null due an unsupported type
   */
  private AbstractTranscoder determineTranscoder(int imageType)
  {
    AbstractTranscoder transcoder = null;

    if (imageType == SupportedImageTypes.PNG || imageType == SupportedImageTypes.TIFF || imageType == SupportedImageTypes.JPEG)
    {
      ImageTranscoder imageTranscoder = null;

View Full Code Here

TOP

Related Classes of org.apache.batik.transcoder.AbstractTranscoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.