diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2022-03-05 17:37:10 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2022-03-05 17:37:10 +0000 |
commit | 5bce2f8f68066861d18616b5a01803a07d04df03 (patch) | |
tree | 9259930306b381e863df849bf9a576b277868c0d | |
parent | dff8f603fe111254a0bf3d12adfb9c6d2fec0b36 (diff) | |
download | netpbm-mirror-5bce2f8f68066861d18616b5a01803a07d04df03.tar.gz netpbm-mirror-5bce2f8f68066861d18616b5a01803a07d04df03.tar.xz netpbm-mirror-5bce2f8f68066861d18616b5a01803a07d04df03.zip |
Fix assertion
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4291 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r-- | converter/other/pamtoxvmini.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/converter/other/pamtoxvmini.c b/converter/other/pamtoxvmini.c index 924611ba..e2e841da 100644 --- a/converter/other/pamtoxvmini.c +++ b/converter/other/pamtoxvmini.c @@ -100,6 +100,8 @@ findClosestColor(struct pam * const pamP, /*---------------------------------------------------------------------------- Find the color in the palette *xvPaletteP that is closest to the color 'tuple' and return its index in the palette. + + *pamP gives the format of 'tuple', which must be RGB with maxval 255. -----------------------------------------------------------------------------*/ unsigned int paletteIndex; unsigned int bestPaletteIndex; @@ -155,11 +157,16 @@ getPaletteIndexThroughCache(struct pam * const pamP, int found; int paletteIndex; + /* As required by findClosestColor(): */ + assert(pamP->depth >= 3); + assert(pamP->maxval == 255); + pnm_lookuptuple(pamP, paletteHash, tuple, &found, &paletteIndex); if (found) *paletteIndexP = paletteIndex; else { int fits; + findClosestColor(pamP, tuple, xvPaletteP, paletteIndexP); pnm_addtotuplehash(pamP, paletteHash, tuple, *paletteIndexP, &fits); @@ -198,6 +205,7 @@ writeXvRaster(struct pam * const pamP, scaledPam = *pamP; scaledPam.maxval = 255; + scaledPam.depth = MAX(3, pamP->depth); for (row = 0; row < pamP->height; ++row) { unsigned int col; |