Logo Search packages:      
Sourcecode: djvulibre version File versions

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

Resets the GPixmap by copying the size and the contents 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 of shades of gray.

Definition at line 306 of file GPixmap.cpp.

References GBitmap::columns(), GBitmap::get_grays(), init(), and GBitmap::rows().

  init(ref.rows(), ref.columns(), 0);
  GPixel *xramp;
  GPBuffer<GPixel> gxramp(xramp);
  if (nrows>0 && ncolumns>0)
    // Create pixel ramp
    const GPixel *ramp = userramp;
    if (!userramp)
        ramp = new_gray_ramp(ref.get_grays(),xramp);
    // Copy pixels
    for (int y=0; y<nrows; y++)
      GPixel *dst = (*this)[y];
      const unsigned char *src = ref[y];
      for (int x=0; x<ncolumns; x++)
        dst[x] = ramp[ src[x] ];
    // Free ramp
//    if (!userramp)
//      delete [] (GPixel*)ramp;

Generated by  Doxygen 1.6.0   Back to index