A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

Add ImageBitmapRenderingContext.getImageData()

AshleyScirra
2016-11-15

The new ImageBitmapRenderingContext can be used standalone for some conversion purposes, e.g. ImageBitmap -> Blob via simply transferring it to a canvas ImageBitmapRenderingContext then calling toBlob() on the canvas.

However it would be much more useful for efficient conversion if it also had getImageData like the 2D context. This would enable efficient and asynchronous conversion like Blob -> ImageData. Currently even with ImageBitmapRenderingContext, it is still necessary to draw the ImageBitmap to a 2D context in order to call getImageData. If ImageBitmapRenderingContext can be used for conversion to Blob, it seems it ought to have the method to do conversion to ImageData, too.

I can’t easily find a github/issues list for the spec for this, so I’m just posting this here.

junov
2016-12-01

This is low hanging fruit, and of obvious usefullness. However, I think it might be even more convenient to have getImageData directly on ImageBitmap (no need to create a canvas and rendering context). It could also be an ImageData constructor that takes an ImageBitmap. WDYT?

AshleyScirra
2016-12-01

I’m happy if it’s possible by any means, but given that canvas seems to be the place to do conversion (given toBlob() is part of HTMLCanvasElement, and getImageData() is part of CanvasRenderingContext2D), it seems logical to add it there as well.

Since getImageData is part of the 2D context, the most obvious place to add it IMO is in the image bitmap rendering context.