-1

I am having issues setting my custom decoder in setDecoder() method of TileView android library. Nothing is getting displayed on the screen. I am having a svg image and converting the same into a bitmap using android svg library.Kindly help. PFB the code On create method in main class

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    TileView tileView = new TileView(this);

    tileView.setSize(600, 400);

    tileView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);


    tileView.setTileDecoder(new BitmapDecoderAssetsCustom(this));

    setContentView(tileView);

}

The BitmapDecoderAssetsCustom decoder class.

    public class BitmapDecoderAssetsCustom implements BitmapDecoder {

    public BitmapDecoderAssetsCustom(Context c){
        decode("acid1_embedcss.svg",c);
    }

        @Override
        public Bitmap decode(String s, Context context) {

   Bitmap  obj=null;

            try {

                SVG svg = SVG.getFromAsset(context.getAssets(), "acid1_embedcss.svg");

                System.out.println("document width  "+svg.getDocumentWidth());

 System.out.println("document height  "+svg.getDocumentHeight());


   obj = Bitmap.createBitmap((int)Math.ceil(svg.getDocumentWidth()),
                        (int) Math.ceil(svg.getDocumentHeight()),
                        Bitmap.Config.ARGB_8888);
            } 
catch (SVGParseException e) {
                e.printStackTrace();
            }
 catch (IOException e) {
                e.printStackTrace();
            }

 return obj;
        }
    }
Jaiprakash Soni
  • 4,100
  • 5
  • 36
  • 67
DSM
  • 1
  • 1

1 Answers1

0

You are parsing the SVG, and you are creating a bitmap. But at no point are you rendering the SVG into the bitmap.

There is an example of how to do that on the AndroidSVG home page.

Paul LeBeau
  • 97,474
  • 9
  • 154
  • 181
  • I am using the TileView Library and using the tileView.setTileDecoder(new BitmapDecoderAssetsCustom(this)); method for displaying the image.PFB the link http://moagrius.github.io/TileView/index.html?com/qozix/tileview/TileView.html – DSM Aug 17 '15 at 05:17