extensions/pdfViewer/pdf/build/pdf.worker.js
function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
    // XXX: Lab input is in the range of [0, 100], [amin, amax], [bmin, bmax]
    // not the usual [0, 1]. If a command like setFillColor is used the src
    // values will already be within the correct range. However, if we are
    // converting an image we have to map the values to the correct range given
    // above.
    // Ls,as,bs <---> L*,a*,b* in the spec
    var Ls = src[srcOffset];
    var as = src[srcOffset + 1];
    var bs = src[srcOffset + 2];
    if (maxVal !== false) {
      Ls = decode(Ls, maxVal, 0, 100);
      as = decode(as, maxVal, cs.amin, cs.amax);
      bs = decode(bs, maxVal, cs.bmin, cs.bmax);
    }

    // Adjust limits of 'as' and 'bs'
    as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
    bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;

    // Computes intermediate variables X,Y,Z as per spec
    var M = (Ls + 16) / 116;
    var L = M + (as / 500);
    var N = M - (bs / 200);

    var X = cs.XW * fn_g(L);
    var Y = cs.YW * fn_g(M);
    var Z = cs.ZW * fn_g(N);

    var r, g, b;
    // Using different conversions for D50 and D65 white points,
    // per http://www.color.org/srgb.pdf
    if (cs.ZW < 1) {
      // Assuming D50 (X=0.9642, Y=1.00, Z=0.8249)
      r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
      g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
      b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
    } else {
      // Assuming D65 (X=0.9505, Y=1.00, Z=1.0888)
      r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
      g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
      b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
    }
    // clamp color values to [0,1] range then convert to [0,255] range.
    dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
    dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
    dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  }
function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
    // XXX: Lab input is in the range of [0, 100], [amin, amax], [bmin, bmax]
    // not the usual [0, 1]. If a command like setFillColor is used the src
    // values will already be within the correct range. However, if we are
    // converting an image we have to map the values to the correct range given
    // above.
    // Ls,as,bs <---> L*,a*,b* in the spec
    var Ls = src[srcOffset];
    var as = src[srcOffset + 1];
    var bs = src[srcOffset + 2];
    if (maxVal !== false) {
      Ls = decode(Ls, maxVal, 0, 100);
      as = decode(as, maxVal, cs.amin, cs.amax);
      bs = decode(bs, maxVal, cs.bmin, cs.bmax);
    }

    // Adjust limits of 'as' and 'bs'
    as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
    bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;

    // Computes intermediate variables X,Y,Z as per spec
    var M = (Ls + 16) / 116;
    var L = M + (as / 500);
    var N = M - (bs / 200);

    var X = cs.XW * fn_g(L);
    var Y = cs.YW * fn_g(M);
    var Z = cs.ZW * fn_g(N);

    var r, g, b;
    // Using different conversions for D50 and D65 white points,
    // per http://www.color.org/srgb.pdf
    if (cs.ZW < 1) {
      // Assuming D50 (X=0.9642, Y=1.00, Z=0.8249)
      r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
      g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
      b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
    } else {
      // Assuming D65 (X=0.9505, Y=1.00, Z=1.0888)
      r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
      g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
      b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
    }
    // clamp color values to [0,1] range then convert to [0,255] range.
    dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
    dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
    dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  }
function convertToRgb ( cs , src , srcOffset , maxVal , dest , destOffset ) { // XXX: Lab input is in the range of [0, 100], [amin, amax], [bmin, bmax] // not the usual [0, 1]. If a command like setFillColor is used the src // values will already be within the correct range. However, if we are // converting an image we have to map the values to the correct range given // above. // Ls,as,bs <---> L*,a*,b* in the spec var Ls = src [ srcOffset ] ; var as = src [ srcOffset + 1 ] ; var bs = src [ srcOffset + 2 ] ; if ( maxVal !== false ) { Ls = decode ( Ls , maxVal , 0 , 100 ) ; as = decode ( as , maxVal , cs . amin , cs . amax ) ; bs = decode ( bs , maxVal , cs . bmin , cs . bmax ) ; } // Adjust limits of 'as' and 'bs' as = as > cs . amax ? cs . amax : as < cs . amin ? cs . amin : as ; bs = bs > cs . bmax ? cs . bmax : bs < cs . bmin ? cs . bmin : bs ; // Computes intermediate variables X,Y,Z as per spec var M = ( Ls + 16 ) / 116 ; var L = M + ( as / 500 ) ; var N = M - ( bs / 200 ) ; var X = cs . XW * fn_g ( L ) ; var Y = cs . YW * fn_g ( M ) ; var Z = cs . ZW * fn_g ( N ) ; var r , g , b ; // Using different conversions for D50 and D65 white points, // per http://www.color.org/srgb.pdf if ( cs . ZW < 1 ) { // Assuming D50 (X=0.9642, Y=1.00, Z=0.8249) r = X * 3.1339 + Y * - 1.6170 + Z * - 0.4906 ; g = X * - 0.9785 + Y * 1.9160 + Z * 0.0333 ; b = X * 0.0720 + Y * - 0.2290 + Z * 1.4057 ; } else { // Assuming D65 (X=0.9505, Y=1.00, Z=1.0888) r = X * 3.2406 + Y * - 1.5372 + Z * - 0.4986 ; g = X * - 0.9689 + Y * 1.8758 + Z * 0.0415 ; b = X * 0.0557 + Y * - 0.2040 + Z * 1.0570 ; } // clamp color values to [0,1] range then convert to [0,255] range. dest [ destOffset ] = r <= 0 ? 0 : r >= 1 ? 255 : Math . sqrt ( r ) * 255 | 0 ; dest [ destOffset + 1 ] = g <= 0 ? 0 : g >= 1 ? 255 : Math . sqrt ( g ) * 255 | 0 ; dest [ destOffset + 2 ] = b <= 0 ? 0 : b >= 1 ? 255 : Math . sqrt ( b ) * 255 | 0 ; }
If decoding is needed maxVal should be 2^bits per component - 1.
If decoding is needed maxVal should be 2^bits per component - 1 .