From 64226599f81b92c260abbc1097e6a2a096da4572 Mon Sep 17 00:00:00 2001 From: modeco80 Date: Tue, 9 Jul 2024 18:59:11 -0400 Subject: [PATCH] read image RGNDATA structure --- msagent.js/src/structs/core.ts | 8 ++++---- msagent.js/src/structs/image.ts | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/msagent.js/src/structs/core.ts b/msagent.js/src/structs/core.ts index a2b4df2..9c833de 100644 --- a/msagent.js/src/structs/core.ts +++ b/msagent.js/src/structs/core.ts @@ -19,7 +19,7 @@ export class RECT { } export class RGNDATAHEADER { - size = 0x20; // I think? + size = 0x20; type = 1; count = 0; rgnSize = 0; @@ -29,11 +29,11 @@ export class RGNDATAHEADER { let hdr = new RGNDATAHEADER(); hdr.size = buffer.readU32LE(); - //if(hdr.size != 0x20) - // throw new Error("Invalid RGNDATAHEADER!"); + if(hdr.size != 0x20) + throw new Error("Invalid RGNDATAHEADER!"); hdr.type = buffer.readU32LE(); - if (hdr.type != 1) throw new Error('Invalid RGNDATAHEADER type!'); + if (hdr.type != 1) throw new Error('Invalid RGNDATAHEADER type (only rectangles are supported)!'); hdr.count = buffer.readU32LE(); hdr.rgnSize = buffer.readU32LE(); diff --git a/msagent.js/src/structs/image.ts b/msagent.js/src/structs/image.ts index f19fc61..a193b90 100644 --- a/msagent.js/src/structs/image.ts +++ b/msagent.js/src/structs/image.ts @@ -55,8 +55,13 @@ export class AcsImage { image.data = data; } + + // this will be a rgndata (TODO) read this - //let temp = COMPRESSED_DATABLOCK.read(buffer); + let temp = COMPRESSED_DATABLOCK.read(buffer); + let tempBuffer = new BufferStream(temp.data); + + image.regionData = RGNDATA.read(tempBuffer); return image; }