import { describe, expect, test } from "vitest";
import { createJimp } from "@jimp/core";
import { getTestImagePath } from "@jimp/test-utils";
import png from "@jimp/js-png";
import bmp from "./index.js";
const jimp = createJimp({ formats: [bmp, png] });
describe("BMP", () => {
test("load BMP", async () => {
const image = await jimp.read(getTestImagePath("windows95.bmp"));
expect(image.getPixelColor(10, 10)).toBe(0xeff7f7ff);
expect(image.getPixelColor(150, 80)).toBe(0x73add6ff);
expect(image.getPixelColor(190, 200)).toBe(0xf7c300ff);
});
test("export BMP", async () => {
const image = jimp.fromBitmap({
width: 3,
height: 3,
data: [
0xff0000ff, 0xff0080ff, 0xff00ffff, 0xff0080ff, 0xff00ffff, 0x8000ffff,
0xff00ffff, 0x8000ffff, 0x0000ffff,
],
});
const buffer = await image.getBuffer("image/bmp");
expect(buffer.toString()).toMatch(/^BM/);
});
});