[whatwg] More random comments on the putImageData definition

Oliver Hunt oliver at apple.com
Fri Jan 25 15:05:19 PST 2008


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/>




More information about the whatwg mailing list