MCPcopy
hub / github.com/jimp-dev/jimp / encode

Function encode

plugins/js-bmp/src/index.ts:37–58  ·  view source on GitHub ↗
(image: Bitmap, options: EncodeOptions = {})

Source from the content-addressed store, hash-verified

35}
36
37function encode(image: Bitmap, options: EncodeOptions = {}) {
38 scan(
39 { bitmap: image },
40 0,
41 0,
42 image.width,
43 image.height,
44 function (_, __, index) {
45 const red = image.data[index + 0]!;
46 const green = image.data[index + 1]!;
47 const blue = image.data[index + 2]!;
48 const alpha = image.data[index + 3]!;
49
50 image.data[index + 0] = alpha;
51 image.data[index + 1] = blue;
52 image.data[index + 2] = green;
53 image.data[index + 3] = red;
54 }
55 );
56
57 return BMP.encode({ ...image, ...options }).data;
58}
59
60function decode(data: Buffer, options?: DecodeBmpOptions) {
61 const result = BMP.decode(data, options);

Callers 4

jpegFunction · 0.85
pngFunction · 0.85
avifFunction · 0.85
pngFunction · 0.85

Calls 1

scanFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…