Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MR414N-ID
GitHub Repository: MR414N-ID/botku2
Path: blob/master/node_modules/@jimp/bmp/test/bmp.test.js
1126 views
1
/* eslint-disable no-control-regex */
2
3
import { Jimp, getTestDir } from '@jimp/test-utils';
4
import configure from '@jimp/custom';
5
6
import bmp from '../src';
7
8
const jimp = configure({ types: [bmp] }, Jimp);
9
10
describe('BMP', () => {
11
const imagesDir = getTestDir(__dirname) + '/images';
12
13
it('load BMP', async () => {
14
const image = await jimp.read(imagesDir + '/windows95.bmp');
15
16
image.getPixelColor(10, 10).should.be.equal(0xeff7f7ff);
17
image.getPixelColor(150, 80).should.be.equal(0x73add6ff);
18
image.getPixelColor(190, 200).should.be.equal(0xf7c300ff);
19
});
20
21
it('export BMP', async () => {
22
const image = await jimp.read({
23
width: 3,
24
height: 3,
25
data: [
26
0xff0000ff,
27
0xff0080ff,
28
0xff00ffff,
29
0xff0080ff,
30
0xff00ffff,
31
0x8000ffff,
32
0xff00ffff,
33
0x8000ffff,
34
0x0000ffff
35
]
36
});
37
const buffer = await image.getBufferAsync('image/bmp');
38
39
buffer.toString().should.match(/^BMZ\u0000/);
40
});
41
42
it('uses correct colors for BMP', async function() {
43
this.timeout(4000);
44
45
const expectedImg = await jimp.read(
46
getTestDir(__dirname) + '/images/windows95.png'
47
);
48
const image = await jimp.read(
49
getTestDir(__dirname) + '/images/windows95.bmp'
50
);
51
52
image.bitmap.data.should.be.deepEqual(expectedImg.bitmap.data);
53
});
54
});
55
56