40         inline static const Color get(SDL_Surface* surface, Sint16  
x, Sint16  
y)
    42             Sint32  bpp = surface->format->BytesPerPixel;
    46             Uint8 *
p = (Uint8 *)surface->pixels + 
y * surface->pitch + x * bpp;
    61                 if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
    63                     color = p[0] << 16 | p[1] << 8 | p[2];
    67                     color = p[0] | p[1] << 8 | p[2] << 16;
    81             return Color(r,g,b,a);
    89         inline static void put(SDL_Surface* surface, Sint32  x, Sint32  
y, 
const Color& 
color)
    91             Sint32  bpp = surface->format->BytesPerPixel;
    95             Uint8 *
p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
    97             Uint32 pixel = SDL_MapRGB(surface->format, color.
r(), color.
g(), color.
b());
   106                 *(Uint16 *)p = pixel;
   110                 if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
   112                     p[0] = (pixel >> 16) & 0xff;
   113                     p[1] = (pixel >> 8) & 0xff;
   119                     p[1] = (pixel >> 8) & 0xff;
   120                     p[2] = (pixel >> 16) & 0xff;
   125                 *(Uint32 *)p = pixel;
   136         inline static Uint32 
alpha32(Uint32  src, Uint32  dst, Uint8  
a)
   138             Uint32  
b = ((src & 0xff) * a + (dst & 0xff) * (255 - 
a)) >> 8;
   139             Uint32  
g = ((src & 0xff00) * a + (dst & 0xff00) * (255 - 
a)) >> 8;
   140             Uint32  
r = ((src & 0xff0000) * a + (dst & 0xff0000) * (255 - 
a)) >> 8;
   142             return (b & 0xff) | (g & 0xff00) | (r & 0xff0000);
   149         inline static Uint16 
alpha16(Uint16 src, Uint16 dst, Uint8  
a, 
const SDL_PixelFormat *f)
   151             Uint32  
b = ((src & f->Rmask) * a + (dst & f->Rmask) * (255 - 
a)) >> 8;
   152             Uint32  
g = ((src & f->Gmask) * a + (dst & f->Gmask) * (255 - 
a)) >> 8;
   153             Uint32  
r = ((src & f->Bmask) * a + (dst & f->Bmask) * (255 - 
a)) >> 8;
   155             return (Uint16)((b & f->Rmask) | (g & f->Gmask) | (r & f->Bmask));
   177             Uint32 bpp = surface->format->BytesPerPixel;
   181             Uint8 *
p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
   183             Uint32 pixel = SDL_MapRGB(surface->format, color.
r(), color.
g(), color.
b());
   192                 *(Uint16 *)p = 
alpha16(pixel, *(Uint32 *)
p, color.
a(), surface->format);
   196                 if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
   198                     Uint32  
r = (p[0] * (255 - color.
a()) + color.
r() * color.
a()) >> 8;
   199                     Uint32  
g = (p[1] * (255 - color.
a()) + color.
g() * color.
a()) >> 8;
   200                     Uint32  
b = (p[2] * (255 - color.
a()) + color.
b() * color.
a()) >> 8;
   208                     Uint32  
r = (p[2] * (255 - color.
a()) + color.
r() * color.
a()) >> 8;
   209                     Uint32  
g = (p[1] * (255 - color.
a()) + color.
g() * color.
a()) >> 8;
   210                     Uint32  
b = (p[0] * (255 - color.
a()) + color.
b() * color.
a()) >> 8;
   219                 *(Uint32 *)p = 
alpha32(pixel, *(Uint32 *)
p, color.
a());
   230 #endif // SDLTK_PIXEL_H Uint8 a
Definition: pixel.h:76
Uint8 g() const 
Definition: color.h:57
Uint8 a() const 
Definition: color.h:59
static Uint32 alpha32(Uint32 src, Uint32 dst, Uint8 a)
Definition: pixel.h:136
Pixel() ROLAND_DELETE~Pixel() ROLAND_DELETE inline static const Color get(SDL_Surface *surface
Uint8 * p
Definition: pixel.h:46
Sint16 Sint16 y
Definition: pixel.h:41
SDL_GetRGBA(color, surface->format,&r,&g,&b,&a)
static void put(SDL_Surface *surface, Sint32 x, Sint32 y, const Color &color)
Definition: pixel.h:89
Uint8 g
Definition: pixel.h:76
Uint8 r() const 
Definition: color.h:56
Uint8 b
Definition: pixel.h:76
Sint16 x
Definition: pixel.h:40
SDL_UnlockSurface(surface)
Uint32 color
Definition: pixel.h:48
Uint8 b() const 
Definition: color.h:58
static void putAlpha(SDL_Surface *surface, Sint32 x, Sint32 y, const Color &color)
Definition: pixel.h:175
RGBA Color Type. 
Definition: color.h:30
Uint8 r
Definition: pixel.h:76
the SDL based Stuff 
Definition: audio.cpp:22
static Uint16 alpha16(Uint16 src, Uint16 dst, Uint8 a, const SDL_PixelFormat *f)
Definition: pixel.h:149
#define ROLAND_DELETE
Definition: compspec.h:47