No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Latest commit 67f6dca Jan 13, 2018
Permalink
Failed to load latest commit information.
src ready for publish Jan 6, 2018
test ready for publish Jan 6, 2018
.gitignore lib directory delete Jan 6, 2018
.npmignore ready Jan 6, 2018
LICENSE Initial commit Jan 5, 2018
README.md fixed Readme Jan 13, 2018
gulpfile.js ready for publish Jan 6, 2018
package-lock.json 1.0.4 Jan 13, 2018
package.json 1.0.4 Jan 13, 2018
tsconfig.json ready for publish Jan 6, 2018

README.md

bmpimagejs

pure javascript nodejs library for decoding all bmp files converted from c library http://www.netsurf-browser.org/projects/libnsbmp/

#npm link
https://www.npmjs.com/package/bmpimagejs

#install
npm install bmpimagejs --save

#build
gulp buildsrc

#test
gulp runspec

#usage

var bmp=require('bmpimagejs');
var fs=require('fs');
fs.readFile('filename', (err, data) => {
try{

        let img= bmp.decode(data.buffer); 
        //if decoding fails, throws a DecodeError;          
        //otherwise returns an RGBA image object
        console.log(img.width);
        console.log(img.height);
        console.log(img.pixels);
        for(var y=0;y<img.height;++y)
        for(var x=0;x<img.width;++x){
            var pixelPos=y*img.width*4+x*4;
            img.pixels[pixelPos]=10;//set R
            img.pixels[pixelPos+1]=10;//set G
            img.pixels[pixelPos+2]=10;//set B
            img.pixels[pixelPos+3]=10;//set A
        }
        
        }catch(ex){
            console.log(ex.errNumber);
            console.log(ex.message);
        }

    });