Upload UI
[lsnes.git] / src / library / pixfmt-rgb32.cpp
blob271b5d736f79d9cfdd3bbd09ef069baf0bb987c1
1 #include "pixfmt-rgb32.hpp"
3 pixel_format_rgb32::~pixel_format_rgb32() throw() {}
5 void pixel_format_rgb32::decode(uint32_t* target, const uint8_t* src, size_t width) throw()
7 const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
8 for(size_t i = 0; i < width; i++)
9 target[i] = _src[i];
12 void pixel_format_rgb32::decode(uint32_t* target, const uint8_t* src, size_t width,
13 const pixel_format_aux_palette<false>& auxp) throw()
15 const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
16 for(size_t i = 0; i < width; i++) {
17 target[i] = ((_src[i] >> 16) & 0xFF) << auxp.rshift;
18 target[i] |= ((_src[i] >> 8) & 0xFF) << auxp.gshift;
19 target[i] |= (_src[i] & 0xFF) << auxp.bshift;
23 void pixel_format_rgb32::decode(uint64_t* target, const uint8_t* src, size_t width,
24 const pixel_format_aux_palette<true>& auxp) throw()
26 const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
27 for(size_t i = 0; i < width; i++) {
28 target[i] = static_cast<uint64_t>((_src[i] >> 16) & 0xFF) << auxp.rshift;
29 target[i] |= static_cast<uint64_t>((_src[i] >> 8) & 0xFF) << auxp.gshift;
30 target[i] |= static_cast<uint64_t>(_src[i] & 0xFF) << auxp.bshift;
31 target[i] += (target[i] << 8);
35 void pixel_format_rgb32::set_palette(pixel_format_aux_palette<false>& auxp, uint8_t rshift, uint8_t gshift,
36 uint8_t bshift) throw(std::bad_alloc)
38 auxp.rshift = rshift;
39 auxp.gshift = gshift;
40 auxp.bshift = bshift;
41 auxp.pcache.clear();
44 void pixel_format_rgb32::set_palette(pixel_format_aux_palette<true>& auxp, uint8_t rshift, uint8_t gshift,
45 uint8_t bshift) throw(std::bad_alloc)
47 auxp.rshift = rshift;
48 auxp.gshift = gshift;
49 auxp.bshift = bshift;
50 auxp.pcache.clear();
53 uint8_t pixel_format_rgb32::get_bpp() throw()
55 return 4;
58 uint8_t pixel_format_rgb32::get_ss_bpp() throw()
60 return 3;
63 uint32_t pixel_format_rgb32::get_magic() throw()
65 return 0x74212536U;
68 pixel_format_rgb32 _pixel_format_rgb32;