zhanaotian / svg-android

Automatically exported from code.google.com/p/svg-android
0 stars 0 forks source link

SImple output generated from SVG Pony does not render #22

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Used Linkscape to implement the classic Swedish flag
2. Used SVG Pony to migrate "Full On" SVG to SVG Tiny
3. Both IE and Google Chrome render output in 2 as expected
4. The code below renders the android.svg supplied by yourself, no problem, but 
fails to render the output from (2), as given below.

Here is the SVG :

--------------------------------------

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" width="320" height="200" 
baseProfile="tiny" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" 
viewBox="0 0 320 200">
<g id="layer1" transform="translate(0,-852.36218)">
  <rect id="rect3761" transform="translate(0,852.36218)" height="200" 
width="320" y="0" x="0" fill="#005a7b"/>
  <path id="rect3763" transform="translate(0,852.36218)" fill="#ffc200" 
d="m80,0v80h-80v40h80v80h40v-80h200v-40h-200v-80h-40z"/>
</g>
</svg>

--------------------------------------

Here is the code (resource sweden_2 is the above svg) :

--------------------------------------

package examples.pma.svg;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;

import com.larvalabs.svgandroid.SVG;
import com.larvalabs.svgandroid.SVGParser;

public class SVGActivity extends Activity
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate (Bundle savedInstanceState)
    {
        super.onCreate (savedInstanceState);

        setContentView (R.layout.main);

        ImageView i = (ImageView) findViewById (R.id.imageView1);

        //i.setImageResource (R.raw.sweden_2);

        SVG svg = SVGParser.getSVGFromResource (getResources (), R.raw.android);

        i.setImageDrawable (svg.createPictureDrawable ());
    }
}

--------------------------------------

What is the expected output? What do you see instead?

   Expected : Classic Swedish Flag (Blue background with yellow cross)

   See : No image rendered

What version of the product are you using? On what operating system?

   Android Emulator, on WIndows 7, emulating SDK ANdroid 2.2,    launched from within Eclipse

Please provide any additional information below.

The Java code renders

   Nothing is rendered, just a black background in the image view.

Original issue reported on code.google.com by paulz...@gmail.com on 11 Feb 2012 at 5:52

GoogleCodeExporter commented 9 years ago
Managed to track down the issue which prevented rendering.

SVG Pony produces :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" width="320" height="200" version="1.1" 
xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 320 200">
<g id="layer1" transform="translate(0,-852.36218)">
  <rect id="rect3761" transform="translate(0,852.36218)" height="200" width="320" y="0" x="0" fill="#005a7b"/>
  <path id="rect3763" transform="translate(0,852.36218)" fill="#ffc200" d="m80,0v80h-80v40h80v80h40v-80h200v-40h-200v-80h-40z"/>
</g>
</svg>

The transform="translate......." statements are faithfully passed through from 
the Linkscape output to the SVG Pony output.

However, these statements prevent the rendering. When I remove them I get my 
Swedish Flag

Original comment by paulz...@gmail.com on 21 Feb 2012 at 1:26

GoogleCodeExporter commented 9 years ago
The 'g' element does not support transforms. The attached patch fixes it.

Original comment by peterost...@gmail.com on 6 Jun 2012 at 5:33

Attachments: