1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef AGS_LIB_ALLEGRO_COLOR_H 24 #define AGS_LIB_ALLEGRO_COLOR_H 25 26 #include "common/scummsys.h" 27 #include "graphics/screen.h" 28 #include "ags/lib/allegro/base.h" 29 #include "ags/lib/allegro/alconfig.h" 30 31 namespace AGS3 { 32 33 #define PAL_SIZE 256 34 #define MASK_COLOR_8 0 35 #define MASK_COLOR_15 0x7C1F 36 #define MASK_COLOR_16 0xF81F 37 #define MASK_COLOR_24 0xFF00FF 38 #define MASK_COLOR_32 0xFF00FF 39 40 class BITMAP; 41 42 namespace AGS { 43 namespace Shared { 44 class Stream; 45 } // namespace Shared 46 } // namespace AGS 47 48 #include "common/pack-start.h" // START STRUCT PACKING 49 50 struct color { 51 byte r, g, b; 52 byte filler; 53 54 void readFromFile(AGS::Shared::Stream *file); 55 void writeToFile(AGS::Shared::Stream *file) const; clearcolor56 void clear() { 57 r = g = b = filler = 0; 58 } 59 } PACKED_STRUCT; 60 61 typedef color RGB; 62 typedef RGB PALETTE[PAL_SIZE]; 63 64 #include "common/pack-end.h" // END STRUCT PACKING 65 66 struct RGB_MAP { 67 byte data[32][32][32]; 68 }; 69 70 struct COLOR_MAP { 71 byte data[PAL_SIZE][PAL_SIZE]; 72 }; 73 74 enum BlenderMode { 75 kSourceAlphaBlender, 76 kArgbToArgbBlender, 77 kArgbToRgbBlender, 78 kRgbToArgbBlender, 79 kRgbToRgbBlender, 80 kAlphaPreservedBlenderMode, 81 kOpaqueBlenderMode, 82 kAdditiveBlenderMode, 83 kTintBlenderMode, 84 kTintLightBlenderMode 85 }; 86 87 AL_ARRAY(const int, _rgb_scale_5); 88 AL_ARRAY(const int, _rgb_scale_6); 89 90 AL_FUNC(void, set_palette, (AL_CONST PALETTE p)); 91 AL_FUNC(void, set_palette_range, (AL_CONST PALETTE p, int from, int to, int retracesync)); 92 93 AL_FUNC(void, get_color, (int idx, RGB *p)); 94 AL_FUNC(void, get_palette, (PALETTE p)); 95 AL_FUNC(void, get_palette_range, (PALETTE p, int from, int to)); 96 97 AL_FUNC(void, fade_interpolate, (AL_CONST PALETTE source, AL_CONST PALETTE dest, PALETTE output, int pos, int from, int to)); 98 99 AL_FUNC(void, select_palette, (AL_CONST PALETTE p)); 100 AL_FUNC(void, unselect_palette, (void)); 101 102 AL_FUNC(void, create_rgb_table, (RGB_MAP *table, AL_CONST PALETTE pal, AL_METHOD(void, callback, (int pos)))); 103 AL_FUNC(void, create_light_table, (COLOR_MAP *table, AL_CONST PALETTE pal, int r, int g, int b, AL_METHOD(void, callback, (int pos)))); 104 AL_FUNC(void, create_trans_table, (COLOR_MAP *table, AL_CONST PALETTE pal, int r, int g, int b, AL_METHOD(void, callback, (int pos)))); 105 106 AL_FUNC(void, set_blender_mode, (BlenderMode, int r, int g, int b, int a)); 107 AL_FUNC(void, set_alpha_blender, (void)); 108 AL_FUNC(void, set_trans_blender, (int r, int g, int b, int a)); 109 110 AL_FUNC(void, hsv_to_rgb, (float h, float s, float v, int *r, int *g, int *b)); 111 AL_FUNC(void, rgb_to_hsv, (int r, int g, int b, float *h, float *s, float *v)); 112 113 AL_FUNC(int, bestfit_color, (AL_CONST PALETTE pal, int r, int g, int b)); 114 115 AL_FUNC(int, makecol8, (int r, int g, int b)); 116 AL_FUNC(int, makecol_depth, (int color_depth, int r, int g, int b)); 117 118 AL_FUNC(int, makeacol_depth, (int color_depth, int r, int g, int b, int a)); 119 120 AL_FUNC(int, getr, (int c)); 121 AL_FUNC(int, getg, (int c)); 122 AL_FUNC(int, getb, (int c)); 123 AL_FUNC(int, geta, (int c)); 124 125 AL_FUNC(int, getr_depth, (int color_depth, int c)); 126 AL_FUNC(int, getg_depth, (int color_depth, int c)); 127 AL_FUNC(int, getb_depth, (int color_depth, int c)); 128 AL_FUNC(int, geta_depth, (int color_depth, int c)); 129 130 extern int makecol15(int r, int g, int b); 131 extern int makecol16(int r, int g, int b); 132 extern int makecol24(int r, int g, int b); 133 extern int makecol32(int r, int g, int b); 134 extern int makeacol32(int r, int g, int b, int a); 135 extern int getr8(int c); 136 extern int getg8(int c); 137 extern int getb8(int c); 138 extern int getr15(int c); 139 extern int getg15(int c); 140 extern int getb15(int c); 141 extern int getr16(int c); 142 extern int getg16(int c); 143 extern int getb16(int c); 144 extern int getr24(int c); 145 extern int getg24(int c); 146 extern int getb24(int c); 147 extern int getr32(int c); 148 extern int getg32(int c); 149 extern int getb32(int c); 150 extern int geta32(int c); 151 152 extern int getr_depth(int color_depth, int c); 153 extern int getg_depth(int color_depth, int c); 154 extern int getb_depth(int color_depth, int c); 155 extern int geta_depth(int color_depth, int c); 156 157 } // namespace AGS3 158 159 #endif 160