Logo Search packages:      
Sourcecode: inkscape version File versions

void nr_pixblock_setup ( NRPixBlock pb,
NR_PIXBLOCK_MODE  mode,
int  x0,
int  y0,
int  x1,
int  y1,
bool  clear 
)

Pixbuf initialisation using g_new.

After allocating memory, the buffer is cleared if the clear flag is set.

Parameters:
pb Pointer to the pixbuf struct.
mode Indicates grayscale/RGB/RGBA.
clear True if buffer should be cleared.
Precondition:
x1>=x0 && y1>=y0 && pb!=NULL FIXME: currently unused except for nr_pixblock_new and pattern tiles, replace with _fast and delete?

Definition at line 101 of file nr-pixblock.cpp.

References NRPixBlock::area, NRPixBlock::data, NRPixBlock::empty, NRPixBlock::mode, NR_PIXBLOCK_MODE_A8, NR_PIXBLOCK_MODE_R8G8B8, NR_PIXBLOCK_SIZE_BIG, NR_PIXBLOCK_SIZE_TINY, NR_TINY_MAX, NRPixBlock::p, NRPixBlock::px, NRPixBlock::rs, NRPixBlock::size, and NRPixBlock::visible_area.

Referenced by nr_pixblock_new().

{
      int w, h, bpp;
      size_t size;

      w = x1 - x0;
      h = y1 - y0;
      bpp = (mode == NR_PIXBLOCK_MODE_A8) ? 1 : (mode == NR_PIXBLOCK_MODE_R8G8B8) ? 3 : 4;

      size = bpp * w * h;

      if (size <= NR_TINY_MAX) {
            pb->size = NR_PIXBLOCK_SIZE_TINY;
            if (clear) memset (pb->data.p, 0x0, size);
      } else {
            pb->size = NR_PIXBLOCK_SIZE_BIG;
            pb->data.px = g_new (unsigned char, size);
            if (clear) memset (pb->data.px, 0x0, size);
      }

      pb->mode = mode;
      pb->empty = 1;
    pb->visible_area.x0 = pb->area.x0 = x0;
    pb->visible_area.y0 = pb->area.y0 = y0;
    pb->visible_area.x1 = pb->area.x1 = x1;
    pb->visible_area.y1 = pb->area.y1 = y1;
      pb->rs = bpp * w;
}


Generated by  Doxygen 1.6.0   Back to index