[whatwg] getImageData/putImageData comments

Boris Zbarsky bzbarsky at MIT.EDU
Mon Jun 1 06:40:24 PDT 2009


Maciej Stachowiak wrote:
> In some environments, a CSS pixel may be more than one device pixel.

Yes, I'm well aware.

> In this case, getImageData followed by putImageData will lose resolution. 

Right.  I did mention that in my reply to Oliver.

It seems that there are two significantly different use cases for 
putImageData.  One is that of doing getImageData on a canvas followed by 
some manipulation of the existing pixel data.  In this case I agree that:

> The current design makes it possible to write code that will do the 
> right thing in a scaled UI. It also makes it easy to do the wrong thing 
> and copy only a fraction of the area intended.

I'm not quite sure what I think of the tradeoffs here yet, and I need to 
go read through the old discussions, but I do appreciate the problems.

The other use case is doing createImageData, followed by filling in the 
pixels, followed by putImageData.  In this case, there is no quality 
loss of existing data involved, but the current design still makes it 
easy to do the wrong thing...  In fact, it makes it much more difficult 
than it should be to do the right thing for a typical web developer.

Perhaps the two use cases should use a different put API and 
incompatible imagedata objects and actually use different coordinate 
spaces?  It'd be somewhat confusing, but the use cases for the two seem 
to me to be sufficiently different that it might be warranted...

-Boris



More information about the whatwg mailing list