My favorites | Sign in
Project Home Wiki Issues Source Code Search
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 866: Provide better pixel operations for Canvas
4 people starred this issue and may be notified of changes. Back to list
Status:  Triaged
Owner:  ----
Cc:  iposva@google.com


Sign in to add a comment
 
Project Member Reported by vsm@google.com, Dec 14, 2011

(From iposva):

Consider better APIs to write canvas pixels than a CanvasPixelArray.  

E.g., setRGBA(x, y, r, g, b, a) instead of CanvasPixelArray's byte accesses.

i = y*n+x;
pixel[i] = r;
pixel[i+1] = g;
pixel[i+2] = b;
pixel[i+3] = a;

becomes:

pixels.setRGBA(x, y, r, g, b, a)
Dec 14, 2011
Project Member #1 vsm@google.com
Looks like CanvasPixelArray -> Uint8ClampedArray in the underlying DOM, which provides more flexible access as well:

http://www.khronos.org/registry/typedarray/specs/latest/#7.1

Dec 14, 2011
Project Member #2 iposva@google.com
(No comment was entered for this change.)
Status: Triaged
Apr 12, 2012
Project Member #3 vsm@google.com
(No comment was entered for this change.)
Labels: -Area-UI Area-DOM
May 30, 2012
Project Member #4 sra@google.com
There is no way to distinguish an array for an NxM image from a MxN image or any other shape with N*M/4 pixels.

ImageData has the needed missing info - the width, but that would incur the overhead of an extra indirection which would make bound checking optimization harder due to potential aliasing and heap mutation.

It might be reasonable to work in pixel indexes:

pixels.setRGBA(x + y*width, r, g, b, a);

void setRGBA(int pixelIndex, int r, int g, int b, int a) {
  int i = pixelIndex * 4;
  this[i] = r;
  this[i+1] = g;
  this[i+2] = b;
  this[i+3] = a;
}

The asymmetry between writing whole pixels at pixel positions and reading channels from channel positions is displeasing.
  

Jun 22, 2012
Project Member #5 vsm@google.com
(No comment was entered for this change.)
Labels: Milestone-Later
Aug 13, 2012
Project Member #6 iposva@google.com
(No comment was entered for this change.)
Labels: -Area-DOM Area-HTML
Aug 16, 2012
Project Member #7 vsm@google.com
(No comment was entered for this change.)
Owner: ---
Oct 3, 2013
Project Member #8 efortuna@google.com
(No comment was entered for this change.)
Labels: html-api
Oct 3, 2013
Project Member #9 blois@google.com
(No comment was entered for this change.)
Labels: -html-api
Apr 7, 2014
Project Member #10 kevmoo@google.com
(No comment was entered for this change.)
Labels: -Area-HTML Area-Library Library-Html
Jul 10, 2014
Project Member #11 kasperl@google.com
(No comment was entered for this change.)
Labels: -Milestone-Later Oldschool-Milestone-Later
Aug 4, 2014
Project Member #12 kasperl@google.com
(No comment was entered for this change.)
Labels: -Oldschool-Milestone-Later
Sign in to add a comment

Powered by Google Project Hosting