Examples of Base64EncoderStream


Examples of org.apache.batik.util.Base64EncoderStream

public class Base64PNGEncoderTest extends PNGEncoderTest {
    /**
     * Template method for building the PNG output stream
     */
    public OutputStream buildOutputStream(ByteArrayOutputStream bos){
        return new Base64EncoderStream(bos);
    }
View Full Code Here

Examples of org.apache.batik.util.Base64EncoderStream

        //
        // Setup Base64Encoder stream to byte array.
        //
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        Base64EncoderStream b64Encoder = new Base64EncoderStream(os);
        try {
            //
            // Now, encode the input image to the base 64 stream.
            //
            encodeImage(image, b64Encoder);

            // Close the b64 encoder stream (terminates the b64 streams).
            b64Encoder.close();
        } catch (IOException e) {
            // Should not happen because we are doing in-memory processing
            throw new SVGGraphics2DIOException(ERR_UNEXPECTED, e);
        }
View Full Code Here

Examples of org.apache.batik.util.Base64EncoderStream

        //
        // Setup Base64Encoder stream to byte array.
        //
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        Base64EncoderStream b64Encoder = new Base64EncoderStream(os);
        try {
            //
            // Now, encode the input image to the base 64 stream.
            //
            encodeImage(image, b64Encoder);

            // Close the b64 encoder stream (terminates the b64 streams).
            b64Encoder.close();
        } catch (IOException e) {
            // Should not happen because we are doing in-memory processing
            throw new SVGGraphics2DIOException(ERR_UNEXPECTED, e);
        }
View Full Code Here

Examples of org.apache.batik.util.Base64EncoderStream

    /**
     * Uses PNG encoding.
     */
    public void encodeImage(BufferedImage buf, OutputStream os)
            throws IOException {
        Base64EncoderStream b64Encoder = new Base64EncoderStream(os);
        ImageEncoder encoder = new PNGImageEncoder(b64Encoder, null);
        encoder.encode(buf);
        b64Encoder.close();
    }
View Full Code Here

Examples of org.apache.batik.util.Base64EncoderStream

        //
        // Setup Base64Encoder stream to byte array.
        //
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        Base64EncoderStream b64Encoder = new Base64EncoderStream(os);
        try {
            //
            // Now, encode the input image to the base 64 stream.
            //
            encodeImage(image, b64Encoder);

            // Close the b64 encoder stream (terminates the b64 streams).
            b64Encoder.close();
        } catch (IOException e) {
            // Should not happen because we are doing in-memory processing
            throw new SVGGraphics2DIOException(ERR_UNEXPECTED, e);
        }
View Full Code Here

Examples of org.apache.batik.util.Base64EncoderStream

public class Base64PNGEncoderTest extends PNGEncoderTest {
    /**
     * Template method for building the PNG output stream
     */
    public OutputStream buildOutputStream(ByteArrayOutputStream bos){
        return new Base64EncoderStream(bos);
    }
View Full Code Here

Examples of org.apache.batik.util.Base64EncoderStream

      return null;
    }
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {
      os.write(SVGSyntax.DATA_PROTOCOL_PNG_PREFIX.getBytes());
      Base64EncoderStream encoder = new Base64EncoderStream(os);
      ImageIO.write(img.createDefaultRendering(), "png", encoder);
      encoder.close();
    }
    catch(IOException e) {
      LoggingUtil.exception("Exception serializing image to png", e);
      return null;
    }
View Full Code Here

Examples of org.apache.batik.util.Base64EncoderStream

      return null;
    }
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {
      os.write(SVGSyntax.DATA_PROTOCOL_PNG_PREFIX.getBytes());
      Base64EncoderStream encoder = new Base64EncoderStream(os);
      FileInputStream instream = new FileInputStream(in);
      byte[] buf = new byte[4096];
      while(true) {
        int read = instream.read(buf, 0, buf.length);
        if(read <= 0) {
          break;
        }
        encoder.write(buf, 0, read);
      }
      instream.close();
      encoder.close();
    }
    catch(IOException e) {
      LoggingUtil.exception("Exception serializing image to png", e);
      return null;
    }
View Full Code Here

Examples of org.apache.batik.util.Base64EncoderStream

          Element i = (Element) img;
          String href = i.getAttributeNS(SVGConstants.XLINK_NAMESPACE_URI, SVGConstants.XLINK_HREF_ATTRIBUTE);
          if(href.startsWith(tmpurl) && href.endsWith(".png")) {
            // need to convert the image into an inline image.
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            Base64EncoderStream encoder = new Base64EncoderStream(os);
            File in = new File(new URI(href));
            FileInputStream instream = new FileInputStream(in);
            byte[] buf = new byte[4096];
            while(true) {
              int read = instream.read(buf, 0, buf.length);
              if(read <= 0) {
                break;
              }
              encoder.write(buf, 0, read);
            }
            instream.close();
            encoder.close();
            // replace HREF with inlined image data.
            i.setAttributeNS(SVGConstants.XLINK_NAMESPACE_URI, SVGConstants.XLINK_HREF_ATTRIBUTE, SVGSyntax.DATA_PROTOCOL_PNG_PREFIX + os.toString());
          }
        }
        catch(URISyntaxException e) {
View Full Code Here

Examples of org.apache.batik.util.Base64EncoderStream

        //
        // Setup Base64Encoder stream to byte array.
        //
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        Base64EncoderStream b64Encoder = new Base64EncoderStream(os);
        try {
            //
            // Now, encode the input image to the base 64 stream.
            //
            encodeImage(image, b64Encoder);

            // Close the b64 encoder stream (terminates the b64 streams).
            b64Encoder.close();
        } catch (IOException e) {
            // Should not happen because we are doing in-memory processing
            throw new SVGGraphics2DIOException(ERR_UNEXPECTED, e);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.