easybotics / node-rpi-rgb-led-matrix

Pilot your rgb led matrix with Nodejs ! Nodejs binding of rpi-rgb-led-matrix library https://github.com/hzeller/rpi-rgb-led-matrix - Actively Maintained!
Do What The F*ck You Want To Public License
57 stars 17 forks source link

any plan for implementing images #15

Open chollan opened 3 years ago

chollan commented 3 years ago

This is more of a feature request, or for someone to point me in the right direction: is there any plan to support images using the setImageBuffer method or any similar? i see images are supported within easybotics/node-red-contrib-easybotics-led-matrix, but i see no documentation about images for nodejs.

nguyenthaohut commented 2 years ago

`var LedMatrix = require("easybotics-rpi-rgb-led-matrix"); var fs = require('fs'); var path = require('path'); const Jimp = require("jimp"); const bufferImage = require("buffer-image"); //init a 16 rows by 16 cols led matrix //default hardware mapping is 'regular', could be 'adafruit-hat-pwm' ect var matrix = new LedMatrix(64, 64,2,1,'regular'); let imgpath = path.join(__dirname, 'vms.bmp'); console.log(imgpath); //let imgf = fs.readFileSync(imgpath); //let fimgb = Buffer.from(imgf,'binary'); Jimp.read(imgpath, function (err, image) { if (err) { console.log(err); } else { //console.log(image); //const fimgb = image.getBuffer(); //const fimgb = Buffer.from(image,'binary'); image.getBuffer(Jimp.MIME_BMP, (err, buffer) => { console.log(buffer); //console.log(fimgb); while(1) { //matrix.drawCircle(15,35,10,0,255,255); matrix.brightness(95); //matrix.fill(0, 255, 0); matrix.setImageBuffer(buffer,64,64); matrix.update(); } });

}

}) I try to set buffer but it return error: node: ../src/ledmatrix.cc:530: static void LedMatrix::SetImageBuffer(const Nan::FunctionCallbackInfo<v8::Value>&): Assertion(int)bufl == widthheight3' failed. Aborted