svg to png behavior

Poster Content
nk4um User
Posts: 131
August 25, 2008 13:22code is not complete function
I meant to say of course that the relevant part of the function looks like that ...

Like · Post Reply
nk4um User
Posts: 131
August 25, 2008 13:20svg to png behavior
I''ve been experimenting with active:imageSVG2PNG.
However, I could not get it to work as I wanted in Internet Explorer (don''t know if the browser matters, but who knows). This is my SVG
<svg xmlns="" version="1.1">
  <circlecx="45" cy="45" r="40" stroke="black" stroke-width="2" fill="red" />
  <textstyle="font-size:20;font-family:verdana" text-anchor="middle" x="45" y="50">Busy</text>

Simple red Busy sign 80 pixels across.
Anyways, when using the imageSVG2PNG it shows an image of 80 pixels across, with somewhere in the top left corner, very small, my sign.

I''m probably missing some required SVG parameter that indicates the size of my canvas, but instead of looking for that, I coded the KEY_AOI (area of interest) into the accessor ;-). The IURRepresentation function then looks as follows :
protected com.ten60.netkernel.urii.IURRepresentation source(XAHelper aHelper) throws Exception
   {  String width="100";
      String aoitlx="0";
      String aoitly="0";
      String aoitrx="100";
      String aoitry="100";
      {   width=aHelper.getOperator().getXDA().getText("/SVG2PNG/width", true);

      {   aoitlx=aHelper.getOperator().getXDA().getText("/SVG2PNG/aoitlx", true);
      {   aoitly=aHelper.getOperator().getXDA().getText("/SVG2PNG/aoitly", true);
      {   aoitrx=aHelper.getOperator().getXDA().getText("/SVG2PNG/aoitrx", true);
      {   aoitry=aHelper.getOperator().getXDA().getText("/SVG2PNG/aoitry", true);

      // create a PNG transcoder
        PNGTranscoder t=new PNGTranscoder();
      t.addTranscodingHint(PNGTranscoder.KEY_WIDTH, new Float(width));
      t.addTranscodingHint(PNGTranscoder.KEY_AOI,  new Rectangle(new Integer(aoitlx),new Integer(aoitly),new Integer(aoitrx),new Integer(aoitry)));

You also need the following import to provide for the Rectangle-class
import java.awt.*;

And the conversion xml document to add then looks like

Works like a charm ;-)

Might be something to add in a future release.
Like · Post Reply