2 #include "oxygine-include.h" 6 const unsigned char lookupTable4to8[] = {0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255};
7 const unsigned char lookupTable5to8[] = {0, 8, 16, 24, 32, 41, 49, 57, 65, 74, 82, 90, 98, 106, 115, 123, 131, 139, 148, 156, 164, 172, 180, 189, 197, 205, 213, 222, 230, 238, 246, 255};
8 const unsigned char lookupTable6to8[] = {0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 85, 89, 93, 97, 101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 170, 174, 178, 182, 186, 190, 194, 198, 202, 206, 210, 214, 218, 222, 226, 230, 234, 238, 242, 246, 250, 255};
16 unsigned char bytes[4];
21 unsigned char r, g, b, a;
28 inline Pixel initPixel(
unsigned int rgba)
35 inline Pixel initPixel(
unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a)
49 void getPixel(
const unsigned char* data, Pixel& p)
const 57 void setPixel(
unsigned char* data,
const Pixel& p)
62 void copy(
const unsigned char* src,
unsigned char* dst)
64 *((
unsigned char*)dst) = *((
unsigned char*)src);
67 unsigned char snap_a(
unsigned char alpha)
const 76 void getPixel(
const unsigned char* data, Pixel& p)
const 78 unsigned char color = *data;
85 void setPixel(
unsigned char* data,
const Pixel& p)
87 *data = (p.r + p.g + p.b) / 3;
90 void copy(
const unsigned char* src,
unsigned char* dst)
95 unsigned char snap_a(
unsigned char alpha)
const 104 void getPixel(
const unsigned char* data, Pixel& p)
const 106 unsigned char color = *data;
113 void setPixel(
unsigned char* data,
const Pixel& p)
115 *data = (p.r + p.g + p.b) / 3;
118 void copy(
const unsigned char* src,
unsigned char* dst)
123 unsigned char snap_a(
unsigned char alpha)
const 136 void getPixel(
const unsigned char* data, Pixel& p)
const 138 unsigned short color = *((
unsigned short*)data);
139 p.r = lookupTable5to8[(color & 0xF800) >> 11];
140 p.g = lookupTable6to8[(color & 0x7E0) >> 5];
141 p.b = lookupTable5to8[(color & 0x1F)];
145 void setPixel(
unsigned char* data,
const Pixel& p)
147 unsigned short* pshort = (
unsigned short*)data;
148 *pshort = ((p.r >> 3) << 11) | ((p.g >> 2) << 5) | (p.b >> 3);
150 void copy(
const unsigned char* src,
unsigned char* dst)
152 *((
unsigned short*)dst) = *((
unsigned short*)src);
155 unsigned char snap_a(
unsigned char alpha)
const 168 void getPixel(
const unsigned char* data, Pixel& p)
const 170 unsigned short color = *((
unsigned short*)data);
171 p.b = lookupTable5to8[(color & 0xF800) >> 11];
172 p.g = lookupTable6to8[(color & 0x7E0) >> 5];
173 p.r = lookupTable5to8[(color & 0x1F)];
177 void setPixel(
unsigned char* data,
const Pixel& p)
179 unsigned short* pshort = (
unsigned short*)data;
180 *pshort = ((p.b >> 3) << 11) | ((p.g >> 2) << 5) | (p.r >> 3);
182 void copy(
const unsigned char* src,
unsigned char* dst)
184 *((
unsigned short*)dst) = *((
unsigned short*)src);
187 unsigned char snap_a(
unsigned char alpha)
const 237 void getPixel(
const unsigned char* data, Pixel& p)
const 239 unsigned short color = *((
unsigned short*)data);
241 p.r = lookupTable4to8[(color & 0xF000) >> 12];
242 p.g = lookupTable4to8[(color & 0xF00) >> 8];
243 p.b = lookupTable4to8[(color & 0xF0) >> 4];
244 p.a = lookupTable4to8[(color & 0xF)];
254 void setPixel(
unsigned char* data,
const Pixel& p)
256 unsigned short* pshort = (
unsigned short*)data;
257 *pshort = ((p.r >> 4) << 12) | ((p.g >> 4) << 8) | ((p.b >> 4) << 4) | ((p.a >> 4));
259 void copy(
const unsigned char* src,
unsigned char* dst)
261 *((
unsigned short*)dst) = *((
const unsigned short*)src);
264 unsigned char snap_a(
unsigned char alpha)
const 266 return lookupTable4to8[alpha >> 4];
310 void getPixel(
const unsigned char* data, Pixel& p)
const 312 unsigned short color = *((
unsigned short*)data);
314 p.r = lookupTable5to8[(color & 0xF800) >> 11];
315 p.g = lookupTable5to8[(color & 0x7C0) >> 6];
316 p.b = lookupTable5to8[(color & 0x3E) >> 1];
317 p.a = (color & 0x01) * 255;
320 void setPixel(
unsigned char* data,
const Pixel& p)
322 unsigned short* pshort = (
unsigned short*)data;
323 *pshort = ((p.a >> 7)) | ((p.r >> 3) << 11) | ((p.g >> 3) << 6) | ((p.b >> 3) << 1);
326 void copy(
const unsigned char* src,
unsigned char* dst)
328 *((
unsigned short*)dst) = *((
const unsigned short*)src);
330 unsigned char snap_a(
unsigned char alpha)
const 332 return (alpha >> 7) * 255;
342 void getPixel(
const unsigned char* data, Pixel& p)
const 351 void setPixel(
unsigned char* data,
const Pixel& p)
359 void copy(
const unsigned char* src,
unsigned char* dst)
361 *((
unsigned int*)dst) = *((
unsigned int*)src);
364 unsigned char snap_a(
unsigned char alpha)
const 379 void getPixel(
const unsigned char* data, Pixel& p)
const 388 void setPixel(
unsigned char* data,
const Pixel& p)
396 void copy(
const unsigned char* src,
unsigned char* dst)
398 *((
unsigned int*)dst) = *((
unsigned int*)src);
401 unsigned char snap_a(
unsigned char alpha)
const 415 void getPixel(
const unsigned char* data, Pixel& p)
const 423 void setPixel(
unsigned char* data,
const Pixel& p)
431 void copy(
const unsigned char* src,
unsigned char* dst)
433 *((
unsigned int*)dst) = *((
unsigned int*)src);
436 unsigned char snap_a(
unsigned char alpha)
const 450 void getPixel(
const unsigned char* data, Pixel& p)
const 458 void setPixel(
unsigned char* data,
const Pixel& p)
466 void copy(
const unsigned char* src,
unsigned char* dst)
468 *((
unsigned int*)dst) = *((
unsigned int*)src);
471 unsigned char snap_a(
unsigned char alpha)
const 477 class PixelX8R8G8B8 :
public PixelA8R8G8B8 {};
478 class PixelR8G8B8X8 :
public PixelR8G8B8A8 {};
487 PixelR8G8B8(
unsigned char alpha = 255): _alpha(alpha) {}
489 void getPixel(
const unsigned char* data, Pixel& p)
const 498 void setPixel(
unsigned char* data,
const Pixel& p)
505 void copy(
const unsigned char* src,
unsigned char* dst)
507 *((
unsigned short*)dst) = *((
const unsigned short*)src);
510 unsigned char snap_a(
unsigned char alpha)
const 516 unsigned char _alpha;
–oxgl-end–!
Definition: Actor.h:14