bmp.js 296 B

1234567891011121314151617
  1. 'use strict';
  2. function isBMP (buffer) {
  3. return ('BM' === buffer.toString('ascii', 0, 2));
  4. }
  5. function calculate (buffer) {
  6. return {
  7. 'width': buffer.readUInt32LE(18),
  8. 'height': Math.abs(buffer.readInt32LE(22))
  9. };
  10. }
  11. module.exports = {
  12. 'detect': isBMP,
  13. 'calculate': calculate
  14. };