1
0
Fork 1

Set a view box for SVG if absent

This commit is contained in:
Arne 2024-04-05 05:29:52 +02:00
parent 10fa0047fd
commit a2095c6fda

View file

@ -2314,8 +2314,6 @@ public class FileBackend {
try {
SVG svg = SVG.getFromInputStream(mXmppConnectionService.getContentResolver().openInputStream(uri));
svg.setDocumentPreserveAspectRatio(com.caverock.androidsvg.PreserveAspectRatio.FULLSCREEN);
svg.setDocumentWidth("100%");
svg.setDocumentHeight("100%");
float w = svg.getDocumentWidth();
float h = svg.getDocumentHeight();
@ -2325,6 +2323,9 @@ public class FileBackend {
float left = (size - outWidth) / 2;
float top = (size - outHeight) / 2;
RectF target = new RectF(left, top, left + outWidth, top + outHeight);
if (svg.getDocumentViewBox() == null) svg.setDocumentViewBox(0, 0, w, h);
svg.setDocumentWidth("100%");
svg.setDocumentHeight("100%");
Bitmap output = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(output);
@ -2353,6 +2354,7 @@ public class FileBackend {
float w = svg.getDocumentWidth();
float h = svg.getDocumentHeight();
Rect r = rectForSize(w < 1 ? size : (int) w, h < 1 ? size : (int) h, size);
if (svg.getDocumentViewBox() == null) svg.setDocumentViewBox(0, 0, w, h);
svg.setDocumentWidth("100%");
svg.setDocumentHeight("100%");