The SVG is not loaded (the alt text of the image is shown) and the error seems referees to the decode function of the SVGMediaDecoder class
@NonNull
@Override
public Drawable decode(@Nullable String contentType, @NonNull InputStream inputStream) {
final SVG svg;
try {
svg = SVG.getFromInputStream(inputStream);
} catch (SVGParseException e) {
throw new IllegalStateException("Exception decoding SVG", e);
}
final float w = svg.getDocumentWidth();
final float h = svg.getDocumentHeight();
final float density = resources.getDisplayMetrics().density;
final int width = (int) (w * density + .5F);
final int height = (int) (h * density + .5F);
final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444);
final Canvas canvas = new Canvas(bitmap);
canvas.scale(density, density);
svg.renderToCanvas(canvas);
return new BitmapDrawable(resources, bitmap);
}
when the decode function runs the width and height are -1 causing the error in Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444);
Hi, I'm trying to use markown to show fontawesome icons (SVGs) as an image in a
HTML tag, but I can figure it out.
I have configured the
markown
instance like this:I have put the font awesome files in the assets folder of the app (the path to an icon is
assets/fontawesome/svgs/solid/plus.svg
)and I used the
com.caverock:androidsvg:1.4
dependency for render the SVGs.With this configuration I'm try to display the following markdown:
<img alt=\"font-awesome-plus\" src=\"file:///android_asset/fontawesome/svgs/solid/plus.svg\" width=\"150px\" height=\"150px\">
The SVG is not loaded (the alt text of the image is shown) and the error seems referees to the
decode
function of theSVGMediaDecoder
classwhen the decode function runs the width and height are
-1
causing the error inBitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444);
Which configuration do I miss?