Path: blob/master/node_modules/@jimp/bmp/test/bmp.test.js
1126 views
/* eslint-disable no-control-regex */12import { Jimp, getTestDir } from '@jimp/test-utils';3import configure from '@jimp/custom';45import bmp from '../src';67const jimp = configure({ types: [bmp] }, Jimp);89describe('BMP', () => {10const imagesDir = getTestDir(__dirname) + '/images';1112it('load BMP', async () => {13const image = await jimp.read(imagesDir + '/windows95.bmp');1415image.getPixelColor(10, 10).should.be.equal(0xeff7f7ff);16image.getPixelColor(150, 80).should.be.equal(0x73add6ff);17image.getPixelColor(190, 200).should.be.equal(0xf7c300ff);18});1920it('export BMP', async () => {21const image = await jimp.read({22width: 3,23height: 3,24data: [250xff0000ff,260xff0080ff,270xff00ffff,280xff0080ff,290xff00ffff,300x8000ffff,310xff00ffff,320x8000ffff,330x0000ffff34]35});36const buffer = await image.getBufferAsync('image/bmp');3738buffer.toString().should.match(/^BMZ\u0000/);39});4041it('uses correct colors for BMP', async function() {42this.timeout(4000);4344const expectedImg = await jimp.read(45getTestDir(__dirname) + '/images/windows95.png'46);47const image = await jimp.read(48getTestDir(__dirname) + '/images/windows95.bmp'49);5051image.bitmap.data.should.be.deepEqual(expectedImg.bitmap.data);52});53});545556