(986a3bf)
#include "gui/color.h"
#include <SDL.h>
Go to the source code of this file.
|
void | SDLputPixel (SDL_Surface *surface, int x, int y, const Color &color) |
|
unsigned int | SDLAlpha32 (const unsigned int src, const unsigned int dst, const unsigned char a) |
|
unsigned short | SDLAlpha16 (const unsigned short src, const unsigned short dst, const unsigned char a, const SDL_PixelFormat *const f) |
|
void | SDLputPixelAlpha (SDL_Surface *surface, int x, int y, const Color &color) |
|
◆ SDLAlpha16()
unsigned short SDLAlpha16 |
( |
const unsigned short |
src, |
|
|
const unsigned short |
dst, |
|
|
const unsigned char |
a, |
|
|
const SDL_PixelFormat *const |
f |
|
) |
| |
|
inline |
Blends two 16 bit colors together.
- Parameters
-
src | the source color. |
dst | the destination color. |
a | alpha. |
Definition at line 170 of file sdlpixel.h.
175 unsigned int b = ((src & f->Rmask) * a + (dst & f->Rmask)
177 unsigned int g = ((src & f->Gmask) * a + (dst & f->Gmask)
179 unsigned int r = ((src & f->Bmask) * a + (dst & f->Bmask)
182 return static_cast<unsigned short>((b & f->Rmask)
183 | (g & f->Gmask) | (r & f->Bmask));
Referenced by SDLputPixelAlpha().
◆ SDLAlpha32()
unsigned int SDLAlpha32 |
( |
const unsigned int |
src, |
|
|
const unsigned int |
dst, |
|
|
const unsigned char |
a |
|
) |
| |
|
inline |
Blends two 32 bit colors together.
- Parameters
-
src | the source color. |
dst | the destination color. |
a | alpha. |
Definition at line 145 of file sdlpixel.h.
149 const unsigned int b = ((src & 0xff) * a + (dst & 0xff) * (255 - a)) >> 8;
150 const unsigned int g = ((src & 0xff00) * a + (dst & 0xff00)
152 const unsigned int r = ((src & 0xff0000) * a + (dst & 0xff0000)
155 return (b & 0xff) | (g & 0xff00) | (r & 0xff0000);
Referenced by SDLputPixelAlpha().
◆ SDLputPixel()
void SDLputPixel |
( |
SDL_Surface * |
surface, |
|
|
int |
x, |
|
|
int |
y, |
|
|
const Color & |
color |
|
) |
| |
|
inline |
Puts a pixel on an SDL_Surface.
- Parameters
-
x | the x coordinate on the surface. |
y | the y coordinate on the surface. |
color | the color the pixel should be in. |
Definition at line 86 of file sdlpixel.h.
89 if (surface ==
nullptr)
92 const int bpp = surface->format->BytesPerPixel;
94 SDL_LockSurface(surface);
96 Uint8 *
const p =
static_cast<uint8_t*
>(surface->pixels)
99 const Uint32 pixel = SDL_MapRGB(surface->format,
110 *
reinterpret_cast<uint16_t*
>(p) =
CAST_U16(pixel);
114 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
115 p[0] =
CAST_U8((pixel >> 16) & 0xff);
116 p[1] =
CAST_U8((pixel >> 8) & 0xff);
117 p[2] =
CAST_U8((pixel) & 0xff);
120 p[0] =
CAST_U8((pixel) & 0xff);
121 p[1] =
CAST_U8((pixel >> 8) & 0xff);
122 p[2] =
CAST_U8((pixel >> 16) & 0xff);
128 *
reinterpret_cast<Uint32*
>(p) = pixel;
135 SDL_UnlockSurface(surface);
References Color::b, CAST_SIZE, CAST_U16, CAST_U8, Color::g, Color::r, x, and y.
◆ SDLputPixelAlpha()
void SDLputPixelAlpha |
( |
SDL_Surface * |
surface, |
|
|
int |
x, |
|
|
int |
y, |
|
|
const Color & |
color |
|
) |
| |
|
inline |
Puts a pixel on an SDL_Surface with alpha
- Parameters
-
x | the x coordinate on the surface. |
y | the y coordinate on the surface. |
color | the color the pixel should be in. |
Definition at line 193 of file sdlpixel.h.
196 if (surface ==
nullptr)
198 const int bpp = surface->format->BytesPerPixel;
200 SDL_LockSurface(surface);
202 Uint8 *
const p =
static_cast<uint8_t*
>(surface->pixels)
205 const Uint32 pixel = SDL_MapRGB(surface->format,
218 static_cast<unsigned short>(pixel),
219 *
reinterpret_cast<unsigned short*
>(p),
224 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
225 p[2] =
CAST_U8((p[2] * (255 - color.
a)
226 + color.
b * color.
a) >> 8);
227 p[1] =
CAST_U8((p[1] * (255 - color.
a)
228 + color.
g * color.
a) >> 8);
229 p[0] =
CAST_U8((p[0] * (255 - color.
a)
230 + color.
r * color.
a) >> 8);
233 p[0] =
CAST_U8((p[0] * (255 - color.
a)
234 + color.
b * color.
a) >> 8);
235 p[1] =
CAST_U8((p[1] * (255 - color.
a)
236 + color.
g * color.
a) >> 8);
237 p[2] =
CAST_U8((p[2] * (255 - color.
a)
238 + color.
r * color.
a) >> 8);
244 *
reinterpret_cast<Uint32*
>(p) =
SDLAlpha32(pixel,
245 *
reinterpret_cast<Uint32*
>(p),
252 SDL_UnlockSurface(surface);
unsigned int SDLAlpha32(const unsigned int src, const unsigned int dst, const unsigned char a)
unsigned short SDLAlpha16(const unsigned short src, const unsigned short dst, const unsigned char a, const SDL_PixelFormat *const f)
References Color::a, Color::b, CAST_SIZE, CAST_U8, Color::g, Color::r, SDLAlpha16(), SDLAlpha32(), x, and y.