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

8bit good for lighting and such - 32bit view for pixel copy? #2

Open
Sarah-C opened this issue Jun 27, 2022 · 2 comments
Open

8bit good for lighting and such - 32bit view for pixel copy? #2

Sarah-C opened this issue Jun 27, 2022 · 2 comments

Comments

@Sarah-C
Copy link

Sarah-C commented Jun 27, 2022

This may speed it up a little?

let ctx = c.getContext("2d");
let canvasDataWrapper = ctx.getImageData(0, 0, c.width, c.height);
let canvasData = imageDataWrapper.data; // 8 bit ARGB
let canvasData32 = new Uint32Array(canvasData.buffer); // 32 bit pixel

copyFnc = function(idxC, idxT){
canvasData[idxC + 0] = textureData[idxT + 0];
canvasData[idxC + 1] = textureData[idxT + 1];
canvasData[idxC + 2] = textureData[idxT + 2];
canvasData[idxC + 3] = 255;
};

Vs

copyFnc = function(idxC, idxT){
canvasData32[idxC] = textureData32[idxT]
};

@SamHasler
Copy link
Owner

Hi thanks for your interest and taking the time to post this. I might not have time to look at this for a couple of months but I've always been curious as to whether this could be speeded up so I'm sure I'll look at it at some point.

@Sarah-C
Copy link
Author

Sarah-C commented Jun 28, 2022

I'm a firm believer of "relaxation driven development." That's where you're relaxed and decide to do a little bit of a puzzle/code for fun. Not that much around these days! Catch up with you in a month or two!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants