comparison tools/libgfx.c @ 2153:7652b3fe8f30

Fix IFF and PCX checks for non-indexed images.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 04 Jun 2019 15:44:49 +0300
parents 0905b2a87cbd
children 1c111bfc17d4
comparison
equal deleted inserted replaced
2152:44d7e8e2483c 2153:7652b3fe8f30
1409 // Always force planar for PCX 1409 // Always force planar for PCX
1410 memcpy(&spec, pspec, sizeof(DMImageConvSpec)); 1410 memcpy(&spec, pspec, sizeof(DMImageConvSpec));
1411 spec.planar = TRUE; 1411 spec.planar = TRUE;
1412 1412
1413 // XXX: 24bit PCX does not work yet .. 1413 // XXX: 24bit PCX does not work yet ..
1414 if (spec.format != DM_COLFMT_PALETTE && 1414 if ((img->format != DM_COLFMT_PALETTE && img->format != DM_COLFMT_GRAYSCALE) ||
1415 spec.format != DM_COLFMT_GRAYSCALE) 1415 (spec.format != DM_COLFMT_PALETTE && spec.format != DM_COLFMT_GRAYSCALE))
1416 { 1416 {
1417 return dmError(DMERR_NOT_SUPPORTED, 1417 return dmError(DMERR_NOT_SUPPORTED,
1418 "24bit PCX not supported yet.\n"); 1418 "24bit PCX not supported yet.\n");
1419 } 1419 }
1420 1420
2620 Uint8 *buf = NULL; 2620 Uint8 *buf = NULL;
2621 size_t bufLen; 2621 size_t bufLen;
2622 int res = DMERR_OK; 2622 int res = DMERR_OK;
2623 2623
2624 // XXX: Non-paletted IFF not supported! 2624 // XXX: Non-paletted IFF not supported!
2625 if (spec->format != DM_COLFMT_PALETTE) 2625 if ((img->format != DM_COLFMT_PALETTE && img->format != DM_COLFMT_GRAYSCALE) ||
2626 (spec->format != DM_COLFMT_PALETTE && spec->format != DM_COLFMT_GRAYSCALE))
2626 { 2627 {
2627 return dmError(DMERR_NOT_SUPPORTED, 2628 return dmError(DMERR_NOT_SUPPORTED,
2628 "Non-paletted IFF is not supported.\n"); 2629 "Non-paletted IFF is not supported.\n");
2629 } 2630 }
2630 2631
2700 goto out; 2701 goto out;
2701 2702
2702 // 2703 //
2703 // CMAP 2704 // CMAP
2704 // 2705 //
2705 if (img->pal->ncolors > 0 && spec->format == DM_COLFMT_PALETTE) 2706 if (spec->format == DM_COLFMT_PALETTE &&
2707 img->pal != NULL &&
2708 img->pal->ncolors > 0)
2706 { 2709 {
2707 if ((res = dmWriteIFFChunkHdr(fp, &iff.chCMAP, IFF_ID_CMAP)) != DMERR_OK) 2710 if ((res = dmWriteIFFChunkHdr(fp, &iff.chCMAP, IFF_ID_CMAP)) != DMERR_OK)
2708 goto out; 2711 goto out;
2709 2712
2710 if ((res = dmPaletteWriteData(fp, img->pal, img->pal->ncolors, -1)) != DMERR_OK) 2713 if ((res = dmPaletteWriteData(fp, img->pal, img->pal->ncolors, -1)) != DMERR_OK)