1 /* Libvisual-plugins - Standard plugins for libvisual
2  *
3  * Copyright (C) 2000, 2001 Richard Ashburn <richard.asbury@btinternet.com>
4  *
5  * Authors: Richard Ashburn <richard.asbury@btinternet.com>
6  * 	    Jean-Christophe Hoelt <jeko@ios-software.com>
7  *	    Dennis Smit <ds@nerds-incorporated.org>
8  *
9  * $Id: palette.h,v 1.4 2005/12/20 18:49:13 synap Exp $
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as
13  * published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24  */
25 
26 #ifndef _PALETTE_H
27 #define _PALETTE_H
28 
29 #define NB_PALETTES 23
30 
31 #include <libvisual/libvisual.h>
32 
33 #include "corona_types.h"
34 
35 // PALETTE
36 //
37 typedef ColorRGB Palette[256];
38 class   CompressedPalette;
39 
40 // COLLECTION OF PALETTES
41 //
42 // Definition of some palettes stored in compressed format.
43 //
44 class PaletteCollection
45 {
46   public:
47     PaletteCollection(const int palettes[][NB_PALETTES], int nbPalettes);
48     ~PaletteCollection();
49 
size()50     int size() const  { return m_nbPalettes; }
51     void expandPalette(int i, Palette dest) const;
52 
53   private:
54     CompressedPalette *m_cpal;
55     int                m_nbPalettes;
56 };
57 
58 // PALETTE CYCLER
59 //
60 // A class to create cycling palettes.
61 //
62 class PaletteCycler
63 {
64   private:
65     Palette m_srcpal;
66     Palette m_destpal;
67     Palette m_curpal;
68 
69     PaletteCollection m_palettes;
70     int    m_srcnum, m_destnum;
71     bool   m_transferring;
72     double m_progress;
73 
74     void startPaletteTransition();
75     void affectPaletteTransition(double p);
76 
77   public:
78     PaletteCycler(const int palettes[][NB_PALETTES], int nbPalettes);
79     void update(TimedLevel *pLevels);
80     void updateVisPalette(VisPalette *pal);
getPalette()81     const Palette &getPalette() const { return m_curpal; }
82 };
83 
84 // PALETTE CONVERSIOn
85 //
86 // Display/Architecture specific routines to convert Palette to int[] (hardware color)
87 //
88 void paletteToRGBA(int dest[256], const Palette src);
89 
90 // BLIT A PALETTIZED SURFACE using converted palette.
91 void blitSurface8To32(unsigned char *byteSurf, int *colorSurf, int palette[256], int size);
92 
93 #endif
94