Open Noitidart opened 8 years ago
Oh I got passed the infinite loop by doing:
var a = new PNG(new Uint8Array(xhr.response));
I need to now get the rgba pixel data. Working on that now.
Hm ok so I was doing this now:
PNG.load('file:///C:/Users/Mercurius/Documents/GitHub/Firefox-PNG-Icon-Collections/_nightly/64.png', function(c) { C = c })
So C
is set to an object but i dont see pixels
(rgba array). Can you please advise?
Oh got it had to do this:
PNG.load('...../64.png', function(pnginfo) {
var imagedata = new ImageData(pnginfo.width, pnginfo.height);
pnginfo.copyToImageData(imagedata, pnginfo.decodePixels());
pnginfo.pixels = imagedata.data;
deferred_loaded.resolve(pnginfo);
});
May I submit a PR, i had to add an if statement, if its a worker, not to load that makeImage
stuff as it uses document
and then to set global instead of window.PNG
we have to set DedicatedWorkerGlobalScope.PNG =
@Noitidart
I am trying to use this from a Web Worker in a browser.
FWIW https://github.com/guest271314/decodePixelsFromOffscreenCanvas
I am trying to use this from a Web Worker in a browser.
I get the image data by doing xhr with responseType arraybuffer. I then do var p = new PNG(arrbuf);
However this gets stuck into an infinite loop. I see this is because:
Can you please help me modify to use in Web Worker scope.
Thanks!