Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

const fs = require('fs');

var read = require(`${__dirname}/lib/read-file.js`);
var write = require(`${__dirname}/lib/write-file.js`);
var transform = require(`${__dirname}/lib/transform.js`);
12 changes: 12 additions & 0 deletions lib/read-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

const fs = require('fs');
const Bitmap = require('../model/bitmap-constructor.js');

module.exports = function(inputFile, cb) {
fs.readFile(inputFile, function(err, data) {
if(err) console.error(err);
var result = new Bitmap(data);
cb(null, result);
};
};
11 changes: 11 additions & 0 deletions lib/write-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

const fs = require('fs');

module.exports = function(path, bitmap, callback) {
fs.writeFile(path, bitmap.buff, function(err) {
if(err) return callback(err);
callback(null, bitmap.buff);
});
};

28 changes: 28 additions & 0 deletions model/bitmap-constructor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';

const fs = require('fs');

//Gets bitmap data and put into construtor
const Bitmap = module.exports = function(data) {
this.data = data;
this.id = data.toString('utf-8', 0, 2);
this.size = data.readUInt32LE(2);
this.height = data.readUInt32LE(18);
this.width = data.readUInt32LE(22);
this.pixelOffSet = data.readUInt32LE(10);
this.colorArray = data.readUInt32LE(54, this.pixelOffSet);
};

//blackout
Bitmap.prototype.blackOut = function() {
this.colorArray.fill(0);
};

//reverse
Bitmap.prototype.reversed = function() {
this.pixelOffSet.reverse();
};




Empty file added test/bitmap-constructor-test.js
Empty file.
Empty file added test/read-test.js
Empty file.
Empty file added test/write-test.js
Empty file.