Logo Search packages:      
Sourcecode: blender version File versions

void IMB_dit2 ( struct ImBuf ibuf,
short  ofs,
short  bits 
)

Attention:
defined in dither.c

Definition at line 68 of file dither.c.

References IMB_dit2(), ImBuf::rect, ImBuf::x, and ImBuf::y.

Referenced by IMB_dit2().

{
      short x,y,pix,and,add1,add2;
      uchar *rect;
      uchar dit[4];

      rect= (uchar *)ibuf->rect;
      rect +=ofs;

      bits = 8 - bits;
      and = ~((1<<bits)-1);
      bits -= 2;

      ofs = 0;
      
      switch(ofs){
      case 3:
            break;
      case 2:
            dit[0]=0;
            dit[1]=1;
            dit[2]=2;
            dit[3]=3;
            break;
      case 1:
            dit[0]=3;
            dit[1]=1;
            dit[2]=0;
            dit[3]=2;
            break;
      case 0:
            dit[0]=0;
            dit[1]=2;
            dit[2]=3;
            dit[3]=1;
            break;
      }
      
      if (bits < 0){
            dit[0] >>= -bits;
            dit[1] >>= -bits;
            dit[2] >>= -bits;
            dit[3] >>= -bits;
      } else{
            dit[0] <<= bits;
            dit[1] <<= bits;
            dit[2] <<= bits;
            dit[3] <<= bits;
      }

      for(y=ibuf->y;y>0;y--){
            if(y & 1){
                  add1=dit[0];
                  add2=dit[1];
            }
            else{
                  add1=dit[2];
                  add2=dit[3];
            }
            for(x=ibuf->x;x>0;x--){
                  pix = *rect;
                  if (x & 1) pix += add1;
                  else pix += add2;

                  if (pix>255) pix=255;
                  *rect = pix & and;
                  rect += 4;
            }
      }
}


Generated by  Doxygen 1.6.0   Back to index