deanm / plask

Plask is a multimedia programming environment.
www.plask.org
Other
443 stars 38 forks source link

SkCanvas.pixels RGBA vs BGRA #51

Closed vorg closed 8 years ago

vorg commented 8 years ago

Why SkCanvas is BGRA but SkCanvas.pixels are RGBA ? texImage2DSkCanvas is using GL_BGRA so I get different results. I was supposed to update my code to always use pixels but if I do that for texture upload i get inverted R & B channels.

deanm commented 8 years ago

I don't think anything should have changed... if it did it's because of a new build of Skia which has the color ordering incorrect. Have a simple reproduction case?

deanm commented 8 years ago

So I just quickly tested the current build vs a build from 2014, and it looks like the ordering is the same as it has always been. Just to clarify that ordering is BGRA. What does the following print for you? I get 3 2 1, which is BGRA.

var plask = require('plask') var canvas = new plask.SkCanvas(3, 3); canvas.clear(1, 2, 3, 255); canvas = canvas.pixels || canvas; console.log(canvas[0]); console.log(canvas[1]); console.log(canvas[2]);

vorg commented 8 years ago

Sorry my fault. I do this

if (data instanceof plask.SkCanvas) {

and use texImage2DSkCanvas for Canvas, but for pixels it branches to texImage2D which is obviously wrong as it uploads BGRA data as RGBA