openMSX
PixelFormat.hh
Go to the documentation of this file.
1 #ifndef PIXELFORMAT_HH
2 #define PIXELFORMAT_HH
3 
4 #include <cstdint>
5 
6 namespace openmsx {
7 
9 {
10 public:
11  PixelFormat() = default;
12  PixelFormat(unsigned bpp_,
13  uint32_t Rmask_, uint8_t Rshift_, uint8_t Rloss_,
14  uint32_t Gmask_, uint8_t Gshift_, uint8_t Gloss_,
15  uint32_t Bmask_, uint8_t Bshift_, uint8_t Bloss_,
16  uint32_t Amask_, uint8_t Ashift_, uint8_t Aloss_)
17  : Rmask (Rmask_), Gmask (Gmask_), Bmask (Bmask_), Amask (Amask_)
18  , Rshift(Rshift_), Gshift(Gshift_), Bshift(Bshift_), Ashift(Ashift_)
19  , Rloss (Rloss_), Gloss (Gloss_), Bloss (Bloss_), Aloss (Aloss_)
20  , bpp(bpp_), bytesPerPixel((bpp + 7) / 8) {}
21 
22  unsigned getBpp() const { return bpp; }
23  unsigned getBytesPerPixel() const { return bytesPerPixel; }
24 
25  unsigned getRmask() const { return Rmask; }
26  unsigned getGmask() const { return Gmask; }
27  unsigned getBmask() const { return Bmask; }
28  unsigned getAmask() const { return Amask; }
29 
30  unsigned getRshift() const { return Rshift; }
31  unsigned getGshift() const { return Gshift; }
32  unsigned getBshift() const { return Bshift; }
33  unsigned getAshift() const { return Ashift; }
34 
35  unsigned getRloss() const { return Rloss; }
36  unsigned getGloss() const { return Gloss; }
37  unsigned getBloss() const { return Bloss; }
38  unsigned getAloss() const { return Aloss; }
39 
40  unsigned map(unsigned r, unsigned g, unsigned b) const
41  {
42  return ((r >> Rloss) << Rshift) |
43  ((g >> Gloss) << Gshift) |
44  ((b >> Bloss) << Bshift) |
45  Amask;
46  }
47 
48 private:
49  uint32_t Rmask, Gmask, Bmask, Amask;
50  uint8_t Rshift, Gshift, Bshift, Ashift;
51  uint8_t Rloss, Gloss, Bloss, Aloss;
52  uint8_t bpp, bytesPerPixel;
53 };
54 
55 } // namespace openmsx
56 
57 #endif
openmsx::PixelFormat::PixelFormat
PixelFormat()=default
openmsx::PixelFormat::getGmask
unsigned getGmask() const
Definition: PixelFormat.hh:26
openmsx::PixelFormat::getRloss
unsigned getRloss() const
Definition: PixelFormat.hh:35
openmsx::PixelFormat::getGshift
unsigned getGshift() const
Definition: PixelFormat.hh:31
openmsx::PixelFormat
Definition: PixelFormat.hh:8
openmsx::PixelFormat::getBloss
unsigned getBloss() const
Definition: PixelFormat.hh:37
openmsx::PixelFormat::getGloss
unsigned getGloss() const
Definition: PixelFormat.hh:36
openmsx::PixelFormat::getRmask
unsigned getRmask() const
Definition: PixelFormat.hh:25
openmsx::PixelFormat::getBmask
unsigned getBmask() const
Definition: PixelFormat.hh:27
openmsx::PixelFormat::getAshift
unsigned getAshift() const
Definition: PixelFormat.hh:33
openmsx::PixelFormat::getBytesPerPixel
unsigned getBytesPerPixel() const
Definition: PixelFormat.hh:23
openmsx::PixelFormat::getAmask
unsigned getAmask() const
Definition: PixelFormat.hh:28
openmsx::PixelFormat::map
unsigned map(unsigned r, unsigned g, unsigned b) const
Definition: PixelFormat.hh:40
g
int g
Definition: ScopedAssign_test.cc:20
openmsx::PixelFormat::getBpp
unsigned getBpp() const
Definition: PixelFormat.hh:22
openmsx::PixelFormat::PixelFormat
PixelFormat(unsigned bpp_, uint32_t Rmask_, uint8_t Rshift_, uint8_t Rloss_, uint32_t Gmask_, uint8_t Gshift_, uint8_t Gloss_, uint32_t Bmask_, uint8_t Bshift_, uint8_t Bloss_, uint32_t Amask_, uint8_t Ashift_, uint8_t Aloss_)
Definition: PixelFormat.hh:12
openmsx::PixelFormat::getRshift
unsigned getRshift() const
Definition: PixelFormat.hh:30
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::PixelFormat::getAloss
unsigned getAloss() const
Definition: PixelFormat.hh:38
openmsx::PixelFormat::getBshift
unsigned getBshift() const
Definition: PixelFormat.hh:32