00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "mx_types.h"
00017
00018
00019
00020
00021
00022 namespace mx
00023 {
00024
00025
00026 Color::Color()
00027 {
00028
00029 color.value = 0;
00030 }
00031
00032 Color::Color(const __Color &c)
00033 {
00034 color = c;
00035 }
00036
00037 Color::Color(unsigned char r, unsigned char g, unsigned char b)
00038 {
00039
00040 color.colors[0] = r, color.colors[1] = g, color.colors[2] = b;
00041 }
00042
00043
00044 Color::Color(const unsigned int value)
00045 {
00046 color.value = value;
00047 }
00048
00049
00050 Color::Color(const Color &c)
00051 {
00052 color = c.color;
00053 }
00054
00055 Color::Color(const SDL_Color &c)
00056 {
00057
00058 color.colors[0] = c.r;
00059 color.colors[1] = c.g;
00060 color.colors[2] = c.b;
00061
00062 }
00063
00064 Color &Color::operator=(const Color &c)
00065 {
00066 color = c.color;
00067 return *this;
00068 }
00069
00070 Color &Color::operator=(const unsigned int long_x)
00071 {
00072
00073 color.value = long_x;
00074 return *this;
00075
00076 }
00077 Color &Color::operator=(const SDL_Color &c)
00078 {
00079
00080 color.colors[0] = c.r;
00081 color.colors[1] = c.g;
00082 color.colors[2] = c.b;
00083 return *this;
00084 }
00085
00086 const SDL_Color Color::toSDL_Color() const
00087 {
00088
00089 SDL_Color col = { color.colors[0], color.colors[1], color.colors[2], 0 };
00090 return col;
00091
00092 }
00093
00094 const unsigned int Color::toInteger() const
00095 {
00096 return color.value;
00097 }
00098
00099 SDL_Surface *CreateBuffer(size_t w, size_t h)
00100 {
00101
00102 SDL_Surface *surface;
00103
00104 static int rmask, gmask, bmask, amask;
00105 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
00106 rmask = 0xff000000;
00107 gmask = 0x00ff0000;
00108 bmask = 0x0000ff00;
00109 amask = 0x000000ff;
00110 #else
00111 rmask = 0x000000ff;
00112 gmask = 0x0000ff00;
00113 bmask = 0x00ff0000;
00114 amask = 0xff000000;
00115 #endif
00116
00117 surface = SDL_CreateRGBSurface(SDL_SWSURFACE , w, h, 32, rmask, gmask,bmask, amask);
00118 return surface;
00119 }
00120
00121
00122 }
00123
00124