Back to index

tetex-bin  3.0
Public Member Functions | Private Member Functions | Private Attributes
JBIG2Bitmap Class Reference
Inheritance diagram for JBIG2Bitmap:
Inheritance graph
[legend]
Collaboration diagram for JBIG2Bitmap:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 JBIG2Bitmap (Guint segNumA, int wA, int hA)
virtual ~JBIG2Bitmap ()
virtual JBIG2SegmentType getType ()
JBIG2Bitmapcopy ()
JBIG2BitmapgetSlice (Guint x, Guint y, Guint wA, Guint hA)
void expand (int newH, Guint pixel)
void clearToZero ()
void clearToOne ()
int getWidth ()
int getHeight ()
int getPixel (int x, int y)
void setPixel (int x, int y)
void clearPixel (int x, int y)
void getPixelPtr (int x, int y, JBIG2BitmapPtr *ptr)
int nextPixel (JBIG2BitmapPtr *ptr)
void duplicateRow (int yDest, int ySrc)
void combine (JBIG2Bitmap *bitmap, int x, int y, Guint combOp)
GuchargetDataPtr ()
int getDataSize ()
void setSegNum (Guint segNumA)
Guint getSegNum ()

Private Member Functions

 JBIG2Bitmap (Guint segNumA, JBIG2Bitmap *bitmap)

Private Attributes

int w
int h
int line
Guchardata

Detailed Description

Definition at line 643 of file JBIG2Stream.cc.


Constructor & Destructor Documentation

JBIG2Bitmap::JBIG2Bitmap ( Guint  segNumA,
int  wA,
int  hA 
)

Definition at line 678 of file JBIG2Stream.cc.

                                                     :
  JBIG2Segment(segNumA)
{
  w = wA;
  h = hA;
  line = (wA + 7) >> 3;
  data = (Guchar *)gmalloc(h * line);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 697 of file JBIG2Stream.cc.

                          {
  gfree(data);
}

Here is the call graph for this function:

JBIG2Bitmap::JBIG2Bitmap ( Guint  segNumA,
JBIG2Bitmap bitmap 
) [private]

Definition at line 687 of file JBIG2Stream.cc.

                                                          :
  JBIG2Segment(segNumA)
{
  w = bitmap->w;
  h = bitmap->h;
  line = bitmap->line;
  data = (Guchar *)gmalloc(h * line);
  memcpy(data, bitmap->data, h * line);
}

Here is the call graph for this function:


Member Function Documentation

void JBIG2Bitmap::clearPixel ( int  x,
int  y 
) [inline]

Definition at line 661 of file JBIG2Stream.cc.

    { data[y * line + (x >> 3)] &= 0x7f7f >> (x & 7); }

Here is the caller graph for this function:

Definition at line 735 of file JBIG2Stream.cc.

                             {
  memset(data, 0xff, h * line);
}

Here is the caller graph for this function:

Definition at line 731 of file JBIG2Stream.cc.

                              {
  memset(data, 0, h * line);
}

Here is the caller graph for this function:

void JBIG2Bitmap::combine ( JBIG2Bitmap bitmap,
int  x,
int  y,
Guint  combOp 
)

Definition at line 779 of file JBIG2Stream.cc.

                                     {
  int x0, x1, y0, y1, xx, yy;
  Guchar *srcPtr, *destPtr;
  Guint src0, src1, src, dest, s1, s2, m1, m2, m3;
  GBool oneByte;

  if (y < 0) {
    y0 = -y;
  } else {
    y0 = 0;
  }
  if (y + bitmap->h > h) {
    y1 = h - y;
  } else {
    y1 = bitmap->h;
  }
  if (y0 >= y1) {
    return;
  }

  if (x >= 0) {
    x0 = x & ~7;
  } else {
    x0 = 0;
  }
  x1 = x + bitmap->w;
  if (x1 > w) {
    x1 = w;
  }
  if (x0 >= x1) {
    return;
  }

  s1 = x & 7;
  s2 = 8 - s1;
  m1 = 0xff >> (x1 & 7);
  m2 = 0xff << (((x1 & 7) == 0) ? 0 : 8 - (x1 & 7));
  m3 = (0xff >> s1) & m2;

  oneByte = x0 == ((x1 - 1) & ~7);

  for (yy = y0; yy < y1; ++yy) {

    // one byte per line -- need to mask both left and right side
    if (oneByte) {
      if (x >= 0) {
       destPtr = data + (y + yy) * line + (x >> 3);
       srcPtr = bitmap->data + yy * bitmap->line;
       dest = *destPtr;
       src1 = *srcPtr;
       switch (combOp) {
       case 0: // or
         dest |= (src1 >> s1) & m2;
         break;
       case 1: // and
         dest &= ((0xff00 | src1) >> s1) | m1;
         break;
       case 2: // xor
         dest ^= (src1 >> s1) & m2;
         break;
       case 3: // xnor
         dest ^= ((src1 ^ 0xff) >> s1) & m2;
         break;
       case 4: // replace
         dest = (dest & ~m3) | ((src1 >> s1) & m3);
         break;
       }
       *destPtr = dest;
      } else {
       destPtr = data + (y + yy) * line;
       srcPtr = bitmap->data + yy * bitmap->line + (-x >> 3);
       dest = *destPtr;
       src1 = *srcPtr;
       switch (combOp) {
       case 0: // or
         dest |= src1 & m2;
         break;
       case 1: // and
         dest &= src1 | m1;
         break;
       case 2: // xor
         dest ^= src1 & m2;
         break;
       case 3: // xnor
         dest ^= (src1 ^ 0xff) & m2;
         break;
       case 4: // replace
         dest = (src1 & m2) | (dest & m1);
         break;
       }
       *destPtr = dest;
      }

    // multiple bytes per line -- need to mask left side of left-most
    // byte and right side of right-most byte
    } else {

      // left-most byte
      if (x >= 0) {
       destPtr = data + (y + yy) * line + (x >> 3);
       srcPtr = bitmap->data + yy * bitmap->line;
       src1 = *srcPtr++;
       dest = *destPtr;
       switch (combOp) {
       case 0: // or
         dest |= src1 >> s1;
         break;
       case 1: // and
         dest &= (0xff00 | src1) >> s1;
         break;
       case 2: // xor
         dest ^= src1 >> s1;
         break;
       case 3: // xnor
         dest ^= (src1 ^ 0xff) >> s1;
         break;
       case 4: // replace
         dest = (dest & (0xff << s2)) | (src1 >> s1);
         break;
       }
       *destPtr++ = dest;
       xx = x0 + 8;
      } else {
       destPtr = data + (y + yy) * line;
       srcPtr = bitmap->data + yy * bitmap->line + (-x >> 3);
       src1 = *srcPtr++;
       xx = x0;
      }

      // middle bytes
      for (; xx < x1 - 8; xx += 8) {
       dest = *destPtr;
       src0 = src1;
       src1 = *srcPtr++;
       src = (((src0 << 8) | src1) >> s1) & 0xff;
       switch (combOp) {
       case 0: // or
         dest |= src;
         break;
       case 1: // and
         dest &= src;
         break;
       case 2: // xor
         dest ^= src;
         break;
       case 3: // xnor
         dest ^= src ^ 0xff;
         break;
       case 4: // replace
         dest = src;
         break;
       }
       *destPtr++ = dest;
      }

      // right-most byte
      dest = *destPtr;
      src0 = src1;
      src1 = *srcPtr++;
      src = (((src0 << 8) | src1) >> s1) & 0xff;
      switch (combOp) {
      case 0: // or
       dest |= src & m2;
       break;
      case 1: // and
       dest &= src | m1;
       break;
      case 2: // xor
       dest ^= src & m2;
       break;
      case 3: // xnor
       dest ^= (src ^ 0xff) & m2;
       break;
      case 4: // replace
       dest = (src & m2) | (dest & m1);
       break;
      }
      *destPtr = dest;
    }
  }
}

Here is the caller graph for this function:

Definition at line 649 of file JBIG2Stream.cc.

{ return new JBIG2Bitmap(0, this); }

Here is the call graph for this function:

void JBIG2Bitmap::duplicateRow ( int  yDest,
int  ySrc 
)

Definition at line 775 of file JBIG2Stream.cc.

                                                  {
  memcpy(data + yDest * line, data + ySrc * line, line);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void JBIG2Bitmap::expand ( int  newH,
Guint  pixel 
)

Definition at line 718 of file JBIG2Stream.cc.

                                              {
  if (newH <= h) {
    return;
  }
  data = (Guchar *)grealloc(data, newH * line);
  if (pixel) {
    memset(data + h * line, 0xff, (newH - h) * line);
  } else {
    memset(data + h * line, 0x00, (newH - h) * line);
  }
  h = newH;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 667 of file JBIG2Stream.cc.

{ return data; }

Here is the caller graph for this function:

Definition at line 668 of file JBIG2Stream.cc.

{ return h * line; }

Here is the caller graph for this function:

Definition at line 655 of file JBIG2Stream.cc.

{ return h; }

Here is the caller graph for this function:

int JBIG2Bitmap::getPixel ( int  x,
int  y 
) [inline]

Definition at line 656 of file JBIG2Stream.cc.

    { return (x < 0 || x >= w || y < 0 || y >= h) ? 0 :
             (data[y * line + (x >> 3)] >> (7 - (x & 7))) & 1; }

Here is the caller graph for this function:

void JBIG2Bitmap::getPixelPtr ( int  x,
int  y,
JBIG2BitmapPtr ptr 
) [inline]

Definition at line 739 of file JBIG2Stream.cc.

                                                                      {
  if (y < 0 || y >= h || x >= w) {
    ptr->p = NULL;
  } else if (x < 0) {
    ptr->p = &data[y * line];
    ptr->shift = 7;
    ptr->x = x;
  } else {
    ptr->p = &data[y * line + (x >> 3)];
    ptr->shift = 7 - (x & 7);
    ptr->x = x;
  }
}

Here is the caller graph for this function:

Guint JBIG2Segment::getSegNum ( ) [inline, inherited]

Definition at line 625 of file JBIG2Stream.cc.

{ return segNum; }

Here is the caller graph for this function:

JBIG2Bitmap * JBIG2Bitmap::getSlice ( Guint  x,
Guint  y,
Guint  wA,
Guint  hA 
)

Definition at line 702 of file JBIG2Stream.cc.

                                                                       {
  JBIG2Bitmap *slice;
  Guint xx, yy;

  slice = new JBIG2Bitmap(0, wA, hA);
  slice->clearToZero();
  for (yy = 0; yy < hA; ++yy) {
    for (xx = 0; xx < wA; ++xx) {
      if (getPixel(x + xx, y + yy)) {
       slice->setPixel(xx, yy);
      }
    }
  }
  return slice;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual JBIG2SegmentType JBIG2Bitmap::getType ( ) [inline, virtual]

Implements JBIG2Segment.

Definition at line 648 of file JBIG2Stream.cc.

{ return jbig2SegBitmap; }
int JBIG2Bitmap::getWidth ( ) [inline]

Definition at line 654 of file JBIG2Stream.cc.

{ return w; }

Here is the caller graph for this function:

Definition at line 753 of file JBIG2Stream.cc.

                                                     {
  int pix;

  if (!ptr->p) {
    pix = 0;
  } else if (ptr->x < 0) {
    ++ptr->x;
    pix = 0;
  } else {
    pix = (*ptr->p >> ptr->shift) & 1;
    if (++ptr->x == w) {
      ptr->p = NULL;
    } else if (ptr->shift == 0) {
      ++ptr->p;
      ptr->shift = 7;
    } else {
      --ptr->shift;
    }
  }
  return pix;
}

Here is the caller graph for this function:

void JBIG2Bitmap::setPixel ( int  x,
int  y 
) [inline]

Definition at line 659 of file JBIG2Stream.cc.

    { data[y * line + (x >> 3)] |= 1 << (7 - (x & 7)); }

Here is the caller graph for this function:

void JBIG2Segment::setSegNum ( Guint  segNumA) [inline, inherited]

Definition at line 624 of file JBIG2Stream.cc.

{ segNum = segNumA; }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 675 of file JBIG2Stream.cc.

int JBIG2Bitmap::h [private]

Definition at line 674 of file JBIG2Stream.cc.

Definition at line 674 of file JBIG2Stream.cc.

int JBIG2Bitmap::w [private]

Definition at line 674 of file JBIG2Stream.cc.


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