Back to index

tetex-bin  3.0
Public Member Functions | Static Public Member Functions | Private Attributes
GfxLabColorSpace Class Reference

#include <GfxState.h>

Inheritance diagram for GfxLabColorSpace:
Inheritance graph
[legend]
Collaboration diagram for GfxLabColorSpace:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 GfxLabColorSpace ()
virtual ~GfxLabColorSpace ()
virtual GfxColorSpacecopy ()
virtual GfxColorSpaceMode getMode ()
virtual void getGray (GfxColor *color, double *gray)
virtual void getRGB (GfxColor *color, GfxRGB *rgb)
virtual void getCMYK (GfxColor *color, GfxCMYK *cmyk)
virtual int getNComps ()
virtual void getDefaultRanges (double *decodeLow, double *decodeRange, int maxImgPixel)
double getWhiteX ()
double getWhiteY ()
double getWhiteZ ()
double getBlackX ()
double getBlackY ()
double getBlackZ ()
double getAMin ()
double getAMax ()
double getBMin ()
double getBMax ()

Static Public Member Functions

static GfxColorSpaceparse (Array *arr)
static GfxColorSpaceparse (Object *csObj)
static int getNumColorSpaceModes ()
static char * getColorSpaceModeName (int idx)

Private Attributes

double whiteX
double whiteY
double whiteZ
double blackX
double blackY
double blackZ
double aMin
double aMax
double bMin
double bMax
double kr
double kg
double kb

Detailed Description

Definition at line 251 of file GfxState.h.


Constructor & Destructor Documentation

Definition at line 475 of file GfxState.cc.

                                   {
  whiteX = whiteY = whiteZ = 1;
  blackX = blackY = blackZ = 0;
  aMin = bMin = -100;
  aMax = bMax = 100;
}

Here is the caller graph for this function:

Definition at line 482 of file GfxState.cc.

                                    {
}

Member Function Documentation

Implements GfxColorSpace.

Definition at line 485 of file GfxState.cc.

                                      {
  GfxLabColorSpace *cs;

  cs = new GfxLabColorSpace();
  cs->whiteX = whiteX;
  cs->whiteY = whiteY;
  cs->whiteZ = whiteZ;
  cs->blackX = blackX;
  cs->blackY = blackY;
  cs->blackZ = blackZ;
  cs->aMin = aMin;
  cs->aMax = aMax;
  cs->bMin = bMin;
  cs->bMax = bMax;
  cs->kr = kr;
  cs->kg = kg;
  cs->kb = kb;
  return cs;
}

Here is the call graph for this function:

double GfxLabColorSpace::getAMax ( ) [inline]

Definition at line 279 of file GfxState.h.

{ return aMax; }
double GfxLabColorSpace::getAMin ( ) [inline]

Definition at line 278 of file GfxState.h.

{ return aMin; }
double GfxLabColorSpace::getBlackX ( ) [inline]

Definition at line 275 of file GfxState.h.

{ return blackX; }
double GfxLabColorSpace::getBlackY ( ) [inline]

Definition at line 276 of file GfxState.h.

{ return blackY; }
double GfxLabColorSpace::getBlackZ ( ) [inline]

Definition at line 277 of file GfxState.h.

{ return blackZ; }
double GfxLabColorSpace::getBMax ( ) [inline]

Definition at line 281 of file GfxState.h.

{ return bMax; }
double GfxLabColorSpace::getBMin ( ) [inline]

Definition at line 280 of file GfxState.h.

{ return bMin; }
void GfxLabColorSpace::getCMYK ( GfxColor color,
GfxCMYK cmyk 
) [virtual]

Implements GfxColorSpace.

Definition at line 619 of file GfxState.cc.

                                                             {
  GfxRGB rgb;
  double c, m, y, k;

  getRGB(color, &rgb);
  c = clip01(1 - rgb.r);
  m = clip01(1 - rgb.g);
  y = clip01(1 - rgb.b);
  k = c;
  if (m < k) {
    k = m;
  }
  if (y < k) {
    k = y;
  }
  cmyk->c = c - k;
  cmyk->m = m - k;
  cmyk->y = y - k;
  cmyk->k = k;
}

Here is the call graph for this function:

char * GfxColorSpace::getColorSpaceModeName ( int  idx) [static, inherited]

Definition at line 124 of file GfxState.cc.

                                                  {
  return gfxColorSpaceModeNames[idx];
}
void GfxLabColorSpace::getDefaultRanges ( double *  decodeLow,
double *  decodeRange,
int  maxImgPixel 
) [virtual]

Reimplemented from GfxColorSpace.

Definition at line 640 of file GfxState.cc.

                                                    {
  decodeLow[0] = 0;
  decodeRange[0] = 100;
  decodeLow[1] = aMin;
  decodeRange[1] = aMax - aMin;
  decodeLow[2] = bMin;
  decodeRange[2] = bMax - bMin;
}
void GfxLabColorSpace::getGray ( GfxColor color,
double *  gray 
) [virtual]

Implements GfxColorSpace.

Definition at line 573 of file GfxState.cc.

                                                            {
  GfxRGB rgb;

  getRGB(color, &rgb);
  *gray = clip01(0.299 * rgb.r +
               0.587 * rgb.g +
               0.114 * rgb.b);
}

Here is the call graph for this function:

virtual GfxColorSpaceMode GfxLabColorSpace::getMode ( ) [inline, virtual]

Implements GfxColorSpace.

Definition at line 257 of file GfxState.h.

{ return csLab; }
virtual int GfxLabColorSpace::getNComps ( ) [inline, virtual]

Implements GfxColorSpace.

Definition at line 266 of file GfxState.h.

{ return 3; }
int GfxColorSpace::getNumColorSpaceModes ( ) [static, inherited]

Definition at line 120 of file GfxState.cc.

                                         {
  return nGfxColorSpaceModes;
}
void GfxLabColorSpace::getRGB ( GfxColor color,
GfxRGB rgb 
) [virtual]

Implements GfxColorSpace.

Definition at line 582 of file GfxState.cc.

                                                          {
  double X, Y, Z;
  double t1, t2;
  double r, g, b;

  // convert L*a*b* to CIE 1931 XYZ color space
  t1 = (color->c[0] + 16) / 116;
  t2 = t1 + color->c[1] / 500;
  if (t2 >= (6.0 / 29.0)) {
    X = t2 * t2 * t2;
  } else {
    X = (108.0 / 841.0) * (t2 - (4.0 / 29.0));
  }
  X *= whiteX;
  if (t1 >= (6.0 / 29.0)) {
    Y = t1 * t1 * t1;
  } else {
    Y = (108.0 / 841.0) * (t1 - (4.0 / 29.0));
  }
  Y *= whiteY;
  t2 = t1 - color->c[2] / 200;
  if (t2 >= (6.0 / 29.0)) {
    Z = t2 * t2 * t2;
  } else {
    Z = (108.0 / 841.0) * (t2 - (4.0 / 29.0));
  }
  Z *= whiteZ;

  // convert XYZ to RGB, including gamut mapping and gamma correction
  r = xyzrgb[0][0] * X + xyzrgb[0][1] * Y + xyzrgb[0][2] * Z;
  g = xyzrgb[1][0] * X + xyzrgb[1][1] * Y + xyzrgb[1][2] * Z;
  b = xyzrgb[2][0] * X + xyzrgb[2][1] * Y + xyzrgb[2][2] * Z;
  rgb->r = pow(clip01(r * kr), 0.5);
  rgb->g = pow(clip01(g * kg), 0.5);
  rgb->b = pow(clip01(b * kb), 0.5);
}

Here is the call graph for this function:

Here is the caller graph for this function:

double GfxLabColorSpace::getWhiteX ( ) [inline]

Definition at line 272 of file GfxState.h.

{ return whiteX; }
double GfxLabColorSpace::getWhiteY ( ) [inline]

Definition at line 273 of file GfxState.h.

{ return whiteY; }
double GfxLabColorSpace::getWhiteZ ( ) [inline]

Definition at line 274 of file GfxState.h.

{ return whiteZ; }
GfxColorSpace * GfxColorSpace::parse ( Object csObj) [static, inherited]

Definition at line 59 of file GfxState.cc.

                                                 {
  GfxColorSpace *cs;
  Object obj1;

  cs = NULL;
  if (csObj->isName()) {
    if (csObj->isName("DeviceGray") || csObj->isName("G")) {
      cs = new GfxDeviceGrayColorSpace();
    } else if (csObj->isName("DeviceRGB") || csObj->isName("RGB")) {
      cs = new GfxDeviceRGBColorSpace();
    } else if (csObj->isName("DeviceCMYK") || csObj->isName("CMYK")) {
      cs = new GfxDeviceCMYKColorSpace();
    } else if (csObj->isName("Pattern")) {
      cs = new GfxPatternColorSpace(NULL);
    } else {
      error(-1, "Bad color space '%s'", csObj->getName());
    }
  } else if (csObj->isArray()) {
    csObj->arrayGet(0, &obj1);
    if (obj1.isName("DeviceGray") || obj1.isName("G")) {
      cs = new GfxDeviceGrayColorSpace();
    } else if (obj1.isName("DeviceRGB") || obj1.isName("RGB")) {
      cs = new GfxDeviceRGBColorSpace();
    } else if (obj1.isName("DeviceCMYK") || obj1.isName("CMYK")) {
      cs = new GfxDeviceCMYKColorSpace();
    } else if (obj1.isName("CalGray")) {
      cs = GfxCalGrayColorSpace::parse(csObj->getArray());
    } else if (obj1.isName("CalRGB")) {
      cs = GfxCalRGBColorSpace::parse(csObj->getArray());
    } else if (obj1.isName("Lab")) {
      cs = GfxLabColorSpace::parse(csObj->getArray());
    } else if (obj1.isName("ICCBased")) {
      cs = GfxICCBasedColorSpace::parse(csObj->getArray());
    } else if (obj1.isName("Indexed") || obj1.isName("I")) {
      cs = GfxIndexedColorSpace::parse(csObj->getArray());
    } else if (obj1.isName("Separation")) {
      cs = GfxSeparationColorSpace::parse(csObj->getArray());
    } else if (obj1.isName("DeviceN")) {
      cs = GfxDeviceNColorSpace::parse(csObj->getArray());
    } else if (obj1.isName("Pattern")) {
      cs = GfxPatternColorSpace::parse(csObj->getArray());
    } else {
      error(-1, "Bad color space");
    }
    obj1.free();
  } else {
    error(-1, "Bad color space - expected name or array");
  }
  return cs;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 505 of file GfxState.cc.

                                                 {
  GfxLabColorSpace *cs;
  Object obj1, obj2, obj3;

  arr->get(1, &obj1);
  if (!obj1.isDict()) {
    error(-1, "Bad Lab color space");
    obj1.free();
    return NULL;
  }
  cs = new GfxLabColorSpace();
  if (obj1.dictLookup("WhitePoint", &obj2)->isArray() &&
      obj2.arrayGetLength() == 3) {
    obj2.arrayGet(0, &obj3);
    cs->whiteX = obj3.getNum();
    obj3.free();
    obj2.arrayGet(1, &obj3);
    cs->whiteY = obj3.getNum();
    obj3.free();
    obj2.arrayGet(2, &obj3);
    cs->whiteZ = obj3.getNum();
    obj3.free();
  }
  obj2.free();
  if (obj1.dictLookup("BlackPoint", &obj2)->isArray() &&
      obj2.arrayGetLength() == 3) {
    obj2.arrayGet(0, &obj3);
    cs->blackX = obj3.getNum();
    obj3.free();
    obj2.arrayGet(1, &obj3);
    cs->blackY = obj3.getNum();
    obj3.free();
    obj2.arrayGet(2, &obj3);
    cs->blackZ = obj3.getNum();
    obj3.free();
  }
  obj2.free();
  if (obj1.dictLookup("Range", &obj2)->isArray() &&
      obj2.arrayGetLength() == 4) {
    obj2.arrayGet(0, &obj3);
    cs->aMin = obj3.getNum();
    obj3.free();
    obj2.arrayGet(1, &obj3);
    cs->aMax = obj3.getNum();
    obj3.free();
    obj2.arrayGet(2, &obj3);
    cs->bMin = obj3.getNum();
    obj3.free();
    obj2.arrayGet(3, &obj3);
    cs->bMax = obj3.getNum();
    obj3.free();
  }
  obj2.free();
  obj1.free();

  cs->kr = 1 / (xyzrgb[0][0] * cs->whiteX +
              xyzrgb[0][1] * cs->whiteY +
              xyzrgb[0][2] * cs->whiteZ);
  cs->kg = 1 / (xyzrgb[1][0] * cs->whiteX +
              xyzrgb[1][1] * cs->whiteY +
              xyzrgb[1][2] * cs->whiteZ);
  cs->kb = 1 / (xyzrgb[2][0] * cs->whiteX +
              xyzrgb[2][1] * cs->whiteY +
              xyzrgb[2][2] * cs->whiteZ);

  return cs;
}

Here is the call graph for this function:


Member Data Documentation

double GfxLabColorSpace::aMax [private]

Definition at line 287 of file GfxState.h.

double GfxLabColorSpace::aMin [private]

Definition at line 287 of file GfxState.h.

double GfxLabColorSpace::blackX [private]

Definition at line 286 of file GfxState.h.

double GfxLabColorSpace::blackY [private]

Definition at line 286 of file GfxState.h.

double GfxLabColorSpace::blackZ [private]

Definition at line 286 of file GfxState.h.

double GfxLabColorSpace::bMax [private]

Definition at line 287 of file GfxState.h.

double GfxLabColorSpace::bMin [private]

Definition at line 287 of file GfxState.h.

double GfxLabColorSpace::kb [private]

Definition at line 288 of file GfxState.h.

double GfxLabColorSpace::kg [private]

Definition at line 288 of file GfxState.h.

double GfxLabColorSpace::kr [private]

Definition at line 288 of file GfxState.h.

double GfxLabColorSpace::whiteX [private]

Definition at line 285 of file GfxState.h.

double GfxLabColorSpace::whiteY [private]

Definition at line 285 of file GfxState.h.

double GfxLabColorSpace::whiteZ [private]

Definition at line 285 of file GfxState.h.


The documentation for this class was generated from the following files: