Logo Search packages:      
Sourcecode: djvulibre version File versions  Download package

void GBitmap::init ( const GBitmap ref,
const GRect rect,
int  border = 0 

Initializes this GBitmap with a rectangular segment rect# of GBitmap ref#. The optional argument border# specifies the size of the optional border of white pixels surrounding the image.

Definition at line 249 of file GBitmap.cpp.

References border, bytes, bytes_per_row, columns(), gbytes_data, grays, grle, GRect::height(), init(), monitor(), ncolumns, nrows, rows(), GRect::width(), GRect::xmin, and GRect::ymin.

  GMonitorLock lock(monitor());
  // test bitmap physical equality
  if (this == &ref)
      GBitmap tmp;
      tmp.grays = grays;
      tmp.border = border;
      tmp.bytes_per_row = bytes_per_row;
      tmp.ncolumns = ncolumns;
      tmp.nrows = nrows;
      tmp.bytes = bytes;
      bytes = 0 ;
      init(tmp, rect, border);
      GMonitorLock lock(ref.monitor());
      // create empty bitmap
      init(rect.height(), rect.width(), border);
      grays = ref.grays;
      // 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())
          for (int y=rect2.ymin; y<rect2.ymax; y++)
              unsigned char *dst = (*this)[y];
              const unsigned char *src = ref[y+rect.ymin] + rect.xmin;
              for (int x=rect2.xmin; x<rect2.xmax; x++)
                dst[x] = src[x];

Generated by  Doxygen 1.6.0   Back to index