Re: [whatwg] createImageData - new ImageData() ?

2008-02-12 Thread Kornel Lesinski

On Sun, 10 Feb 2008 23:25:51 -, Ian Hickson [EMAIL PROTECTED] wrote:


That would mean that passing ImageData around between two canvas
elements doesn't always work as expected. I think that's highly
undesirable. Is there any implementation where we know this will the
case?


Not today, but why preclude it? Implementations could get higher quality
renderings on canvases that get resized dynamically, by using a bigger
backing store. What's wrong with what we have now?


It's very easy to write code which assumes that size of imageData is the  
same as size given in canvas width height (I know, because I did it :)


Since the ratio is system/browser-dependent and 200dpi screens aren't  
popular yet, such bug may be easily overlooked/ignored and get widely  
deployed.


The difference in sizes isn't intuitive. For example if browser doubled  
number of pixels in ImageData only when user used zoom, I think authors  
would rather think that browser's zoom is buggy.


I think that by default getImageData should return data with same size as  
specified in width/height attributes of canvas. There might be another  
method (getImageScreenData?) or method argument that returns all pixels of  
canvas.


ImageData can be made portable between canvases by adding aspect ratio  
field or additional width/height fields given in CSS pixels.


--
regards, Kornel LesiƄski


Re: [whatwg] createImageData - new ImageData() ?

2008-02-10 Thread Ian Hickson
On Sun, 3 Feb 2008, Anne van Kesteren wrote:

 Why not give the object a constructor? I think that's cleaner. Also, 
 Opera already supports that :-)

The relationship between the height and width arguments and the height and 
width of the ImageData structure returned can vary on a per-canvas basis.

-- 
Ian Hickson   U+1047E)\._.,--,'``.fL
http://ln.hixie.ch/   U+263A/,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


Re: [whatwg] createImageData - new ImageData() ?

2008-02-10 Thread Anne van Kesteren

On Sun, 10 Feb 2008 10:21:34 +0100, Ian Hickson [EMAIL PROTECTED] wrote:

On Sun, 3 Feb 2008, Anne van Kesteren wrote:

Why not give the object a constructor? I think that's cleaner. Also,
Opera already supports that :-)


The relationship between the height and width arguments and the height  
and width of the ImageData structure returned can vary on a per-canvas  
basis.


That would mean that passing ImageData around between two canvas  
elements doesn't always work as expected. I think that's highly  
undesirable. Is there any implementation where we know this will the case?



--
Anne van Kesteren
http://annevankesteren.nl/
http://www.opera.com/


Re: [whatwg] createImageData - new ImageData() ?

2008-02-10 Thread Robert O'Callahan
On Feb 10, 2008 11:14 PM, Anne van Kesteren [EMAIL PROTECTED] wrote:

 That would mean that passing ImageData around between two canvas
 elements doesn't always work as expected. I think that's highly
 undesirable. Is there any implementation where we know this will the case?


Not yet, but in Gecko when we get around to implementing variable-resolution
canvas backing stores, I expect it would happen because different documents
--- even different documents that can reference each other --- can be zoomed
different amounts, which affects the device-pixels-per-CSS-pixel ratio we
use internally.

It's actually worse than that, because we respond to dynamic DPI changes
(due to zooming or changes in preferences; I'm not sure if we actually
support detection of hardware DPI changes, e.g. due to screen mode
switching, but we easily could). So we might want to dynamically rescale the
canvas backing store.

Rob
-- 
He was pierced for our transgressions, he was crushed for our iniquities;
the punishment that brought us peace was upon him, and by his wounds we are
healed. We all, like sheep, have gone astray, each of us has turned to his
own way; and the LORD has laid on him the iniquity of us all. [Isaiah
53:5-6]


Re: [whatwg] createImageData - new ImageData() ?

2008-02-10 Thread Ian Hickson
On Sun, 10 Feb 2008, Anne van Kesteren wrote:
 On Sun, 10 Feb 2008 10:21:34 +0100, Ian Hickson [EMAIL PROTECTED] wrote:
  On Sun, 3 Feb 2008, Anne van Kesteren wrote:
   Why not give the object a constructor? I think that's cleaner. Also,
   Opera already supports that :-)
  
  The relationship between the height and width arguments and the height and
  width of the ImageData structure returned can vary on a per-canvas basis.
 
 That would mean that passing ImageData around between two canvas 
 elements doesn't always work as expected. I think that's highly 
 undesirable. Is there any implementation where we know this will the 
 case?

Not today, but why preclude it? Implementations could get higher quality 
renderings on canvases that get resized dynamically, by using a bigger 
backing store. What's wrong with what we have now?

-- 
Ian Hickson   U+1047E)\._.,--,'``.fL
http://ln.hixie.ch/   U+263A/,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


[whatwg] createImageData - new ImageData() ?

2008-02-03 Thread Anne van Kesteren
Why not give the object a constructor? I think that's cleaner. Also, Opera  
already supports that :-)



--
Anne van Kesteren
http://annevankesteren.nl/
http://www.opera.com/


Re: [whatwg] createImageData - new ImageData() ?

2008-02-03 Thread Oliver Hunt

On Feb 3, 2008, at 2:38 AM, Anne van Kesteren wrote:

Why not give the object a constructor? I think that's cleaner. Also,  
Opera already supports that :-)
The biggest problem is that you would have to define the behaviour in  
a fairly counterintuitive way
new ImageData(400, 400) would not necessarily result in an ImageData  
object with width=400, height=400

as a system with a non-1:1 css to device pixel ratio.


The moment people start using getImageData() as storage mechanism  
(which they will if browsers do not fix their data: image origin  
stuff) you'll have a problem with this if the application is  
accessed through different devices that have different ratios. I  
suspect though that given that Firefox has a 1:1 ratio sites will  
simply rely on that...

Part of my commentary was on a misunderstanding of the spec sorry :(

That said, what do you mean by using getImageData as a storage  
mechanism?


--Oliver





--
Anne van Kesteren
http://annevankesteren.nl/
http://www.opera.com/




Re: [whatwg] createImageData - new ImageData() ?

2008-02-03 Thread Anne van Kesteren

On Sun, 03 Feb 2008 12:20:54 +0100, Oliver Hunt [EMAIL PROTECTED] wrote:

On Feb 3, 2008, at 2:38 AM, Anne van Kesteren wrote:
Why not give the object a constructor? I think that's cleaner. Also,  
Opera already supports that :-)


The biggest problem is that you would have to define the behaviour in a  
fairly counterintuitive way
new ImageData(400, 400) would not necessarily result in an ImageData  
object with width=400, height=400

as a system with a non-1:1 css to device pixel ratio.


How is this a non-issue for createImageData()?


The moment people start using getImageData() as storage mechanism  
(which they will if browsers do not fix their data: image origin stuff)  
you'll have a problem with this if the application is accessed through  
different devices that have different ratios. I suspect though that  
given that Firefox has a 1:1 ratio sites will simply rely on that...


Part of my commentary was on a misunderstanding of the spec sorry :(

That said, what do you mean by using getImageData as a storage mechanism?


If you have some kind of painting application and to store the result of  
the painting so that the user can edit it in another session every now and  
then you do getImageData() on the whole canvas and export the data to  
some database through XMLHttpRequest so when the visitor comes back he  
doesn't have to start all over again.



--
Anne van Kesteren
http://annevankesteren.nl/
http://www.opera.com/