Posts

Showing posts with the label webgl2

Mapped color transformation on cors tainted image

Image
Clash Royale CLAN TAG #URR8PPP Mapped color transformation on cors tainted image I need to transform colors in an image obtained from an s3 server which disallows crossOrigin. This is the functionality I need: const img = new Image(); img.src = src; ctx.drawImage(img, 0, 0); const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); const colors = [25,50,100,255]; const data = imageData.data; for (let i = 0; i < data.length; i += 4) { if(data[i] == 1){data[i] = colors[1]} if(data[i] == 2){data[i] = colors[2]} if(data[i] == 3){data[i] = colors[3]} } but got tainted by crossOrigin error: I know I can not use getImageData in this case. I don't want to read the image data. getImageData But maybe complete my task through some other webGL / canvas operation? Rendering on a server or proxying is not possible. Possible duplicate of How to fix getImageData() error The canvas has been tainted by cross-origin data? ...