1 #include "framebuffer-pixfmt-rgb16.hpp"
6 _pixfmt_rgb16
<uvswap
>::~_pixfmt_rgb16() throw()
11 void _pixfmt_rgb16
<uvswap
>::decode(uint32_t* target
, const uint8_t* src
, size_t width
) throw()
13 const uint16_t* _src
= reinterpret_cast<const uint16_t*>(src
);
14 for(size_t i
= 0; i
< width
; i
++) {
15 uint32_t word
= _src
[i
];
16 uint64_t r
= ((word
>> (uvswap
? 11 : 0)) & 0x1F);
17 uint64_t g
= ((word
>> 5) & 0x3F);
18 uint64_t b
= ((word
>> (uvswap
? 0 : 11)) & 0x1F);
19 target
[i
] = (((r
<< 8) - r
+ 15) / 31) << 16;
20 target
[i
] |= (((g
<< 8) - g
+ 31) / 63) << 8;
21 target
[i
] |= ((b
<< 8) - b
+ 15) / 31;
26 void _pixfmt_rgb16
<uvswap
>::decode(uint32_t* target
, const uint8_t* src
, size_t width
,
27 const auxpalette
<false>& auxp
) throw()
29 const uint16_t* _src
= reinterpret_cast<const uint16_t*>(src
);
30 for(size_t i
= 0; i
< width
; i
++)
31 target
[i
] = auxp
.pcache
[_src
[i
]];
35 void _pixfmt_rgb16
<uvswap
>::decode(uint64_t* target
, const uint8_t* src
, size_t width
,
36 const auxpalette
<true>& auxp
) throw()
38 const uint16_t* _src
= reinterpret_cast<const uint16_t*>(src
);
39 for(size_t i
= 0; i
< width
; i
++)
40 target
[i
] = auxp
.pcache
[_src
[i
]];
44 void _pixfmt_rgb16
<uvswap
>::set_palette(auxpalette
<false>& auxp
, uint8_t rshift
, uint8_t gshift
,
45 uint8_t bshift
) throw(std::bad_alloc
)
47 auxp
.pcache
.resize(0x10000);
48 for(size_t i
= 0; i
< 0x10000; i
++) {
49 uint32_t r
= ((i
>> (uvswap
? 11 : 0)) & 0x1F);
50 uint32_t g
= ((i
>> 5) & 0x3F);
51 uint32_t b
= ((i
>> (uvswap
? 0 : 11)) & 0x1F);
52 auxp
.pcache
[i
] = (((r
<< 8) - r
+ 15) / 31) << rshift
;
53 auxp
.pcache
[i
] += (((g
<< 8) - g
+ 31) / 63) << gshift
;
54 auxp
.pcache
[i
] += (((b
<< 8) - b
+ 15) / 31) << bshift
;
62 void _pixfmt_rgb16
<uvswap
>::set_palette(auxpalette
<true>& auxp
, uint8_t rshift
, uint8_t gshift
,
63 uint8_t bshift
) throw(std::bad_alloc
)
65 auxp
.pcache
.resize(0x10000);
66 for(size_t i
= 0; i
< 0x10000; i
++) {
67 uint64_t r
= ((i
>> (uvswap
? 11 : 0)) & 0x1F);
68 uint64_t g
= ((i
>> 5) & 0x3F);
69 uint64_t b
= ((i
>> (uvswap
? 0 : 11)) & 0x1F);
70 auxp
.pcache
[i
] = (((r
<< 16) - r
+ 15) / 31) << rshift
;
71 auxp
.pcache
[i
] += (((g
<< 16) - g
+ 31) / 63) << gshift
;
72 auxp
.pcache
[i
] += (((b
<< 16) - b
+ 15) / 31) << bshift
;
80 uint8_t _pixfmt_rgb16
<uvswap
>::get_bpp() throw()
86 uint8_t _pixfmt_rgb16
<uvswap
>::get_ss_bpp() throw()
92 uint32_t _pixfmt_rgb16
<uvswap
>::get_magic() throw()
100 _pixfmt_rgb16
<false> pixfmt_rgb16
;
101 _pixfmt_rgb16
<true> pixfmt_bgr16
;