Mercurial > hg > dmlib
diff tools/gfxconv.c @ 1465:88845f95e791
Change dmC64EncodeGenericBMP() to use DMGrowBuf, and make the necessary changes in gfxconv as well.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 10 May 2018 21:29:52 +0300 |
parents | 73e00bf7531c |
children | 499835ba215c |
line wrap: on
line diff
--- a/tools/gfxconv.c Thu May 10 21:28:14 2018 +0300 +++ b/tools/gfxconv.c Thu May 10 21:29:52 2018 +0300 @@ -1034,8 +1034,7 @@ int dmWriteBitmap(const char *filename, const DMC64Image *image, const DMC64ImageFormat *fmt, const BOOL enableFixUps) { FILE *outFile = NULL; - Uint8 *buf = NULL; - size_t bufSize; + DMGrowBuf buf; int res = DMERR_OK; dmMsg(1, "Converting to %s format bitmap.\n", fmt->name); @@ -1054,11 +1053,11 @@ } } - - if ((res = dmC64EncodeGenericBMP(&buf, &bufSize, image, fmt)) != DMERR_OK) + // Encode it, XXX TODO: Use proper abstraction function when it works dmC64EncodeBMP() + if ((res = dmC64EncodeGenericBMP(&buf, image, fmt)) != DMERR_OK) goto error; - dmMsg(2, "Result: %d bytes\n", bufSize); + dmMsg(2, "Result: %d bytes\n", buf.len); if ((outFile = fopen(filename, "wb")) == NULL) { @@ -1068,7 +1067,7 @@ goto error; } - if (!dm_fwrite_str(outFile, buf, bufSize)) + if (!dm_fwrite_str(outFile, buf.data, buf.len)) { res = dmGetErrno(); dmError(res, "Error writing image data to '%s', %d: %s\n", @@ -1078,7 +1077,8 @@ error: if (outFile != NULL) fclose(outFile); - dmFree(buf); + + dmGrowBufFree(&buf); return res; }