W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2008

[whatwg] More random comments on the putImageData definition

From: Oliver Hunt <oliver@apple.com>
Date: Fri, 25 Jan 2008 15:05:19 -0800
Message-ID: <03081A14-77C2-4749-B8AD-8C56F00AA3A2@apple.com>
Ah true I had forgotten that, however this still fails for non- 
integral ratios :-/

--Oliver

On Jan 25, 2008, at 3:05 PM, Anne van Kesteren wrote:

> On Fri, 25 Jan 2008 23:57:56 +0100, Oliver Hunt <oliver at apple.com>  
> wrote:
>> Another thing that we need is some way to determine what the device  
>> pixel->css pixel ratio is.  Currently there's isn't even a real way  
>> to tell that it's 1:1 -- you would have do do a fillRect(width-1,  
>> height-1, 1, 1),; then getImageData(width-1, height-1, 1, 1) and  
>> see if they match.  Conceivably you could do this multiple times to  
>> estimate the ratio, but it would be non-trivial.
>
> You can determine this by checking the height and width attributes  
> on the ImageData object. If you get a 2x2 region and ImageData.width  
> and .height return 4 you know there's a factor two scaling happening  
> between canvas pixels and device pixels. What the factor is between  
> canvas pixels and CSS pixels isn't really relevant (and easy to  
> determine).
>
>
> -- 
> Anne van Kesteren
> <http://annevankesteren.nl/>
> <http://www.opera.com/>
Received on Friday, 25 January 2008 15:05:19 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:00 UTC