Open mackwu828 opened 1 year ago
public static void GetFileSvg(String input, ImageView img, Context activity, TextView tv1) {
try {
File startDir = new File(input);
FileInputStream fileInputStream = new FileInputStream(startDir);
SVG svg = SVG.getFromInputStream(fileInputStream);
final Drawable drawable = new PictureDrawable(svg.renderToPicture());
Glide.with(activity)
.load(drawable)
.transition(com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade((int)600))
// .circleCrop()
.error(R.drawable.close)
.diskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy.ALL)
.priority(Priority.HIGH)
.into(img);
infoLog("load");
if (svg.getDocumentWidth() != 1) {
tv1.setText(String.valueOf((long) Math.ceil(svg.getDocumentWidth())).concat(" x ")
.concat(String.valueOf((long) Math.ceil(svg.getDocumentHeight()))));
}
} catch (IOException | SVGParseException d) {
d.printStackTrace();
}
}```
@mackwu828 try it bro
glide version:
Loading a jpg image, but reporting an svg exception. Any idea why?
I have added svg demo from https://github.com/bumptech/glide/tree/master/samples/svg.