You.i Engine
YiBitmap.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_BITMAP_H_
3 #define _YI_BITMAP_H_
4 
5 #include "framework/YiPredef.h"
6 
7 #include <memory>
8 
14 class CYIBitmapPriv;
15 class CYIColor;
16 
20 class CYIBitmap
21 {
22  friend class CYIBitmapPriv;
23 
24 public:
25  enum class Ownership
26  {
27  Shared,
28  Private
29  };
30 
35  enum class ColorMode
36  {
37  RGBA8888,
38  RGBA4444,
39  RGB565
40  };
41 
46  enum class DitheringMode
47  {
48  None = 0,
49  FloydSteinberg
50  };
51 
52  CYIBitmap();
53  virtual ~CYIBitmap();
54 
58  std::unique_ptr<CYIBitmap> Clone() const;
59 
64  virtual bool Create(int32_t width, int32_t height);
65 
72  void Draw(const CYIBitmap &srcImage, int32_t destX, int32_t destY);
73 
80  void Draw(const CYIBitmap &srcImage, int32_t destX, int32_t destY, const YI_RECT_REL &clipRegion);
81 
88  void Draw(const CYIBitmap &srcImage, int32_t destX, int32_t destY, int32_t clipWidth, int32_t clipHeight);
89 
96  void DrawScale(const CYIBitmap &srcImage, const YI_RECT_REL *pDest, const YI_RECT_REL *pSrc);
97 
101  void Fill(const CYIColor &color);
102 
106  void Fill(const CYIColor &color, const YI_RECT &region);
107 
112  const uint32_t *GetPixels() const;
113 
118  uint32_t *GetPixels();
119 
123  void FreePixels();
124 
128  virtual int32_t GetHeight() const;
129 
135  void ReduceHeightTo(int32_t newHeight);
136 
140  virtual int32_t GetWidth() const;
141 
147  int32_t GetXPitch() const;
148 
154  int32_t GetYPitch() const;
155 
159  virtual int32_t GetDepth() const;
160 
164  uint32_t GetBytesPerPixel() const;
165 
169  virtual size_t GetSize() const;
170 
179  void SetPixels(uint32_t *pBits, int32_t width, int32_t height, Ownership ownership = Ownership::Private);
180 
184  void SetPixel(int32_t x, int32_t y, const CYIColor &color);
185 
191  virtual void SetPixelPacked(int32_t x, int32_t y, uint32_t color);
192 
198  void SetPixelRaw(int32_t x, int32_t y, uint32_t color);
199 
203  CYIColor GetPixel(int32_t x, int32_t y) const;
204 
210  virtual uint32_t GetPixelPacked(int32_t x, int32_t y) const;
211 
217  uint32_t GetPixelRaw(int32_t x, int32_t y) const;
218 
223  ColorMode GetColorMode() const;
224 
228  std::unique_ptr<CYIBitmap> ToColorMode(ColorMode colorMode, DitheringMode ditheringMode = DitheringMode::None) const;
229 
233  bool operator==(const CYIBitmap &other) const;
234 
238  bool operator!=(const CYIBitmap &other) const;
239 
240 private:
241  std::unique_ptr<CYIBitmapPriv> m_pPriv;
242  CYIBitmap(std::unique_ptr<CYIBitmapPriv> pPriv);
243  CYIBitmap(const CYIBitmap &other);
244  CYIBitmap &operator=(const CYIBitmap &other) = delete;
245 };
246 
249 #endif // _YI_BITMAP_H_
virtual ~CYIBitmap()
ColorMode GetColorMode() const
virtual void SetPixelPacked(int32_t x, int32_t y, uint32_t color)
int32_t GetXPitch() const
std::unique_ptr< CYIBitmap > Clone() const
Definition: YiPredef.h:291
int32_t GetYPitch() const
virtual uint32_t GetPixelPacked(int32_t x, int32_t y) const
std::unique_ptr< CYIBitmap > ToColorMode(ColorMode colorMode, DitheringMode ditheringMode=DitheringMode::None) const
Definition: YiPredef.h:197
The core bitmap container class used by You.i Engine.
Definition: YiBitmap.h:20
void Draw(const CYIBitmap &srcImage, int32_t destX, int32_t destY)
void SetPixels(uint32_t *pBits, int32_t width, int32_t height, Ownership ownership=Ownership::Private)
void DrawScale(const CYIBitmap &srcImage, const YI_RECT_REL *pDest, const YI_RECT_REL *pSrc)
void ReduceHeightTo(int32_t newHeight)
constexpr std::enable_if< YiEnableBitmaskOperators< E >::enable, bool >::type None(E a)
Definition: YiEnumBitmaskOperators.h:136
friend class CYIBitmapPriv
Definition: YiBitmap.h:22
virtual int32_t GetDepth() const
uint32_t GetBytesPerPixel() const
CYIColor GetPixel(int32_t x, int32_t y) const
ColorMode
Definition: YiBitmap.h:35
const uint32_t * GetPixels() const
void FreePixels()
void SetPixel(int32_t x, int32_t y, const CYIColor &color)
virtual size_t GetSize() const
Ownership
Definition: YiBitmap.h:25
virtual int32_t GetHeight() const
void SetPixelRaw(int32_t x, int32_t y, uint32_t color)
DitheringMode
Definition: YiBitmap.h:46
virtual bool Create(int32_t width, int32_t height)
A class used to represent a color value.
Definition: YiColor.h:31
bool operator!=(const CYIBitmap &other) const
virtual int32_t GetWidth() const
void Fill(const CYIColor &color)
uint32_t GetPixelRaw(int32_t x, int32_t y) const
bool operator==(const CYIBitmap &other) const