Logo Search packages:      
Sourcecode: blender version File versions

struct ImBuf* IMB_dupImBuf ( struct ImBuf ibuf1  )  [read]

Attention:
Defined in allocimbuf.c

Definition at line 308 of file allocimbuf.c.

References ImBuf::cmap, ImBuf::depth, ImBuf::encodedbuffer, ImBuf::encodedbuffersize, ImBuf::encodedsize, ImBuf::flags, IB_rect, IMB_allocImBuf(), IMB_dupImBuf(), IMB_freeImBuf(), ImBuf::mall, ImBuf::maxcol, ImBuf::planes, ImBuf::rect, ImBuf::skipx, ImBuf::x, and ImBuf::y.

Referenced by IMB_antialias(), IMB_converttocmap(), IMB_dupImBuf(), IMB_half_x(), and IMB_half_y().

{
      struct ImBuf *ibuf2, tbuf;
      int flags = 0;
      int x, y;
      
      if (ibuf1 == 0) return (0);

      if (ibuf1->rect) flags |= IB_rect;
      if (ibuf1->planes) flags |= IB_planes;

      x = ibuf1->x;
      y = ibuf1->y;
      if (ibuf1->flags & IB_fields) y *= 2;
      
      ibuf2 = IMB_allocImBuf(x, y, ibuf1->depth, flags, 0);
      if (ibuf2 == 0) return (0);

      if (flags & IB_rect) memcpy(ibuf2->rect,ibuf1->rect,x * y * sizeof(int));
      if (flags & IB_planes) memcpy(*(ibuf2->planes),*(ibuf1->planes),ibuf1->depth * ibuf1->skipx * y * sizeof(int));

      if (ibuf1->encodedbuffer) {
            ibuf2->encodedbuffersize = ibuf1->encodedbuffersize;
            if (imb_addencodedbufferImBuf(ibuf2) == FALSE) {
                  IMB_freeImBuf(ibuf2);
                  return(0);
            }

            memcpy(ibuf2->encodedbuffer, ibuf1->encodedbuffer, ibuf1->encodedsize);
      }


      tbuf = *ibuf1;
      
      // pointers goedzetten
      tbuf.rect         = ibuf2->rect;
      tbuf.planes       = ibuf2->planes;
      tbuf.cmap         = ibuf2->cmap;
      tbuf.encodedbuffer = ibuf2->encodedbuffer;
      
      // malloc flag goed zetten
      tbuf.mall         = ibuf2->mall;
      
      *ibuf2 = tbuf;
      
      if (ibuf1->cmap){
            imb_addcmapImBuf(ibuf2);
            if (ibuf2->cmap) memcpy(ibuf2->cmap,ibuf1->cmap,ibuf2->maxcol * sizeof(int));
      }

      return(ibuf2);
}


Generated by  Doxygen 1.6.0   Back to index