1 #include "framebuffer-pixfmt-lrgb.hpp"
2 #include "framebuffer.hpp"
6 _pixfmt_lrgb::~_pixfmt_lrgb() throw()
10 void _pixfmt_lrgb::decode(uint32_t* target
, const uint8_t* src
, size_t width
)
13 const uint32_t* _src
= reinterpret_cast<const uint32_t*>(src
);
14 for(size_t i
= 0; i
< width
; i
++) {
15 uint32_t word
= _src
[i
];
16 uint32_t l
= 1 + ((word
>> 15) & 0xF);
17 uint32_t r
= l
* ((word
>> 0) & 0x1F);
18 uint32_t g
= l
* ((word
>> 5) & 0x1F);
19 uint32_t b
= l
* ((word
>> 10) & 0x1F);
20 uint32_t x
= (((r
<< 8) - r
+ 248) / 496) << 16;
21 x
|= (((g
<< 8) - g
+ 248) / 496) << 8;
22 x
|= ((b
<< 8) - b
+ 248) / 496;
27 void _pixfmt_lrgb::decode(uint32_t* target
, const uint8_t* src
, size_t width
,
28 const auxpalette
<false>& auxp
) throw()
30 const uint32_t* _src
= reinterpret_cast<const uint32_t*>(src
);
31 for(size_t i
= 0; i
< width
; i
++)
32 target
[i
] = auxp
.pcache
[_src
[i
] & 0x7FFFF];
35 void _pixfmt_lrgb::decode(uint64_t* target
, const uint8_t* src
, size_t width
,
36 const auxpalette
<true>& auxp
) throw()
38 const uint32_t* _src
= reinterpret_cast<const uint32_t*>(src
);
39 for(size_t i
= 0; i
< width
; i
++)
40 target
[i
] = auxp
.pcache
[_src
[i
] & 0x7FFFF];
43 void _pixfmt_lrgb::set_palette(auxpalette
<false>& auxp
, uint8_t rshift
, uint8_t gshift
,
44 uint8_t bshift
) throw(std::bad_alloc
)
46 auxp
.pcache
.resize(0x80000);
47 for(size_t i
= 0; i
< 0x80000; i
++) {
48 uint32_t l
= 1 + ((i
>> 15) & 0xF);
49 uint32_t r
= l
* ((i
>> 0) & 0x1F);
50 uint32_t g
= l
* ((i
>> 5) & 0x1F);
51 uint32_t b
= l
* ((i
>> 10) & 0x1F);
52 auxp
.pcache
[i
] = (((r
<< 8) - r
+ 248) / 496) << rshift
;
53 auxp
.pcache
[i
] += (((g
<< 8) - g
+ 248) / 496) << gshift
;
54 auxp
.pcache
[i
] += (((b
<< 8) - b
+ 248) / 496) << bshift
;
61 void _pixfmt_lrgb::set_palette(auxpalette
<true>& auxp
, uint8_t rshift
, uint8_t gshift
,
62 uint8_t bshift
) throw(std::bad_alloc
)
64 auxp
.pcache
.resize(0x80000);
65 for(size_t i
= 0; i
< 0x80000; i
++) {
66 uint64_t l
= 1 + ((i
>> 15) & 0xF);
67 uint64_t r
= l
* ((i
>> 0) & 0x1F);
68 uint64_t g
= l
* ((i
>> 5) & 0x1F);
69 uint64_t b
= l
* ((i
>> 10) & 0x1F);
70 auxp
.pcache
[i
] = (((r
<< 16) - r
+ 248) / 496) << rshift
;
71 auxp
.pcache
[i
] += (((g
<< 16) - g
+ 248) / 496) << gshift
;
72 auxp
.pcache
[i
] += (((b
<< 16) - b
+ 248) / 496) << bshift
;
79 uint8_t _pixfmt_lrgb::get_bpp() throw()
84 uint8_t _pixfmt_lrgb::get_ss_bpp() throw()
89 uint32_t _pixfmt_lrgb::get_magic() throw()
94 _pixfmt_lrgb pixfmt_lrgb
;