From 2e38e9f218f5949f5a2b9ff31e2e7fd323e694f6 Mon Sep 17 00:00:00 2001 From: Nic Limper Date: Sat, 7 Dec 2024 22:25:23 +0100 Subject: [PATCH] added g5 preview to file editor --- ESP32_AP-Flasher/wwwroot/edit.html | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ESP32_AP-Flasher/wwwroot/edit.html b/ESP32_AP-Flasher/wwwroot/edit.html index 3e7c7109..2c29dbcf 100644 --- a/ESP32_AP-Flasher/wwwroot/edit.html +++ b/ESP32_AP-Flasher/wwwroot/edit.html @@ -425,7 +425,7 @@ const canvas = $('#previewimg'); canvas.style.display = 'block'; - fetch(path) + fetch(path + "?r=" + Math.random()) .then(response => response.arrayBuffer()) .then(buffer => { @@ -433,6 +433,16 @@ if (tagTypes[hwtype].zlib > 0 && targetDiv.dataset.ver >= tagTypes[hwtype].zlib) { data = window.opener.processZlib(data); } + if (data.length > 0 && tagTypes[hwtype].g5 > 0 && targetDiv.dataset.ver >= tagTypes[hwtype].g5) { + const headerSize = data[0]; + let bufw = (data[2] << 8) | data[1]; + let bufh = (data[4] << 8) | data[3]; + if ((bufw == tagTypes[hwtype].width || bufw == tagTypes[hwtype].height) && (bufh == tagTypes[hwtype].width || bufh == tagTypes[hwtype].height) && (data[5] <= 3)) { + // valid header for g5 compression + if (data[5] == 2) bufh *= 2; + data = window.opener.processG5(data.subarray(headerSize), bufw, bufh); + } + } [canvas.width, canvas.height] = [tagTypes[hwtype].width, tagTypes[hwtype].height] || [0, 0]; if (tagTypes[hwtype].rotatebuffer%2) [canvas.width, canvas.height] = [canvas.height, canvas.width];