Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide better pixel operations for Canvas #866

Closed
vsmenon opened this issue Dec 15, 2011 · 12 comments
Closed

Provide better pixel operations for Canvas #866

vsmenon opened this issue Dec 15, 2011 · 12 comments
Labels
area-library closed-obsolete Closed as the reported issue is no longer relevant library-html P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@vsmenon
Copy link
Member

vsmenon commented Dec 15, 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)

@vsmenon
Copy link
Member Author

vsmenon commented Dec 15, 2011

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

@iposva-google
Copy link
Contributor

Added Triaged label.

@vsmenon
Copy link
Member Author

vsmenon commented Apr 12, 2012

Removed Area-UI label.
Added Area-DOM label.

@rakudrama
Copy link
Member

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.
  

@vsmenon
Copy link
Member Author

vsmenon commented Jun 22, 2012

Added this to the Later milestone.

@iposva-google
Copy link
Contributor

Removed Area-DOM label.
Added Area-HTML label.

@vsmenon
Copy link
Member Author

vsmenon commented Aug 17, 2012

Removed the owner.

@efortuna
Copy link
Contributor

efortuna commented Oct 3, 2013

Added html-api label.

@blois
Copy link
Contributor

blois commented Oct 3, 2013

Removed html-api label.

@kevmoo
Copy link
Member

kevmoo commented Apr 7, 2014

Removed Area-HTML label.
Added Area-Library, Library-Html labels.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed triaged type-enhancement A request for a change that isn't a bug labels Feb 29, 2016
@matanlurey matanlurey added the closed-obsolete Closed as the reported issue is no longer relevant label Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-library closed-obsolete Closed as the reported issue is no longer relevant library-html P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

8 participants