use of com.caverock.androidsvg.SVG in project android by nextcloud.
the class SvgOrImageBitmapTranscoder method transcode.
@Override
public Resource<Bitmap> transcode(Resource<SVGorImage> toTranscode) {
SVGorImage svGorImage = toTranscode.get();
if (svGorImage.getSVG() != null) {
SVG svg = svGorImage.getSVG();
try {
svg.setDocumentHeight("100%");
svg.setDocumentWidth("100%");
} catch (SVGParseException e) {
Log_OC.e(this, "Could not set document size. Output might have wrong size");
}
// Create a canvas to draw onto
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
// Render our document onto our canvas
svg.renderToCanvas(canvas);
return new SimpleResource<>(bitmap);
} else {
Bitmap bitmap = svGorImage.getBitmap();
return new SimpleResource<>(bitmap);
}
}
Aggregations