1 #include "pixfmt-lrgb.hpp"
3 pixel_format_lrgb::~pixel_format_lrgb() throw()
7 void pixel_format_lrgb::decode(uint32_t* target
, const uint8_t* src
, size_t width
)
10 const uint32_t* _src
= reinterpret_cast<const uint32_t*>(src
);
11 for(size_t i
= 0; i
< width
; i
++) {
12 uint32_t word
= _src
[i
];
13 uint32_t l
= 1 + ((word
>> 15) & 0xF);
14 uint32_t r
= l
* ((word
>> 0) & 0x1F);
15 uint32_t g
= l
* ((word
>> 5) & 0x1F);
16 uint32_t b
= l
* ((word
>> 10) & 0x1F);
17 uint32_t x
= (((r
<< 8) - r
+ 248) / 496) << 16;
18 x
|= (((g
<< 8) - g
+ 248) / 496) << 8;
19 x
|= ((b
<< 8) - b
+ 248) / 496;
24 void pixel_format_lrgb::decode(uint32_t* target
, const uint8_t* src
, size_t width
,
25 const pixel_format_aux_palette
<false>& auxp
) throw()
27 const uint32_t* _src
= reinterpret_cast<const uint32_t*>(src
);
28 for(size_t i
= 0; i
< width
; i
++)
29 target
[i
] = auxp
.pcache
[_src
[i
] & 0x7FFFF];
32 void pixel_format_lrgb::decode(uint64_t* target
, const uint8_t* src
, size_t width
,
33 const pixel_format_aux_palette
<true>& auxp
) throw()
35 const uint32_t* _src
= reinterpret_cast<const uint32_t*>(src
);
36 for(size_t i
= 0; i
< width
; i
++)
37 target
[i
] = auxp
.pcache
[_src
[i
] & 0x7FFFF];
40 void pixel_format_lrgb::set_palette(pixel_format_aux_palette
<false>& auxp
, uint8_t rshift
, uint8_t gshift
,
41 uint8_t bshift
) throw(std::bad_alloc
)
43 auxp
.pcache
.resize(0x80000);
44 for(size_t i
= 0; i
< 0x80000; i
++) {
45 uint32_t l
= 1 + ((i
>> 15) & 0xF);
46 uint32_t r
= l
* ((i
>> 0) & 0x1F);
47 uint32_t g
= l
* ((i
>> 5) & 0x1F);
48 uint32_t b
= l
* ((i
>> 10) & 0x1F);
49 auxp
.pcache
[i
] = (((r
<< 8) - r
+ 248) / 496) << rshift
;
50 auxp
.pcache
[i
] += (((g
<< 8) - g
+ 248) / 496) << gshift
;
51 auxp
.pcache
[i
] += (((b
<< 8) - b
+ 248) / 496) << bshift
;
58 void pixel_format_lrgb::set_palette(pixel_format_aux_palette
<true>& auxp
, uint8_t rshift
, uint8_t gshift
,
59 uint8_t bshift
) throw(std::bad_alloc
)
61 auxp
.pcache
.resize(0x80000);
62 for(size_t i
= 0; i
< 0x80000; i
++) {
63 uint64_t l
= 1 + ((i
>> 15) & 0xF);
64 uint64_t r
= l
* ((i
>> 0) & 0x1F);
65 uint64_t g
= l
* ((i
>> 5) & 0x1F);
66 uint64_t b
= l
* ((i
>> 10) & 0x1F);
67 auxp
.pcache
[i
] = (((r
<< 16) - r
+ 248) / 496) << rshift
;
68 auxp
.pcache
[i
] += (((g
<< 16) - g
+ 248) / 496) << gshift
;
69 auxp
.pcache
[i
] += (((b
<< 16) - b
+ 248) / 496) << bshift
;
76 uint8_t pixel_format_lrgb::get_bpp() throw()
81 uint8_t pixel_format_lrgb::get_ss_bpp() throw()
86 uint32_t pixel_format_lrgb::get_magic() throw()
91 pixel_format_lrgb _pixel_format_lrgb
;