@Override
 public Resource<Bitmap> transcode(Resource<SVG> toTranscode) {
   SVG svg = toTranscode.get();
   Picture picture = svg.renderToPicture();
   PictureDrawable drawable = new PictureDrawable(picture);
   return new SimpleResource<>(pictureDrawableToBitmap(drawable));
 }
Exemplo n.º 2
0
  /** This method is called on creation of the activity. */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // ADD SVG COAT OF ARMS BY SETTING ImageView in the layout
    // SVG SOURCE:
    // https://commons.wikimedia.org/wiki/File:Coat_of_Arms_of_the_Russian_Federation_bw2.svg
    // SVG AUTHOR: Федеральный конституционный закон «О Государственном гербе Российской Федерации»
    SVG svg = null;
    try {
      svg = SVG.getFromResource(this, R.raw.coat);
    } catch (SVGParseException e) {
      e.printStackTrace();
    }
    SVGImageView svgImageView = new SVGImageView(this);
    Drawable drawableCoat = new PictureDrawable(svg.renderToPicture());
    ImageView coatImage = (ImageView) findViewById(R.id.coatImage);
    coatImage.setImageDrawable(drawableCoat);
  }