comparison tools/libgfx.c @ 2082:a0a6f5a3fbbf

Fix plane buffer size calculation for IFF ACBM to round up to nearest byte (minimum of 1).
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 10 Dec 2018 20:48:46 +0200
parents a14286e2710e
children feed844a5ae1
comparison
equal deleted inserted replaced
2081:a14286e2710e 2082:a0a6f5a3fbbf
1689 1689
1690 } 1690 }
1691 else 1691 else
1692 if (iff->idsig == IFF_ID_ACBM) 1692 if (iff->idsig == IFF_ID_ACBM)
1693 { 1693 {
1694 bufLen = (img->width * img->height) / 8; 1694 bufLen = (img->width * img->height + 7) / 8;
1695 dmMsg(2, "IFF: Plane buffer size %d bytes.\n", bufLen); 1695 dmMsg(2, "IFF: Plane buffer size %d bytes.\n", bufLen);
1696 } 1696 }
1697 1697
1698 if (bufLen > 0 && (buf = dmMalloc(bufLen)) == NULL) 1698 if (bufLen > 0 && (buf = dmMalloc(bufLen)) == NULL)
1699 return DMERR_MALLOC; 1699 return DMERR_MALLOC;
2358 (iff.idsig == IFF_ID_ACBM) ? IFF_ID_ABIT : IFF_ID_BODY)) != DMERR_OK) 2358 (iff.idsig == IFF_ID_ACBM) ? IFF_ID_ABIT : IFF_ID_BODY)) != DMERR_OK)
2359 goto out; 2359 goto out;
2360 2360
2361 // Allocate encoding buffer 2361 // Allocate encoding buffer
2362 if (iff.idsig == IFF_ID_ILBM) 2362 if (iff.idsig == IFF_ID_ILBM)
2363 bufLen = (((img->width * spec->scaleX) + 15) / 16) * 2; 2363 bufLen = ((img->width * spec->scaleX + 15) / 16) * 2;
2364 else 2364 else
2365 if (iff.idsig == IFF_ID_ACBM) 2365 if (iff.idsig == IFF_ID_ACBM)
2366 bufLen = (img->width * spec->scaleX * img->height * spec->scaleY) / 8; 2366 bufLen = (img->width * spec->scaleX * img->height * spec->scaleY + 7) / 8;
2367 else 2367 else
2368 bufLen = img->width * spec->scaleX; 2368 bufLen = img->width * spec->scaleX;
2369 2369
2370 dmMsg(2, "IFF: Line/plane row size %d bytes.\n", bufLen); 2370 dmMsg(2, "IFF: Line/plane row size %d bytes.\n", bufLen);
2371 2371