[jira] [Closed] (BATIK-1207) NPE with different PNGTranscoder.KEY_WIDTH, PNGTranscoder.KEY_HEIGHT

"Pascual Lorente (JIRA)" <[email protected]>
Newsgroups gmane.text.xml.batik.devel
Message-ID <[email protected]>
     [ https://issues.apache.org/jira/browse/BATIK-1207?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pascual Lorente closed BATIK-1207.
----------------------------------
    Resolution: Not A Problem

I just added style="color-interpolation-filters:sRGB" to the filter

> NPE with different PNGTranscoder.KEY_WIDTH, PNGTranscoder.KEY_HEIGHT
> --------------------------------------------------------------------
>
>                 Key: BATIK-1207
>                 URL: https://issues.apache.org/jira/browse/BATIK-1207
>             Project: Batik
>          Issue Type: Bug
>          Components: SVG Rasterizer
>    Affects Versions: 1.9
>         Environment: Debian 9
> SDK 1.8.0_151
>            Reporter: Pascual Lorente
>            Priority: Critical
>              Labels: KEY_HEIGHT, KEY_WIDTH, PNGTranscoder
>         Attachments: ehld.svg
>
>
> I'm having a tough time with PNGTranscoder. I am rendering an SVG document into a PNG image of different sizes. For that, I use a factor.
> {code:java}
> final float factor = 1.0f;
> // Load document
> final SAXSVGDocumentFactory DOCUMENT_FACTORY = new SAXSVGDocumentFactory(XMLResourceDescriptor.getXMLParserClassName());
> SVGDocument document = DOCUMENT_FACTORY.createSVGDocument("ehld.svg");
> // Extract original height and width
> final SVGSVGElement root = document.getRootElement();
> final String viewBox = root.getAttributes().getNamedItem("viewBox").getNodeValue();
> final Scanner scanner = new Scanner(viewBox);
> scanner.useLocale(Locale.UK);
> float x = scanner.nextFloat();
> float y = scanner.nextFloat();
> float width = scanner.nextFloat();
> float height = scanner.nextFloat();
> // Set png width and height
> final float w = width * factor;
> final float h = height * factor;
> final ImageTranscoder transcoder = new PNGTranscoder();
> transcoder.addTranscodingHint(PNGTranscoder.KEY_WIDTH, w);
> transcoder.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, h);
> // Export
> final TranscoderInput input = new TranscoderInput(document);
> final File file = new File("output.png");
> final TranscoderOutput output = new TranscoderOutput(new FileOutputStream(file));
> transcoder.transcode(input, output);
> {code}
> For some factors, it works nicely, but there are some of them that crash with:
> Enclosed Exception:
> Unable to transform src image
> 	at org.apache.batik.transcoder.image.ImageTranscoder.transcode(ImageTranscoder.java:132)
> 	at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142)
> 	at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:156)
> 	at visual.VisualTesting.test(VisualTesting.java:298)
> 	at visual.VisualTesting.main(VisualTesting.java:64)
> From 0.1 to 2.0 (step 0.1) it does NOT work with 0.7, 1.3, 1.4, 1.5, 1.7.
> When I remove the filter in the SVG document (*style="filter:url(#selection-filter)"*, line 1188) problems dissapear.
> Not sure if a bug or a misusage. Thanks



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.