comparison tools/gfxconv.c @ 931:2270d7f3af77

Refactor the DMC64Image handling to be more dynamic, and start work on allowing non 320/160 x 200 formats, and charmode based formats. There is still work to be done, and some problems to sort out.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 25 Feb 2015 19:37:59 +0200
parents 602b4aa34293
children 8fe48c08dbca
comparison
equal deleted inserted replaced
930:efbad8817b79 931:2270d7f3af77
1554 1554
1555 int main(int argc, char *argv[]) 1555 int main(int argc, char *argv[])
1556 { 1556 {
1557 FILE *inFile; 1557 FILE *inFile;
1558 const DMC64ImageFormat *cfmt; 1558 const DMC64ImageFormat *cfmt;
1559 DMC64Image cimage; 1559 DMC64Image *cimage = NULL;
1560 Uint8 *dataBuf = NULL; 1560 Uint8 *dataBuf = NULL;
1561 size_t dataSize; 1561 size_t dataSize;
1562 int i; 1562 int i;
1563 1563
1564 // Default colors 1564 // Default colors
1707 } 1707 }
1708 1708
1709 switch (optOutFormat) 1709 switch (optOutFormat)
1710 { 1710 {
1711 case FFMT_IMAGE: 1711 case FFMT_IMAGE:
1712 res = dmC64ConvertBMP2Image(&outImage, &cimage, cfmt, FALSE); 1712 res = dmC64ConvertBMP2Image(&outImage, cimage, cfmt, FALSE);
1713 1713
1714 if (res != DMERR_OK || outImage == NULL) 1714 if (res != DMERR_OK || outImage == NULL)
1715 { 1715 {
1716 dmError("Error in bitmap to image conversion.\n"); 1716 dmError("Error in bitmap to image conversion.\n");
1717 goto error; 1717 goto error;
1720 res = dmWriteImage(optOutFilename, outImage, &optSpec, optOutSubFormat, TRUE); 1720 res = dmWriteImage(optOutFilename, outImage, &optSpec, optOutSubFormat, TRUE);
1721 break; 1721 break;
1722 1722
1723 1723
1724 case FFMT_BITMAP: 1724 case FFMT_BITMAP:
1725 res = dmWriteBitmap(optOutFilename, &cimage, optOutSubFormat, TRUE); 1725 res = dmWriteBitmap(optOutFilename, cimage, optOutSubFormat, TRUE);
1726 break; 1726 break;
1727 1727
1728 case FFMT_CHAR: 1728 case FFMT_CHAR:
1729 case FFMT_SPRITE: 1729 case FFMT_SPRITE:
1730 res = dmC64ConvertBMP2Image(&outImage, &cimage, cfmt, TRUE); 1730 res = dmC64ConvertBMP2Image(&outImage, cimage, cfmt, TRUE);
1731 1731
1732 if (res != DMERR_OK || outImage == NULL) 1732 if (res != DMERR_OK || outImage == NULL)
1733 { 1733 {
1734 dmError("Error in bitmap to template image conversion.\n"); 1734 dmError("Error in bitmap to template image conversion.\n");
1735 goto error; 1735 goto error;
1801 exit(0); 1801 exit(0);
1802 return 0; 1802 return 0;
1803 1803
1804 error: 1804 error:
1805 dmFree(dataBuf); 1805 dmFree(dataBuf);
1806 dmFree(cimage);
1806 return -3; 1807 return -3;
1807 exit(3); 1808 exit(3);
1808 } 1809 }