Logo Search packages:      
Sourcecode: blender version File versions

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

Attention:
Defined in scaling.c

Definition at line 210 of file scaling.c.

References ImBuf::depth, IMB_allocImBuf(), IMB_half_x(), IMB_half_y(), IMB_onehalf(), ImBuf::rect, ImBuf::x, and ImBuf::y.

Referenced by IMB_onehalf().

{
      struct ImBuf *ibuf2;
      uchar *p1,*p2,*dest;
      int x,y;

      if (ibuf1 == 0) return (0);
      if (ibuf1->rect == 0) return (0);

      if (ibuf1->x <= 1) return(IMB_half_y(ibuf1));
      if (ibuf1->y <= 1) return(IMB_half_x(ibuf1));
      
      ibuf2=IMB_allocImBuf((ibuf1->x)/2,(ibuf1->y)/2,ibuf1->depth,1,0);
      if (ibuf2==0) return (0);

      p1 = (uchar *) ibuf1->rect;
      dest=(uchar *) ibuf2->rect;

      for(y=ibuf2->y;y>0;y--){
            p2 = p1 + (ibuf1->x << 2);
            for(x=ibuf2->x;x>0;x--){
                  dest[0] = (p1[0] + p2[0] + p1[4] + p2[4]) >> 2;
                  dest[1] = (p1[1] + p2[1] + p1[5] + p2[5]) >> 2;
                  dest[2] = (p1[2] + p2[2] + p1[6] + p2[6]) >> 2;
                  dest[3] = (p1[3] + p2[3] + p1[7] + p2[7]) >> 2;
                  p1 += 8; 
                  p2 += 8; 
                  dest += 4;
            }
            p1=p2;
            if(ibuf1->x & 1) {
                  p1+=4;
            }
      }
      return (ibuf2);
}


Generated by  Doxygen 1.6.0   Back to index