• Wow, that's pretty frustrating. It might make life easier to use 4 bits per pixel, which then aligns a pixels nicely into 32 bits?

    var g = Graphics.createArrayBuffer(8,8,4,{msb:tr­ue}); // note 4 bits/pixel
    
    // extract just the red bits from 32 bits of 4bpp data = 8 pixels
    function convert_red(x) {
      //"compiled" - compiled code should work here
      return (x&1)|((x>>3)&2)|((x>>6)&4)|((x>>9)&8)|
             ((x>>12)&16)|((x>>15)&32)|((x>>18)&64)|(­(x>>21)&128);
    }
    var b = new Uint32Array(g.buffer);
    var eight_red_pixels = convert_red(b[row_number]);
    // etc
    

    ... and then maybe implement that in a flip function as you say so you're not having to do that ~800 times a second. For smaller displays like you're using I imagine non-compiled code would be absolutely fine.

    There's almost certainly a way to do the convert_red function more efficiently as well. If you haven't seen it already, http://graphics.stanford.edu/~seander/bi­thacks.html looks like it'd be right up your street :)

    I don't think that page contains the answer, but there must be a neat solution out there somewhere!

About

Avatar for Gordon @Gordon started