Skip to content

Commit ac76f38

Browse files
committed
Making player skip unsupported and wrong files
1 parent 12e7e09 commit ac76f38

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

BinaryAnimationPlayer/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,15 @@ <h2>Binary Animation Player</h2>
109109
const w = isDeprecatedFormat ? view.getUint8(0) : view.getUint16(4, true);
110110
const h = isDeprecatedFormat ? view.getUint8(1) : view.getUint16(6, true);
111111
const pixelsPerFrame = w * h;
112-
const bpp = is565 || filetype === 'b2' ? 2 : 1;
112+
const bpp = is565 || filetype === 'b2' ? 2 : is332 || filetype === 'b1' ? -1 : 1;
113113
const totalDataBytes = buffer.byteLength - headerSize;
114114
const bytesPerFrame = pixelsPerFrame * bpp;
115115
const frames = Math.floor(totalDataBytes / bytesPerFrame);
116116

117+
if ((!isDeprecatedFormat || !filesignature === "bA") || bpp === -1) {
118+
status.innerHTML = `<span style="color: #e74c3c;">Unsupported file format.</span>`;
119+
return;
120+
}
117121
meta = {headerSize, w, h, frames, bpp, view };
118122
currentBuffer = view;
119123

0 commit comments

Comments
 (0)