Logo Search packages:      
Sourcecode: djvulibre version File versions

void GPixmap::upsample ( const GPixmap src,
int  factor,
const GRect rect = 0 
)

Resets this GPixmap with a oversampled segment of color image src#. This function conceptually rescales image src# by a factor factor:1#, and copies rectangle rect# of the oversampled image into the current GPixmap. The full oversampled image is copied if rect# is a null pointer. Both operations are however performed together for efficiency reasons. Oversampling works by replicating the color of the source pixels into squares of size factor# times factor#.

Definition at line 936 of file GPixmap.cpp.

References columns(), init(), rows(), rowsize(), GRect::xmax, GRect::xmin, GRect::ymax, and GRect::ymin.

{
  // check arguments
  GRect rect(0, 0, src->columns()*factor, src->rows()*factor);
  if (pdr != 0)
  {
    if (pdr->xmin < rect.xmin || 
        pdr->ymin < rect.ymin || 
        pdr->xmax > rect.xmax || 
        pdr->ymax > rect.ymax  )
      G_THROW( ERR_MSG("GPixmap.overflow2") );
    rect = *pdr;
  }
  // initialise pixmap
  init(rect.height(), rect.width(), 0);
  // compute starting point in source rectangle
  int sy, sy1, sxz, sx1z;
  euclidian_ratio(rect.ymin, factor, sy, sy1);
  euclidian_ratio(rect.xmin, factor, sxz, sx1z);
  // loop over rows
  const GPixel *sptr = (*src)[sy];
  GPixel *dptr = (*this)[0];
  for (int y=0; y<nrows; y++)
  {
    // loop over columns
    int sx = sxz;
    int sx1 = sx1z;
    for (int x=0; x<ncolumns; x++)
    {
      dptr[x] = sptr[sx];
      // next column
      if (++sx1 >= factor)
      {
        sx1 = 0;
        sx += 1;
      }
    }
    // next row
    dptr += rowsize();
    if (++sy1 >= factor)
    {
      sy1 = 0;
      sptr += src->rowsize();
    }
  }
}


Generated by  Doxygen 1.6.0   Back to index