openMSX
PixelFormat.hh
Go to the documentation of this file.
1#ifndef PIXELFORMAT_HH
2#define PIXELFORMAT_HH
3
4#include <cstdint>
5
6namespace openmsx {
7
9{
10public:
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 [[nodiscard]] unsigned getBpp() const { return bpp; }
23 [[nodiscard]] unsigned getBytesPerPixel() const { return bytesPerPixel; }
24
25 [[nodiscard]] unsigned getRmask() const { return Rmask; }
26 [[nodiscard]] unsigned getGmask() const { return Gmask; }
27 [[nodiscard]] unsigned getBmask() const { return Bmask; }
28 [[nodiscard]] unsigned getAmask() const { return Amask; }
29
30 [[nodiscard]] unsigned getRshift() const { return Rshift; }
31 [[nodiscard]] unsigned getGshift() const { return Gshift; }
32 [[nodiscard]] unsigned getBshift() const { return Bshift; }
33 [[nodiscard]] unsigned getAshift() const { return Ashift; }
34
35 [[nodiscard]] unsigned getRloss() const { return Rloss; }
36 [[nodiscard]] unsigned getGloss() const { return Gloss; }
37 [[nodiscard]] unsigned getBloss() const { return Bloss; }
38 [[nodiscard]] unsigned getAloss() const { return Aloss; }
39
40 [[nodiscard]] 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
48private:
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
int g
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
unsigned getAshift() const
Definition: PixelFormat.hh:33
unsigned getGloss() const
Definition: PixelFormat.hh:36
unsigned getBshift() const
Definition: PixelFormat.hh:32
unsigned map(unsigned r, unsigned g, unsigned b) const
Definition: PixelFormat.hh:40
unsigned getBpp() const
Definition: PixelFormat.hh:22
unsigned getBloss() const
Definition: PixelFormat.hh:37
unsigned getRshift() const
Definition: PixelFormat.hh:30
unsigned getGmask() const
Definition: PixelFormat.hh:26
unsigned getAmask() const
Definition: PixelFormat.hh:28
unsigned getAloss() const
Definition: PixelFormat.hh:38
unsigned getGshift() const
Definition: PixelFormat.hh:31
unsigned getBytesPerPixel() const
Definition: PixelFormat.hh:23
unsigned getRmask() const
Definition: PixelFormat.hh:25
unsigned getBmask() const
Definition: PixelFormat.hh:27
unsigned getRloss() const
Definition: PixelFormat.hh:35
This file implemented 3 utility functions:
Definition: Autofire.cc:9