source: abuse/trunk/src/imlib/filter.h @ 579

Last change on this file since 579 was 579, checked in by Sam Hocevar, 11 years ago

imlib: refactor the Filter and ColorFilter? classes.

  • Property svn:keywords set to Id
File size: 1.1 KB
RevLine 
[56]1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
[494]4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
[56]5 *
6 *  This software was released into the Public Domain. As with most public
[555]7 *  domain software, no warranty is made or implied by Crack dot Com, by
8 *  Jonathan Clark, or by Sam Hocevar.
[56]9 */
10
[2]11#ifndef _FILTER_HPP
12#define _FILTER_HPP
[129]13
[481]14#include "image.h"
15#include "palette.h"
16#include "specs.h"
[2]17
[579]18class Filter
[2]19{
20public :
[579]21    Filter(int colors = 256);
22    Filter(palette *from, palette *to);
23    ~Filter();
[2]24
[579]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
[2]36{
37public:
[579]38    ColorFilter(spec_entry *e, bFILE *fp);
39    ColorFilter(palette *pal, int color_bits);
40    ~ColorFilter();
[2]41
[579]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    }
[2]48
[579]49private:
50    int m_size;
51    uint8_t *m_table;
52};
[2]53
[579]54#endif
[2]55
Note: See TracBrowser for help on using the repository browser.