Mercurial > hg > dmlib
comparison tools/gfxconv.c @ 2256:fe974f670d1d
Rename a variable.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 15 Jun 2019 22:53:25 +0300 |
parents | 65a2c2e99c81 |
children | 48b48251610a |
comparison
equal
deleted
inserted
replaced
2255:92385f9b7384 | 2256:fe974f670d1d |
---|---|
1660 int dmWriteSpritesAndChars(const char *filename, DMImage *image, int outFormat, const BOOL multicolor) | 1660 int dmWriteSpritesAndChars(const char *filename, DMImage *image, int outFormat, const BOOL multicolor) |
1661 { | 1661 { |
1662 int ret = DMERR_OK; | 1662 int ret = DMERR_OK; |
1663 int outBlockW, outBlockH, bx, by; | 1663 int outBlockW, outBlockH, bx, by; |
1664 FILE *outFile = NULL; | 1664 FILE *outFile = NULL; |
1665 Uint8 *buf = NULL; | 1665 Uint8 *tmpBuf = NULL; |
1666 size_t outBufSize; | 1666 size_t outBufSize; |
1667 char *outType; | 1667 char *outType; |
1668 | 1668 |
1669 switch (outFormat) | 1669 switch (outFormat) |
1670 { | 1670 { |
1702 dmErrorMsg("Could not open '%s' for writing, %d: %s.\n", | 1702 dmErrorMsg("Could not open '%s' for writing, %d: %s.\n", |
1703 filename, ret, dmErrorStr(ret)); | 1703 filename, ret, dmErrorStr(ret)); |
1704 goto error; | 1704 goto error; |
1705 } | 1705 } |
1706 | 1706 |
1707 if ((buf = dmMalloc(outBufSize)) == NULL) | 1707 if ((tmpBuf = dmMalloc(outBufSize)) == NULL) |
1708 { | 1708 { |
1709 dmErrorMsg("Could not allocate %d bytes for conversion buffer.\n", | 1709 dmErrorMsg("Could not allocate %d bytes for conversion buffer.\n", |
1710 outBufSize); | 1710 outBufSize); |
1711 goto error; | 1711 goto error; |
1712 } | 1712 } |
1718 for (bx = 0; bx < outBlockW; bx++) | 1718 for (bx = 0; bx < outBlockW; bx++) |
1719 { | 1719 { |
1720 switch (outFormat) | 1720 switch (outFormat) |
1721 { | 1721 { |
1722 case FFMT_CHAR: | 1722 case FFMT_CHAR: |
1723 if (!dmConvertImage2Char(buf, image, | 1723 if (!dmConvertImage2Char(tmpBuf, image, |
1724 bx * D64_CHR_WIDTH_PX, by * D64_CHR_HEIGHT_PX, | 1724 bx * D64_CHR_WIDTH_PX, by * D64_CHR_HEIGHT_PX, |
1725 multicolor)) | 1725 multicolor)) |
1726 { | 1726 { |
1727 ret = DMERR_DATA_ERROR; | 1727 ret = DMERR_DATA_ERROR; |
1728 goto error; | 1728 goto error; |
1729 } | 1729 } |
1730 break; | 1730 break; |
1731 | 1731 |
1732 case FFMT_SPRITE: | 1732 case FFMT_SPRITE: |
1733 if (!dmConvertImage2Sprite(buf, image, | 1733 if (!dmConvertImage2Sprite(tmpBuf, image, |
1734 bx * D64_SPR_WIDTH_PX, by * D64_SPR_HEIGHT_PX, | 1734 bx * D64_SPR_WIDTH_PX, by * D64_SPR_HEIGHT_PX, |
1735 multicolor)) | 1735 multicolor)) |
1736 { | 1736 { |
1737 ret = DMERR_DATA_ERROR; | 1737 ret = DMERR_DATA_ERROR; |
1738 goto error; | 1738 goto error; |
1739 } | 1739 } |
1740 break; | 1740 break; |
1741 } | 1741 } |
1742 | 1742 |
1743 if (!dm_fwrite_str(outFile, buf, outBufSize)) | 1743 if (!dm_fwrite_str(outFile, tmpBuf, outBufSize)) |
1744 { | 1744 { |
1745 ret = dmGetErrno(); | 1745 ret = dmGetErrno(); |
1746 dmError(ret, "Error writing data block %d,%d to '%s', %d: %s\n", | 1746 dmError(ret, "Error writing data block %d,%d to '%s', %d: %s\n", |
1747 bx, by, filename, ret, dmErrorStr(ret)); | 1747 bx, by, filename, ret, dmErrorStr(ret)); |
1748 goto error; | 1748 goto error; |
1749 } | 1749 } |
1750 } | 1750 } |
1751 | 1751 |
1752 fclose(outFile); | |
1753 dmFree(buf); | |
1754 return 0; | |
1755 | |
1756 error: | 1752 error: |
1757 if (outFile != NULL) | 1753 if (outFile != NULL) |
1758 fclose(outFile); | 1754 fclose(outFile); |
1759 dmFree(buf); | 1755 |
1756 dmFree(tmpBuf); | |
1757 | |
1760 return ret; | 1758 return ret; |
1761 } | 1759 } |
1762 | 1760 |
1763 | 1761 |
1764 int dmDumpSpritesAndChars(const Uint8 *dataBuf, const size_t dataSize, const size_t realOffs) | 1762 int dmDumpSpritesAndChars(const Uint8 *dataBuf, const size_t dataSize, const size_t realOffs) |