Mercurial > hg > dmlib
comparison tools/libgfx.c @ 1800:45e7688336dc
Fix checks for NULL palette in index/palette images. Also improve error
messages.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 14 Jun 2018 12:42:29 +0300 |
parents | 881a3fc421d8 |
children | 0562dd55a1f6 |
comparison
equal
deleted
inserted
replaced
1799:708d333734f9 | 1800:45e7688336dc |
---|---|
949 memcpy(&spec, pspec, sizeof(DMImageConvSpec)); | 949 memcpy(&spec, pspec, sizeof(DMImageConvSpec)); |
950 spec.planar = TRUE; | 950 spec.planar = TRUE; |
951 | 951 |
952 // XXX: 24bit PCX does not work yet .. | 952 // XXX: 24bit PCX does not work yet .. |
953 if (!spec.paletted) | 953 if (!spec.paletted) |
954 return DMERR_NOT_SUPPORTED; | 954 { |
955 return dmError(DMERR_NOT_SUPPORTED, | |
956 "24bit PCX not supported yet.\n"); | |
957 } | |
958 | |
959 if (spec.paletted && img->pal == NULL) | |
960 { | |
961 return dmError(DMERR_NULLPTR, | |
962 "Image spec says paletted/indexed image, but palette pointer is NULL.\n"); | |
963 } | |
955 | 964 |
956 // Create output file | 965 // Create output file |
957 pcx.buf = NULL; | 966 pcx.buf = NULL; |
958 pcx.header = &hdr; | 967 pcx.header = &hdr; |
959 pcx.fp = fp; | 968 pcx.fp = fp; |
960 | 969 |
961 // Create PCX header | 970 // Create PCX header |
962 dmMemset(&hdr, 0, sizeof(hdr)); | 971 dmMemset(&hdr, 0, sizeof(hdr)); |
963 if (spec.paletted && img->pal != NULL) | 972 if (spec.paletted) |
964 { | 973 { |
965 for (int i = 0; i < (img->ncolors > DMPCX_PAL_COLORS ? DMPCX_PAL_COLORS : img->ncolors); i++) | 974 for (int i = 0; i < (img->ncolors > DMPCX_PAL_COLORS ? DMPCX_PAL_COLORS : img->ncolors); i++) |
966 { | 975 { |
967 hdr.colorMap[i].r = img->pal[i].r; | 976 hdr.colorMap[i].r = img->pal[i].r; |
968 hdr.colorMap[i].g = img->pal[i].g; | 977 hdr.colorMap[i].g = img->pal[i].g; |