From 8f4efcc731180eb51a80206e55889dbb56d0be28 Mon Sep 17 00:00:00 2001 From: staphen Date: Fri, 11 Oct 2024 21:40:33 -0400 Subject: [PATCH] Force 10-byte frame header for CLX --- source/d1formats/d1cl2.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/source/d1formats/d1cl2.cpp b/source/d1formats/d1cl2.cpp index 66133a25f..166bf0e30 100644 --- a/source/d1formats/d1cl2.cpp +++ b/source/d1formats/d1cl2.cpp @@ -392,7 +392,9 @@ static quint8 *writeFrameData(D1GfxFrame *frame, quint8 *pBuf, bool isClx, int s pBuf = AppendClxTransparentRun(transparentRunWidth, pBuf); transparentRunWidth = 0; } - pHeader[i / CEL_BLOCK_HEIGHT] = SwapLE16(pBuf - reinterpret_cast(pHeader)); // buf - SUB_HEADER_SIZE; + if (!isClx) { + pHeader[i / CEL_BLOCK_HEIGHT] = SwapLE16(pBuf - reinterpret_cast(pHeader)); // buf - SUB_HEADER_SIZE; + } } int y = frame->getHeight() - i; // Process line: @@ -442,12 +444,15 @@ bool D1Cl2::writeFileData(D1Gfx &gfx, QFile &outFile, bool isClx, const QString // calculate sub header size int subHeaderSize = SUB_HEADER_SIZE; - for (int n = 0; n < numFrames; n++) { - D1GfxFrame *frame = gfx.getFrame(n); - int hs = (frame->getHeight() - 1) / CEL_BLOCK_HEIGHT; - hs = (hs + 1) * sizeof(quint16); - subHeaderSize = std::max(subHeaderSize, hs); + if (!isClx) { + for (int n = 0; n < numFrames; n++) { + D1GfxFrame *frame = gfx.getFrame(n); + int hs = (frame->getHeight() - 1) / CEL_BLOCK_HEIGHT; + hs = (hs + 1) * sizeof(quint16); + subHeaderSize = std::max(subHeaderSize, hs); + } } + // estimate data size int maxSize = headerSize; for (int n = 0; n < numFrames; n++) {