Skip to content

Instantly share code, notes, and snippets.

@urish
Last active March 19, 2020 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urish/bb1ca32b992b027d4f557dfb58b0d97f to your computer and use it in GitHub Desktop.
Save urish/bb1ca32b992b027d4f557dfb58b0d97f to your computer and use it in GitHub Desktop.
const bmpjs = require('bmp-js');
const fs = require('fs');
const happyb = fs.readFileSync('./happy-birthday.bmp');
const bitmap = bmpjs.decode(happyb);
for (x = 0; x < bitmap.width; x++) {
let line = '';
for (y = 0; y < bitmap.height; y++) {
line += bitmap.data[y * bitmap.width * 4 + (bitmap.width - 1 - x) * 4 + 1] ? ' ' : '#';
}
console.log(line);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment