Back to index

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

#include <GfxState.h>

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

List of all members.

Public Member Functions

 GfxIndexedColorSpace (GfxColorSpace *baseA, int indexHighA)
virtual ~GfxIndexedColorSpace ()
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)
GfxColorSpacegetBase ()
int getIndexHigh ()
GuchargetLookup ()
GfxColormapColorToBase (GfxColor *color, GfxColor *baseColor)

Static Public Member Functions

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

Private Attributes

GfxColorSpacebase
int indexHigh
Gucharlookup

Detailed Description

Definition at line 332 of file GfxState.h.


Constructor & Destructor Documentation

Definition at line 786 of file GfxState.cc.

                                                      {
  base = baseA;
  indexHigh = indexHighA;
  lookup = (Guchar *)gmalloc((indexHigh + 1) * base->getNComps() *
                          sizeof(Guchar));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 794 of file GfxState.cc.

                                            {
  delete base;
  gfree(lookup);
}

Here is the call graph for this function:


Member Function Documentation

Implements GfxColorSpace.

Definition at line 799 of file GfxState.cc.

                                          {
  GfxIndexedColorSpace *cs;

  cs = new GfxIndexedColorSpace(base->copy(), indexHigh);
  memcpy(cs->lookup, lookup,
        (indexHigh + 1) * base->getNComps() * sizeof(Guchar));
  return cs;
}

Here is the call graph for this function:

Definition at line 353 of file GfxState.h.

{ return base; }

Here is the caller graph for this function:

void GfxIndexedColorSpace::getCMYK ( GfxColor color,
GfxCMYK cmyk 
) [virtual]

Implements GfxColorSpace.

Definition at line 911 of file GfxState.cc.

                                                                 {
  GfxColor color2;

  base->getCMYK(mapColorToBase(color, &color2), cmyk);
}

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 GfxIndexedColorSpace::getDefaultRanges ( double *  decodeLow,
double *  decodeRange,
int  maxImgPixel 
) [virtual]

Reimplemented from GfxColorSpace.

Definition at line 917 of file GfxState.cc.

                                                        {
  decodeLow[0] = 0;
  decodeRange[0] = maxImgPixel;
}
void GfxIndexedColorSpace::getGray ( GfxColor color,
double *  gray 
) [virtual]

Implements GfxColorSpace.

Definition at line 899 of file GfxState.cc.

                                                                {
  GfxColor color2;

  base->getGray(mapColorToBase(color, &color2), gray);
}

Here is the call graph for this function:

Definition at line 354 of file GfxState.h.

{ return indexHigh; }

Here is the caller graph for this function:

Definition at line 355 of file GfxState.h.

{ return lookup; }

Here is the caller graph for this function:

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

Implements GfxColorSpace.

Definition at line 338 of file GfxState.h.

{ return csIndexed; }
virtual int GfxIndexedColorSpace::getNComps ( ) [inline, virtual]

Implements GfxColorSpace.

Definition at line 347 of file GfxState.h.

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

Definition at line 120 of file GfxState.cc.

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

Implements GfxColorSpace.

Definition at line 905 of file GfxState.cc.

                                                              {
  GfxColor color2;

  base->getRGB(mapColorToBase(color, &color2), rgb);
}

Here is the call graph for this function:

Definition at line 884 of file GfxState.cc.

                                                               {
  Guchar *p;
  double low[gfxColorMaxComps], range[gfxColorMaxComps];
  int n, i;

  n = base->getNComps();
  base->getDefaultRanges(low, range, indexHigh);
  p = &lookup[(int)(color->c[0] + 0.5) * n];
  for (i = 0; i < n; ++i) {
    baseColor->c[i] = low[i] + (p[i] / 255.0) * range[i];
  }
  return baseColor;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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 808 of file GfxState.cc.

                                                     {
  GfxIndexedColorSpace *cs;
  GfxColorSpace *baseA;
  int indexHighA;
  Object obj1;
  int x;
  char *s;
  int n, i, j;

  if (arr->getLength() != 4) {
    error(-1, "Bad Indexed color space");
    goto err1;
  }
  arr->get(1, &obj1);
  if (!(baseA = GfxColorSpace::parse(&obj1))) {
    error(-1, "Bad Indexed color space (base color space)");
    goto err2;
  }
  obj1.free();
  if (!arr->get(2, &obj1)->isInt()) {
    error(-1, "Bad Indexed color space (hival)");
    delete baseA;
    goto err2;
  }
  indexHighA = obj1.getInt();
  if (indexHighA < 0 || indexHighA > 255) {
    // the PDF spec requires indexHigh to be in [0,255] -- allowing
    // values larger than 255 creates a security hole: if nComps *
    // indexHigh is greater than 2^31, the loop below may overwrite
    // past the end of the array
    error(-1, "Bad Indexed color space (invalid indexHigh value)");
    delete baseA;
    goto err2;
  }
  obj1.free();
  cs = new GfxIndexedColorSpace(baseA, indexHighA);
  arr->get(3, &obj1);
  n = baseA->getNComps();
  if (obj1.isStream()) {
    obj1.streamReset();
    for (i = 0; i <= indexHighA; ++i) {
      for (j = 0; j < n; ++j) {
       if ((x = obj1.streamGetChar()) == EOF) {
         error(-1, "Bad Indexed color space (lookup table stream too short)");
         goto err3;
       }
       cs->lookup[i*n + j] = (Guchar)x;
      }
    }
    obj1.streamClose();
  } else if (obj1.isString()) {
    if (obj1.getString()->getLength() < (indexHighA + 1) * n) {
      error(-1, "Bad Indexed color space (lookup table string too short)");
      goto err3;
    }
    s = obj1.getString()->getCString();
    for (i = 0; i <= indexHighA; ++i) {
      for (j = 0; j < n; ++j) {
       cs->lookup[i*n + j] = (Guchar)*s++;
      }
    }
  } else {
    error(-1, "Bad Indexed color space (lookup table)");
    goto err3;
  }
  obj1.free();
  return cs;

 err3:
  delete cs;
 err2:
  obj1.free();
 err1:
  return NULL;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 360 of file GfxState.h.

Definition at line 361 of file GfxState.h.

Definition at line 362 of file GfxState.h.


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