Logo Search packages:      
Sourcecode: blender version File versions

struct ImBuf* IMB_scalefastImBuf ( struct ImBuf ibuf,
short  newx,
short  newy 
) [read]

Attention:
Defined in scaling.c

Definition at line 611 of file scaling.c.

References IB_rect, IMB_scalefastImBuf(), ImBuf::mall, ImBuf::rect, ImBuf::x, and ImBuf::y.

Referenced by IMB_scalefastfieldImBuf(), and IMB_scalefastImBuf().

{
      unsigned int *rect,*_newrect,*newrect;
      int x,y;
      int ofsx,ofsy,stepx,stepy;

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

      if (newx == ibuf->x && newy == ibuf->y) return(ibuf);

      _newrect = malloc(newx * newy * sizeof(int));
      if (_newrect == 0) return(ibuf);

      newrect = _newrect;
      stepx = (65536.0 * (ibuf->x - 1.0) / (newx - 1.0)) + 0.5;
      stepy = (65536.0 * (ibuf->y - 1.0) / (newy - 1.0)) + 0.5;
      ofsy = 32768;

      for (y = newy; y > 0 ; y--){
            rect = ibuf->rect;
            rect += (ofsy >> 16) * ibuf->x;
            ofsy += stepy;
            ofsx = 32768;
            for (x = newx ; x>0 ; x--){
                  *newrect++ = rect[ofsx >> 16];
                  ofsx += stepx;
            }
      }

      imb_freerectImBuf(ibuf);
      ibuf->mall |= IB_rect;
      ibuf->rect = _newrect;
      
      scalefast_Z_ImBuf(ibuf, newx, newy);
      
      ibuf->x = newx;
      ibuf->y = newy;
      return(ibuf);
}


Generated by  Doxygen 1.6.0   Back to index