Logo Search packages:      
Sourcecode: blender version File versions

void IMB_applycmap ( struct ImBuf ibuf  ) 

Attention:
Defined in cmap.c

Definition at line 529 of file cmap.c.

References ImBuf::cmap, ImBuf::depth, IMB_applycmap(), ImBuf::rect, ImBuf::x, and ImBuf::y.

Referenced by IMB_applycmap().

{
      unsigned int *rect, *cmap;
      int x, y, i, col, code;
      int *mask = 0;
      
      if (ibuf == 0) return;
      if (ibuf->rect == 0 || ibuf->cmap == 0) return;
      
      rect = ibuf->rect;
      cmap = ibuf->cmap;

      if (IS_ham(ibuf)){
            
            /* generate mask of max (8 + 2) bits */
            mask = malloc(1024 * 2 * sizeof(int));

            x = 1 << (ibuf->depth - 2);
            y = 65535 / (x - 1);
            
            for (i = 0; i < x; i++){
                  mask[i] = 0;
                  mask[i + x] = 0x00ffff;
                  mask[i + x + x] = 0xffff00;
                  mask[i + x + x + x] = 0xff00ff;

                  col = (y * i) >> 8;
                  
                  mask[i + 1024] = 0xff000000 | ibuf->cmap[i];
                  mask[i + x + 1024] = 0xff000000 | col << 16;
                  mask[i + x + x + 1024] = 0xff000000 | col;
                  mask[i + x + x + x + 1024] = 0xff000000 | col << 8;
            }
            
            /* only color 0 transparant */
            mask[0+1024] =ibuf->cmap[0];
            
            for (y = ibuf->y ; y>0 ; y--){
                  col = cmap[0];
                  for (x=ibuf->x ; x>0 ; x--){
                        code = *rect;
                        *rect++ = col = (col & mask[code]) | mask[code + 1024];
                  }
            }
            free(mask);
      } else {
      
            for(i = ibuf->x * ibuf->y; i>0; i--){
                  col = *rect;
                  if (col >= 0 && col < ibuf->maxcol) *rect = cmap[col];
                  rect++;

                  /* *(rect++) = cmap[*rect]; */
            }
      }
}


Generated by  Doxygen 1.6.0   Back to index