protected Node inlineThumbnail ( Document doc , ParsedURL urldata , Node eold ) { RenderableImage img = ThumbnailRegistryEntry . handleURL ( urldata ) ; if ( img == null ) { LoggingUtil . warning ( "Image not found in registry: " + urldata . toString ( ) ) ; 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 ; } Element i = ( Element ) super . cloneNode ( doc , eold ) ; i . setAttributeNS ( SVGConstants . XLINK_NAMESPACE_URI , SVGConstants . XLINK_HREF_ATTRIBUTE , os . toString ( ) . replaceAll ( "\\s*[\\r\\n]+\\s*" , "" ) ) ; return i ; }
Inline a referenced thumbnail .