Ignore:
Timestamp:
May 14, 2011, 4:00:53 PM (11 years ago)
Author:
Sam Hocevar
Message:

imlib: remove unused code and tag unused method arguments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/imlib/palette.cpp

    r555 r653  
    5656}
    5757
    58 int palette::find_closest(unsigned char r, unsigned char g, unsigned char b)
     58int palette::find_closest(uint8_t r, uint8_t g, uint8_t b)
    5959{
    6060   unsigned char *cl=(unsigned char *)addr();
     
    7171}
    7272
    73 
    74 int palette::find_closest_non0(unsigned char r, unsigned char g, unsigned char b)
    75 {
    76    unsigned char *cl=(unsigned char *)addr()+3;
    77    int c=1,d=0x7fffffff,i,nd;
    78    for (i=1; i<256; i++)
    79    {
    80      nd=((int)r-(int)(*cl))*((int)r-(int)(*cl)); cl++;
    81      nd+=((int)g-(int)(*cl))*((int)g-(int)(*cl)); cl++;
    82      nd+=((int)b-(int)(*cl))*((int)b-(int)(*cl)); cl++;
    83      if (nd<d)
    84      { c=i; d=nd; }
    85    }
    86    return c;
    87 }
    88 
    89 
    90 int palette::find_color(unsigned char r, unsigned char g, unsigned char b)
     73int palette::find_color(uint8_t r, uint8_t g, uint8_t b)
    9174{
    9275  int i,ub,mask,find;
     
    210193  b=color_num%8;
    211194  return (usd[x]&(128>>b));
    212 }
    213 
    214 int palette::add_color(unsigned int r, int unsigned g, int unsigned b, int closest_only)
    215 {
    216   int i,f,u,c;
    217   if (!closest_only)
    218   {
    219     for (i=ncolors-1,f=-1,u=-1; i>=0 && f<0; i--)
    220     {
    221       if (used(i))
    222       {
    223         if (pal[i].red==r && pal[i].green==g && pal[i].blue==b)
    224     f=i;
    225       }
    226       else
    227         u=i;
    228     }
    229   } else { f=-1; u=-1; }
    230   if (f<0)
    231   {
    232     if (u>=0)
    233     { pal[u].red=r;
    234       pal[u].green=g;
    235       pal[u].blue=b;
    236       set_used(u);
    237       f=u;
    238     }
    239     else
    240     {
    241       for (i=0,f=0,u=10000; i<ncolors; i++)
    242       { c=(pal[i].red-r)*(pal[i].red-r)+
    243       (pal[i].green-g)*(pal[i].green-g)+
    244       (pal[i].blue-b)*(pal[i].blue-b);
    245     if (c<u)
    246     { f=i;
    247       u=c;
    248     }
    249       }
    250     }
    251   }
    252   return f;
    253195}
    254196
     
    430372}
    431373
    432 void quant_palette::add_color(unsigned char r, unsigned char g, unsigned char b)
    433 {
    434   quant_node **p,*fat;
    435   int lev,cn,stop;
    436   p=&root;
    437   lev=0;
    438   stop=0;
    439   fat=NULL;
    440   if (nc>=mx-1)
    441     prune();
    442   while (!stop)
    443   {
    444     lev++;
    445     if (!(*p))
    446     {
    447       if (lev>2 && !fat)
    448     printf("h");
    449       (*p)=new quant_node(lev,fat);
    450       level[lev-1].add_end(*p);
    451     }
    452 
    453     if (!(*p)->is_leaf())
    454     {
    455       cn=((r&(256>>lev))!=0)<<2;
    456       cn+=((g&(256>>lev))!=0)<<1;
    457       cn+=((b&(256>>lev))!=0);
    458       fat=(*p);
    459       p=&((*p)->children[cn]);
    460     } else stop=1;
    461 
    462   }
    463   (*p)->set(r,g,b);
    464   if (!(*p)->tot)
    465     nc++;
    466   (*p)->tot++;
    467 }
    468 
    469 palette *quant_palette::create_pal()
    470 {
    471   palette *p;
    472   int i,x;
    473   quant_node *pn;
    474   p=new palette(mx);
    475   for (x=0,i=7; i>=0; i++)
    476     for (pn=(quant_node *)level[i].first();
    477      pn!=(quant_node *)level[i].first(); pn=(quant_node *)pn->Next())
    478       if (pn->is_leaf())
    479     p->set(x++,pn->red,pn->green,pn->blue);
    480   return p;
    481 }
    482 
    483374quant_palette::~quant_palette()
    484375{
     
    490381}
    491382
    492 unsigned char palette::brightest(int all)
    493 { unsigned char r,g,b,bri;
     383uint8_t palette::brightest(int all)
     384{ uint8_t r,g,b,bri;
    494385  unsigned i;
    495386  long brv;
     
    510401}
    511402
    512 unsigned char palette::darkest(int all, int noblack)
    513 { unsigned char r,g,b,bri;
     403uint8_t palette::darkest(int all, int noblack)
     404{ uint8_t r,g,b,bri;
    514405  unsigned i;
    515406  long brv,x;
Note: See TracChangeset for help on using the changeset viewer.