Logo Search packages:      
Sourcecode: djvulibre version File versions

void GPixmap::init ( const GBitmap ref,
const GRect rect,
const GPixel ramp = 0 

Resets the GPixmap by copying the rectangle rect# of the gray level image ref#. The optional argument ramp# is an array of 256 pixel values used for mapping the gray levels to color values. Setting ramp# to zero selects a linear ramp computed according to the maximal number of gray levels in ref#.

Definition at line 337 of file GPixmap.cpp.

References GBitmap::columns(), GBitmap::get_grays(), GRect::height(), init(), GBitmap::rows(), GRect::width(), GRect::xmin, and GRect::ymin.

  init(rect.height(), rect.width(), 0);
  // compute destination rectangle
  GRect rect2(0, 0, ref.columns(), ref.rows() );
  rect2.intersect(rect2, rect);
  rect2.translate(-rect.xmin, -rect.ymin);
  // copy bits
  if (! rect2.isempty())
    GPixel *xramp;
    GPBuffer<GPixel> gxramp(xramp);
    // allocate ramp
    const GPixel *ramp = userramp;
    if (!userramp)
          ramp = new_gray_ramp(ref.get_grays(),xramp);
    // copy pixels
    for (int y=rect2.ymin; y<rect2.ymax; y++)
      GPixel *dst = (*this)[y];
      const unsigned char *src = ref[y+rect.ymin] + rect.xmin;
      for (int x=rect2.xmin; x<rect2.xmax; x++)
        dst[x] = ramp[ src[x] ];
    // free ramp
//    if (!userramp)
//      delete [] (GPixel*) ramp;

Generated by  Doxygen 1.6.0   Back to index