-
• #2
One thing you're going to need to do is use Uint32Arrays. An array of 32 32 entry simple arrays will take up a bit over 2048 memory units, which is more than the espruino board has. Even with typed arrays, that's going to be like 500-something memory units.
-
• #3
Tryed several things always running out of memory, un the end I used a unit8array and stored everything on a 4096 lineal array and I will have to calculate the positions every time
-
• #4
So you have it working now?
You should have some luck using 32 x Uint32Arrays (or Uint8Arrays)?
-
• #5
In the end I dumped the 32 X 32 bmp into Uint32Arrays, here is the code:
var image = require("fs").readFile("GIF/blue.bmp", "binary"); image = image.substr(54,image.length); if (image.length==4096){ var bytes = new Uint8Array(4096); for (var j=0;j<4096;j++){ //bytes[j]=Math.round(image[j].charCodeAt()*TONES/256); bytes[j]=image[j].charCodeAt(); //console.log(image[j].charCodeAt()); } } if (image.length==3072){ var c = 0; var bytes = new Uint8Array(4096); for (var j=0;j<3072;j++){ if ((c+1)%4==0){ bytes[c]=128; c+=1; } else { //bytes[j]=Math.round(image[j].charCodeAt()*TONES/256); bytes[c]=image[j].charCodeAt(); //console.log(image[j].charCodeAt()); } c+=1; } }
-
• #6
Could you please modify your post, as it looks broken :)
You can extract colour data from bmp into Uint8Array on desktop computer, then using
atob
convert into binary string, and save into a file.
Then it will be much easier and faster to load it from SD card on Espruino from that file (binary string) usingatob
, speed should spike dramatically. -
• #7
I just edited the post - you just need to highlight the code and click the 'code' button.
You can actually set the value of the Uint8Array to the string with a simple:
bytes.set(image);
Which could be a bit faster for the first case.
Thanks @moka - If anyone's interested there's a little bit on how to do this at the bottom of http://www.espruino.com/Graphics
Having said that, a module to load Bitmaps off the SD card would be pretty cool :)
Hi,
I've been trying to dump a bmp file in to an array as follows:
an array of 32 arrays of 32 arrays of 4 byte values, but have not been able to make it work, I would appreciate any help, this is what I've been trying:
The first 54 bytes have header information:
I would really appreciate any help.
Bests