00001 /* 00002 $Id: pixelformat.h,v 1.1 2001/03/06 15:09:10 mbn Exp $ 00003 00004 ------------------------------------------------------------------------ 00005 ClanLib, the platform independent game SDK. 00006 00007 This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE 00008 version 2. See COPYING for details. 00009 00010 For a total list of contributers see CREDITS. 00011 00012 ------------------------------------------------------------------------ 00013 */ 00014 00016 00017 #ifndef header_pixelformat 00018 #define header_pixelformat 00019 00020 class CL_Target; 00021 00022 enum EPixelFormat 00023 //: Pixelformat types available. 00024 { 00025 PAL8, 00026 //: Palettelized 8 bpp mode. 00027 00028 RGB565, 00029 //: Red-green-blue, using depth 565, 16 bpp. 00030 00031 RGBA4444, 00032 //: Red-green-blue-alpha, using depth 4444, 16 bpp. 00033 00034 RGBA5551, 00035 //: Red-green-blue-alpha, using depth 5551, 16 bpp. 00036 00037 RGB888, 00038 //: Red-green-blue, using depth 888, 24 bpp. 00039 00040 RGBA8888, 00041 //: Red-green-blue-alpha, using depth 8888, 32 bpp. 00042 }; 00043 00044 class CL_Color 00045 //: This class provides methods that deal with colors, 00046 // including the ability to find color-component bit 00047 // masks for particular pixel formats. Also you can 00048 // use this class to get colors, in any of the 00049 // different pixel formats, from the color components 00050 // (Red, Blue, Green and Alpha).<p> 00051 // Often you can specify color components as either 00052 // integers or floating points (the component value 00053 // divided by it's maximum possible value.) 00054 { 00055 public: 00056 static unsigned int get_red_mask(EPixelFormat pixelformat); 00057 //: Returns the bit mask for red using the given pixel format. 00058 00059 static unsigned int get_green_mask(EPixelFormat pixelformat); 00060 //: Returns the bit mask for green using the given pixel format. 00061 00062 static unsigned int get_blue_mask(EPixelFormat pixelformat); 00063 //: Returns the bit mask for blue using the given pixel format. 00064 00065 static unsigned int get_alpha_mask(EPixelFormat pixelformat); 00066 //: Returns the bit mask for alpha using the given pixel format. 00067 00068 static unsigned int get_color(EPixelFormat fmt, int r, int g, int b, int a=255); 00069 //: Converts separate red, blue, green and alpha integer values into a color value 00076 00077 static unsigned int get_color(EPixelFormat fmt, float r, float g, float b, float a=1.0); 00078 //: Converts separate red, blue, green and alpha floating 00079 //: point values into a single color value 00086 00087 static unsigned int get_color(unsigned int rmask, 00088 unsigned int gmask, 00089 unsigned int bmask, 00090 unsigned int amask, 00091 int r, int g, int b, int a=255); 00092 //: Returns the color value in a format you specify 00093 //: by giving the red, green, blue and alpha 00094 //: masks, along with the corresponding red, blue, 00095 //: green and alpha values. 00105 00106 static unsigned int get_color(unsigned int rmask, 00107 unsigned int gmask, 00108 unsigned int bmask, 00109 unsigned int amask, 00110 float r, float g, float b, float a=1.0); 00111 //: Returns the color value in a format you specify 00112 //: by giving the red, green, blue and alpha 00113 //: masks, along with the corresponding red, blue, 00114 //: green and alpha values. 00124 00125 00126 00127 static unsigned int get_color(CL_Target* target, 00128 int r, int g, int b, int a=255); 00129 //: Returns the color value for the specified 00130 //: red, blue and green integer components, 00131 //: in the same pixel format as the target. 00137 00138 static unsigned int get_color(CL_Target* target, 00139 float r, float g, float b, float a=1.0); 00140 //: Returns the color value for the specified 00141 //: red, blue and green floating point components 00142 //: in the same pixel format as the target. 00147 00148 static float get_color(unsigned int cmask, int color); 00149 //: Takes a color, extracts the color component 00150 // (red, green, blue or alpha) specified by cmask, and 00151 // returns it as a floating point. (The floating point 00152 // value is the amount of the color component divided by 00153 // that color component's maximum value.) 00154 // <p> For example: 00155 // <p> If the red component has a maximum value of 255, 00156 // and the red component of your color was 200, the floating 00157 // point returned would be 200/255 or 0.7843 00161 00162 }; 00163 00164 #endif
1.2.6 written by Dimitri van Heesch,
© 1997-2001