diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc index 0bafb6d..0f1d942 100644 --- a/poppler/GfxState.cc +++ b/poppler/GfxState.cc @@ -1649,7 +1649,7 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, OutputDev *out, int recu obj1.free(); #ifdef USE_CMS // check cache - if (out && iccProfileStreamA.num > 0) { + if (out && iccProfileStreamA.num > 0) { GfxICCBasedColorSpaceKey k(iccProfileStreamA.num, iccProfileStreamA.gen); GfxICCBasedColorSpaceItem *item = static_cast(out->getIccColorSpaceCache()->lookup(k)); if (item != NULL) @@ -5301,6 +5301,16 @@ GfxImageColorMap::GfxImageColorMap(int bitsA, Object *decode, } } break; +#ifdef USE_CMS + case csICCBased: + for (k = nComps; k < nComps + 3; ++k) { + lookup2[k] = (GfxColorComp *)gmallocn(maxPixel + 1, + sizeof(GfxColorComp)); + for (i = 0; i < maxPixel + 1; i++) { + lookup2[k][i] = -1; + } + } +#endif default: if (colorSpace->useGetGrayLine() || colorSpace->useGetRGBLine()) { byte_lookup = (Guchar *)gmallocn ((maxPixel + 1), nComps); @@ -5415,10 +5425,34 @@ void GfxImageColorMap::getRGB(Guchar *x, GfxRGB *rgb) { } colorSpace2->getRGB(&color, rgb); } else { +#ifdef USE_CMS + if (colorSpace->getMode() == csICCBased && nComps == 3) { + GBool useCache = gTrue; + for (i = 0; i < nComps; ++i) { + if (lookup2[nComps+i][x[i]] == -1) { + useCache = gFalse; + break; + } + } + if (useCache) { + rgb->r = lookup2[nComps][x[0]]; + rgb->g = lookup2[nComps+1][x[1]]; + rgb->b = lookup2[nComps+2][x[2]]; + return; + } + } +#endif for (i = 0; i < nComps; ++i) { color.c[i] = lookup2[i][x[i]]; } colorSpace->getRGB(&color, rgb); +#ifdef USE_CMS + if (colorSpace->getMode() == csICCBased && nComps == 3) { + lookup2[nComps][x[0]] = rgb->r; + lookup2[nComps+1][x[1]] = rgb->g; + lookup2[nComps+2][x[2]] = rgb->b; + } +#endif } }