uupaa.binarypacker0x0003.js
v0.0.5
Published
APNGDecoder pack/unpack for BinaryPacker.js
Downloads
16
Maintainers
Readme
BinaryPacker0x0003.js
APNGDecoder pack/unpack for BinaryPacker.js
Document
How to use
Browser
<script src="lib/BinaryPacker0x0003.js"></script>
<script>
var formatID = 0x0003; // APNGDecoder
var frameData = [
new APNGFrameData(0, 1, 2, 3, 4, 5.5, 6, 7),
new APNGFrameData(0, 1, 2, 3, 4, 5.5, 6, 7),
new APNGFrameData(0, 1, 2, 3, 4, 5.5, 6, 7),
];
frameData[0]._pixels = new Uint8Array([10, 11, 12, 13]);
frameData[1]._pixels = new Uint8Array([20, 21, 22, 23, 24,]);
frameData[2]._pixels = new Uint8Array([30, 31, 32, 33, 35, 36]);
var source = {
"apng": true,
"width": 2,
"height": 3,
"loopCount": 4,
"usePosterFrame": true,
"backgroundColor": 0xffeedd,
"frameData": frameData,
};
var packed = BinaryPacker.pack(source, formatID);
var result = BinaryPacker.unpack(packed);
if (source.apng === result.apng &&
source.width === result.width &&
source.height === result.height &&
source.loopCount === result.loopCount &&
source.usePosterFrame === result.usePosterFrame &&
source.backgroundColor === result.backgroundColor &&
source.frameData.length === result.frameData.length &&
source.frameData[0]._pixels[0] === result.frameData[0]._pixels[0] &&
source.frameData[0]._pixels[1] === result.frameData[0]._pixels[1] &&
source.frameData[0]._pixels[2] === result.frameData[0]._pixels[2] &&
source.frameData[0]._pixels[3] === result.frameData[0]._pixels[3]) {
console.log("OK");
} else {
console.log("NG");
}
</script>
WebWorkers
importScripts("lib/BinaryPacker0x0003.js");
...
Node.js
var BinaryPacker0x0003 = require("lib/BinaryPacker0x0003.js");
...