W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2007

[whatwg] new ImageData(w, h) proposal

From: Ian Hickson <ian@hixie.ch>
Date: Fri, 11 May 2007 22:11:40 +0000 (UTC)
Message-ID: <Pine.LNX.4.62.0705112115390.17396@dhalsim.dreamhost.com>
On Mon, 5 Mar 2007, Mathieu HENRI wrote:
> 
> The ImageData [1] object used in Canvas should be instantiable like 
> HTMLImageElement are using the Image constructor [2,3].

You can already do that:

   var imagedata = {
     height: 1,
     width: 1,
     data: [0,0,0,0]
   };


> * Specify the ImageData constructor should go in 3.14.7.1.10. Pixel
> manipulation [4]:
> 
>     ImageData(in unsigned long w, in unsigned long h)
> 
>     Constructs an ImageData object. The new object's width and height
> attributes must be set to respectively w and h. The new object's data is
> set to transparent black, that is w*h*4 integers set to 0.

   var imagedata = {
     height: h,
     width: w,
     data: [i for (i in function (n) { for (let i = 0; i < n; i += 1) yield 0 }(w*h*4)) ]
   };

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Friday, 11 May 2007 15:11:40 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:55 UTC