1 /* 2 * file color.h - color and image manipulation 3 * 4 * $Id: color.h,v 1.6 2006/02/09 21:21:23 fzago Exp $ 5 * 6 * Program XBLAST 7 * (C) by Oliver Vogel (e-mail: m.vogel@ndh.net) 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published 11 * by the Free Software Foundation; either version 2; or (at your option) 12 * any later version 13 * 14 * This program is distributed in the hope that it will be entertaining, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILTY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 17 * Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License along 20 * with this program; if not, write to the Free Software Foundation, Inc. 21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 */ 23 #ifndef _COLOR_H 24 #define _COLOR_H 25 26 /* 27 * type definitions 28 */ 29 typedef unsigned short XBColor; 30 31 /* 32 * macros for color manipulation 33 */ 34 #define XBCOLOR_DEPTH 31 35 36 #define SET_COLOR(r,g,b) ((XBColor) (((r) & 0x001F) << 10) | (XBColor) (((g) & 0x001F) << 5) | (XBColor) ((b) & 0x001F) ) 37 38 #define GET_RED(c) (((c) >> 10) & 0x001F) 39 #define GET_GREEN(c) (((c) >> 5) & 0x001F) 40 #define GET_BLUE(c) ( (c) & 0x001F) 41 42 /* 43 * predefined colors 44 */ 45 #define COLOR_INVALID 0xFFFF 46 #define COLOR_BLACK 0x0000 47 #define COLOR_WHITE 0x7FFF 48 49 #define COLOR_RED SET_COLOR (31, 0, 0) 50 #define COLOR_GREEN SET_COLOR ( 0, 31, 0) 51 #define COLOR_BLUE SET_COLOR ( 0, 0, 31) 52 53 #define COLOR_DARK_BLUE SET_COLOR ( 0, 0, 17) 54 #define COLOR_DARK_SEA_GREEN SET_COLOR (17, 23, 17) 55 #define COLOR_DARK_SLATE_GRAY_4 SET_COLOR (10, 17, 17) 56 #define COLOR_DEEP_PINK SET_COLOR (31, 2, 18) 57 #define COLOR_FIRE_BRICK_1 SET_COLOR (31, 6, 6) 58 #define COLOR_FOREST_GREEN SET_COLOR ( 4, 17, 4) 59 #define COLOR_GOLD SET_COLOR (31, 26, 0) 60 #define COLOR_GRAY_25 SET_COLOR ( 8, 8, 8) 61 #define COLOR_GRAY_75 SET_COLOR (24, 24, 24) 62 #define COLOR_GREEN_YELLOW SET_COLOR (21, 31, 5) 63 #define COLOR_INDIAN_RED SET_COLOR (25, 11, 11) 64 #define COLOR_LIGHT_GOLDENROD SET_COLOR (29, 27, 16) 65 #define COLOR_LIGHT_SALMON SET_COLOR (31, 20, 15) 66 #define COLOR_LIGHT_STEEL_BLUE SET_COLOR (22, 24, 27) 67 #define COLOR_LIGHT_YELLOW SET_COLOR (31, 31, 28) 68 #define COLOR_MIDNIGHT_BLUE SET_COLOR ( 3, 3, 14) 69 #define COLOR_NAVY_BLUE SET_COLOR ( 0, 0, 16) 70 #define COLOR_ORANGE SET_COLOR (31, 20, 0) 71 #define COLOR_ORANGE_RED SET_COLOR (31, 8, 0) 72 #define COLOR_ORCHID SET_COLOR (27, 14, 26) 73 #define COLOR_ROYAL_BLUE SET_COLOR ( 8, 13, 28) 74 #define COLOR_SADDLE_BROWN SET_COLOR (17, 8, 2) 75 #define COLOR_SPRING_GREEN SET_COLOR ( 0, 31, 15) 76 #define COLOR_TAN SET_COLOR (26, 22, 17) 77 #define COLOR_TURQUOISE SET_COLOR ( 8, 28, 21) 78 #define COLOR_YELLOW SET_COLOR (31, 31, 0) 79 80 /* 81 * global prototypes 82 */ 83 extern void CchToPpm (unsigned char *ppm, int width, int height, 84 XBColor fg, XBColor bg, XBColor add); 85 extern void EpmToPpm (unsigned char *epm, unsigned char *ppm, int width, int height, 86 int ncolors, const XBColor * color); 87 extern const char *ColorToString (XBColor color); 88 extern XBColor StringToColor (const char *string); 89 extern XBColor LighterColor (XBColor color); 90 extern XBColor DarkerColor (XBColor color); 91 extern XBColor RandomColor (void); 92 93 #endif 94 /* 95 * end of color.h 96 */ 97