From 5972b991f95e8aec690bd005758147c7adb164d1 Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Sun, 5 Sep 2021 20:42:36 +0200 Subject: [PATCH] Layout: add support for "img" with object or ArrayBuffer Graphics object Rendering these already worked, because we simply pass src to drawImage, so we just need to determine the correct size. --- modules/Layout.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/Layout.js b/modules/Layout.js index a45b17107..893403c59 100644 --- a/modules/Layout.js +++ b/modules/Layout.js @@ -167,9 +167,15 @@ function updateMin(l) { break; } case "img": { - var im = E.toString(l.src()); - l._h = im.charCodeAt(0); - l._w = im.charCodeAt(1); + var src = l.src(); + if (typeof(src) === 'object') { + l._h = ("width" in src) ? src.width : src.getWidth(); + l._w = ("height" in src) ? src.height : src.getHeight(); + } else { + var im = E.toString(src); + l._h = im.charCodeAt(0); + l._w = im.charCodeAt(1); + } break; } case undefined: