Mercurial > hg > dmlib
changeset 2154:1c111bfc17d4
Add check to PNG and PPM output as well.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 04 Jun 2019 15:56:10 +0300 |
parents | 7652b3fe8f30 |
children | 28b7a842181f |
files | tools/libgfx.c |
diffstat | 1 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/libgfx.c Tue Jun 04 15:44:49 2019 +0300 +++ b/tools/libgfx.c Tue Jun 04 15:56:10 2019 +0300 @@ -770,6 +770,14 @@ DMImageConvSpec tmpSpec; char *tmpFmt; + // Check if we can do this + if ((spec->format == DM_COLFMT_PALETTE || spec->format == DM_COLFMT_GRAYSCALE) && + img->format != spec->format) + { + return dmError(DMERR_NOT_SUPPORTED, + "Conversion of non-indexed image to indexed not supported yet.\n"); + } + memcpy(&tmpSpec, spec, sizeof(DMImageConvSpec)); switch (spec->format) @@ -972,6 +980,14 @@ png_infop info_ptr = NULL; int fmt, res; + // Check if we can do this + if ((spec->format == DM_COLFMT_PALETTE || spec->format == DM_COLFMT_GRAYSCALE) && + img->format != spec->format) + { + return dmError(DMERR_NOT_SUPPORTED, + "Conversion of non-indexed image to indexed not supported yet.\n"); + } + // Create PNG structures png_ptr = png_create_write_struct( PNG_LIBPNG_VER_STRING,