Ignore:
Timestamp:
May 5, 2011, 12:36:33 PM (11 years ago)
Author:
Sam Hocevar
Message:

imlib: refactor the Filter and ColorFilter? classes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/imlib/filter.h

    r555 r579  
    1616#include "specs.h"
    1717
    18 class filter
     18class Filter
    1919{
    20   unsigned char *fdat;
    21   int nc;
    2220public :
    23   filter(int colors=256);
    24   filter(palette *from, palette *to);     // creates a conversion filter from one palette to another
    25   void set(int color_num, char change_to);
    26   unsigned char get_mapping(int color_num) { return fdat[color_num]; }
    27   void apply(image *im);
    28   void max_threshold(int minv, char blank=0);
    29   void min_threshold(int maxv, char blank=0);
    30   void put_image(image *screen, image *im, short x, short y, char transparent=0);
    31   void clear();
    32   ~filter() { free(fdat); }
    33 } ;
     21    Filter(int colors = 256);
     22    Filter(palette *from, palette *to);
     23    ~Filter();
    3424
    35 class color_filter
     25    void Set(int color_num, int change_to);
     26    int GetMapping(int color_num) { return m_table[color_num]; }
     27    void Apply(image *im);
     28    void PutImage(image *screen, image *im, vec2i pos);
     29
     30private:
     31    int m_size;
     32    uint8_t *m_table;
     33};
     34
     35class ColorFilter
    3636{
    37   unsigned char *color_table;
    3837public:
    39   int size();
    40   int write(bFILE *fp);
    41   color_filter(spec_entry *e, bFILE *fp);
    42   color_filter(palette *pal, int color_bits=6, void (*stat_fun)(int)=NULL);
    43   unsigned char lookup_color(int r, int g, int b)
    44    { return color_table[r*32*32+g*32+b]; }
    45   unsigned char *table() { return color_table; }
    46   int total_colors() { return 32; }
    47   unsigned char *get_table() { return color_table; }
    48   ~color_filter() { free(color_table); }
    49 } ;
     38    ColorFilter(spec_entry *e, bFILE *fp);
     39    ColorFilter(palette *pal, int color_bits);
     40    ~ColorFilter();
     41
     42    size_t DiskUsage();
     43    int Write(bFILE *fp);
     44    int Lookup(int r, int g, int b)
     45    {
     46        return m_table[(r * m_size + g) * m_size + b];
     47    }
     48
     49private:
     50    int m_size;
     51    uint8_t *m_table;
     52};
    5053
    5154#endif
    5255
    53 
    54 
    55 
Note: See TracChangeset for help on using the changeset viewer.