# HG changeset patch # User Matti Hamalainen # Date 1559652970 -10800 # Node ID 1c111bfc17d4ad9660ecb3003874b38bf62ba9ef # Parent 7652b3fe8f309ba641195bcb30e0d87fa6854ecc Add check to PNG and PPM output as well. diff -r 7652b3fe8f30 -r 1c111bfc17d4 tools/libgfx.c --- 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,