I would like to load a binary image from sd directly to a graphicsbuffer.
The only way, it worked for me is this:
var gr = Graphics.createArrayBuffer(64,32,4,{interleavex:true}); //this is a 64x32 LED matrix
fs = require("fs");
var x = E.toUint8Array(fs.readFile("myFile.bin")); //myFile.bin is binary file holding 1024 bytes
for(var i = 0; i < 1024; i++) gr.buffer[i] = x[i];
Using a temporary array and copy value by value in a loop looks strange to me.
And it takes a lot of CPU power to copy.
But all I tried to assign Uint8Array directly to graphics buffer, failed.
Failed in the way, that loaded image was not shown.
I'm pretty sure, there is a way to do better, but I don't find it.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I would like to load a binary image from sd directly to a graphicsbuffer.
The only way, it worked for me is this:
Using a temporary array and copy value by value in a loop looks strange to me.
And it takes a lot of CPU power to copy.
But all I tried to assign Uint8Array directly to graphics buffer, failed.
Failed in the way, that loaded image was not shown.
I'm pretty sure, there is a way to do better, but I don't find it.