Skip to content

Commit

Permalink
Rework Super Hi-Res handling, particularly APF
Browse files Browse the repository at this point in the history
We weren't handling oddly sized images well.  This was mostly a
problem for Apple Preferred Format, PNT/$0002.
  • Loading branch information
fadden committed Sep 22, 2017
1 parent 549342b commit d35a967
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 105 deletions.
17 changes: 11 additions & 6 deletions reformat/ReformatBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -786,11 +786,14 @@ void ReformatGraphics::SetResultBuffer(ReformatOutput* pOutput, MyDIBitmap* pDib
* Pass the destination buffer in "dst", source buffer in "src", source
* length in "srcLen", and expected sizes of output in "dstRem".
*
* Returns 0 on success, nonzero if the buffer is overfilled or underfilled.
* Returns the number of bytes unpacked on success, negative if the buffer is
* overfilled.
*/
int ReformatGraphics::UnpackBytes(uint8_t* dst, const uint8_t* src,
long dstRem, long srcLen)
{
const uint8_t* origDst = dst;

while (srcLen > 0) {
uint8_t flag = *src++;
int count = (flag & 0x3f) +1;
Expand Down Expand Up @@ -884,13 +887,15 @@ int ReformatGraphics::UnpackBytes(uint8_t* dst, const uint8_t* src,

ASSERT(srcLen == 0);

/* require that we completely fill the buffer */
if (dstRem != 0) {
LOGI(" SHR unpack dstRem at %d", dstRem);
return -1;
if (false) {
/* require that we completely fill the buffer */
if (dstRem != 0) {
LOGI(" SHR unpack dstRem at %d", dstRem);
return -1;
}
}

return 0;
return dst - origDst;
}

/*
Expand Down
Loading

0 comments on commit d35a967

Please sign in to comment.