00001 /* 00002 Copyright (C) 2003-2004 The Pentagram Team 00003 00004 This program is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU General Public License 00006 as published by the Free Software Foundation; either version 2 00007 of the License, or (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #ifndef PALETTE_H 00020 #define PALETTE_H 00021 00022 class IDataSource; 00023 00024 namespace Pentagram 00025 { 00026 00027 enum PalTransforms { 00028 // Normal untransformed palette 00029 Transform_None = 0, 00030 00031 // O[i] = I[r]*0.375 + I[g]*0.5 + I[b]*0.125; 00032 Transform_Greyscale = 1, 00033 00034 // O[r] = 0; 00035 Transform_NoRed = 2, 00036 00037 // O[i] = (I[i] + Grey)*0.25 + 0.1875; 00038 Transform_RainStorm = 3, 00039 00040 // O[r] = (I[r] + Grey)*0.5 + 0.1875; 00041 // O[g] = I[g]*0.5 + Grey*0.25; 00042 // O[b] = I[b]*0.5; 00043 Transform_FireStorm = 4, 00044 00045 // O[i] = I[i]*2 -Grey; 00046 Transform_Saturate = 5, 00047 00048 // O[g] = I[r]; O[b] = I[g]; O[r] = I[b]; 00049 Transform_GBR = 6, 00050 00051 // O[b] = I[r]; O[r] = I[g]; O[g] = I[b]; 00052 Transform_BRG = 7 00053 }; 00054 00055 struct Palette 00056 { 00057 void load(IDataSource& ds, IDataSource& xformds); 00058 void load(IDataSource& ds); 00059 00060 // 256 rgb entries 00061 uint8 palette[768]; 00062 00063 // Untransformed native format palette. Created by the RenderSurface 00064 uint32 native_untransformed[256]; 00065 00066 // Transformed native format palette. Created by the RenderSurface 00067 uint32 native[256]; 00068 00069 // Untransformed XFORM ARGB palette 00070 uint32 xform_untransformed[256]; 00071 00072 // Transformed XFORM ARGB palette. Created by the RenderSurface 00073 uint32 xform[256]; 00074 00075 // Colour transformation matrix (for fades, hue shifts) 00076 // Applied by the RenderSurface (fixed -4.11) 00077 // R = R*matrix[0] + G*matrix[1] + B*matrix[2] + matrix[3]; 00078 // G = R*matrix[4] + G*matrix[5] + B*matrix[6] + matrix[7]; 00079 // B = R*matrix[8] + G*matrix[9] + B*matrix[10] + matrix[11]; 00080 // A = A; 00081 sint16 matrix[12]; 00082 00083 // The current palette transform 00084 PalTransforms transform; 00085 }; 00086 00087 } 00088 00089 #endif