@@ -334,7 +334,7 @@ namespace PnnLABQuant
334334
335335 unsigned short PnnLABQuantizer::nearestColorIndex (const ARGB * pPalette, const UINT nMaxColors, ARGB argb, const UINT pos)
336336 {
337- int offset = GetARGBIndex (argb, hasSemiTransparency, hasAlpha ());
337+ int offset = nMaxColors > 32 ? argb : GetARGBIndex (argb, hasSemiTransparency, hasAlpha ());
338338 auto got = nearestMap.find (offset);
339339 if (got != nearestMap.end ())
340340 return got->second ;
@@ -424,7 +424,7 @@ namespace PnnLABQuant
424424
425425 unsigned short PnnLABQuantizer::hybridColorIndex (const ARGB * pPalette, const UINT nMaxColors, ARGB argb, const UINT pos)
426426 {
427- int offset = GetARGBIndex (argb, hasSemiTransparency, hasAlpha ());
427+ int offset = nMaxColors > 32 ? argb : GetARGBIndex (argb, hasSemiTransparency, hasAlpha ());
428428 auto got = nearestMap.find (offset);
429429 if (got != nearestMap.end ())
430430 return got->second ;
@@ -491,7 +491,7 @@ namespace PnnLABQuant
491491 return nearestColorIndex (pPalette, nMaxColors, argb, pos);
492492
493493 vector<unsigned short > closest (4 );
494- int offset = GetARGBIndex (argb, hasSemiTransparency, hasAlpha ());
494+ int offset = nMaxColors > 32 ? argb : GetARGBIndex (argb, hasSemiTransparency, hasAlpha ());
495495 auto got = closestMap.find (offset);
496496 if (got == closestMap.end ()) {
497497 closest[2 ] = closest[3 ] = USHRT_MAX ;
0 commit comments