W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2011

[whatwg] Size of SVG->Img->Canvas

From: Gavin Kistner <gkistner@nvidia.com>
Date: Thu, 17 Nov 2011 14:56:19 -0800
Message-ID: <01804B6F1D74DE41819D69F2866C60EF512A5491DE@HQMAIL03.nvidia.com>
Imagine an SVG file displayed in an img: <img id="i" src="my.svg" ... >

The SVG file can have an explicit size (height and width attributes, in a variety of CSS units), or it can have no size (defaulting to "100%"). Whether or not the SVG file has explicit units, it may have an intrinsic aspect ratio (via the viewBox attribute).

The img can have an explicit size (height and width attributes) or no size. Separate from these, it may or may not have a separate display size (CSS units).

Now imagine that the user draws this img to a canvas:

    myCanvasContext.drawImage( document.querySelector('#i'), 0, 0 );

In each of the eight combinations of (img heightwidth/CSS heightwidth/SVG heightwidth) being present or not, what are the intrinsic dimensions of the "image" drawn to the canvas?
(Should it always use the raster bitmap created for the img? Should it re-rasterize the sourced SVG at the specified height/width?)

I have a test page showing current behavior here: http://phrogz.net/SVG/svg_to_img_to_canvas.html

Note: Firefox has bug 700533 that currently prevents it from drawing the image to the canvas when the SVG has no height/width.
https://bugzilla.mozilla.org/show_bug.cgi?id=700533

Note: Chrome v16 on Win7 produces non-deterministic results when the SVG has no height/width; each reload can result in different appearance of the SVG-in-img. This may be bug 16167.
https://bugs.webkit.org/show_bug.cgi?id=16167

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
Received on Thursday, 17 November 2011 14:56:19 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:09 UTC