MCPcopy Create free account
hub / github.com/melonjs/melonJS / writeCompressedCelChunk

Function writeCompressedCelChunk

packages/melonjs/tests/aseprite-parser.spec.js:147–166  ·  view source on GitHub ↗
(
	w,
	{ layer, x, y, width, height, rgbaPixels },
)

Source from the content-addressed store, hash-verified

145
146// write a compressed cel chunk — RGBA pixels are zlib-compressed at test time
147async function writeCompressedCelChunk(
148 w,
149 { layer, x, y, width, height, rgbaPixels },
150) {
151 const compressed = await deflateZlib(rgbaPixels);
152 const sizeOffset = w.length;
153 w.u32(0);
154 w.u16(0x2005);
155 w.u16(layer);
156 w.i16(x);
157 w.i16(y);
158 w.u8(255);
159 w.u16(2); // cel type 2 = compressed image
160 w.zeros(7);
161 w.u16(width);
162 w.u16(height);
163 w.bytes(compressed);
164 const end = w.length;
165 patchU32WriterPart(w, sizeOffset, end - sizeOffset);
166}
167
168// write a tags chunk
169function writeTagsChunk(w, tags) {

Callers 1

writeFrameFunction · 0.85

Calls 8

deflateZlibFunction · 0.85
patchU32WriterPartFunction · 0.85
zerosMethod · 0.80
bytesMethod · 0.80
u32Method · 0.45
u16Method · 0.45
i16Method · 0.45
u8Method · 0.45

Tested by

no test coverage detected