CGeneralBitmap.h
Go to the documentation of this file.
1 #ifndef iimg_CGeneralBitmap_included
2 #define iimg_CGeneralBitmap_included
3 
4 
5 // ACF includes
6 #include <istd/TOptDelPtr.h>
7 #include <iimg/CBitmapBase.h>
8 
9 
10 namespace iimg
11 {
12 
13 
18 {
19 public:
21  CGeneralBitmap(const CGeneralBitmap& bitmap);
22 
23  // reimplemented (iimg::IBitmap)
24  virtual bool IsFormatSupported(PixelFormat pixelFormat) const;
25  virtual PixelFormat GetPixelFormat() const;
26  virtual bool CreateBitmap(PixelFormat pixelFormat, const istd::CIndex2d& size, int pixelBitsCount = 0, int componentsCount = 0);
27  virtual bool CreateBitmap(PixelFormat pixelFormat, const istd::CIndex2d& size, void* dataPtr, bool releaseFlag, int linesDifference = 0);
28  virtual int GetLinesDifference() const;
29  virtual int GetPixelsDifference() const;
30  virtual int GetPixelBitsCount() const;
31  virtual const void* GetLinePtr(int positionY) const;
32  virtual void* GetLinePtr(int positionY);
33 
34  // reimplemented (iimg::IRasterImage)
35  virtual void ResetImage();
36  virtual void ClearImage();
37  virtual istd::CIndex2d GetImageSize() const;
38  virtual int GetComponentsCount() const;
39 
40  // reimplemented (istd::IChangeable)
41  virtual int GetSupportedOperations() const;
42  virtual bool CopyFrom(const istd::IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS);
44 
45  // operators
46  CGeneralBitmap& operator=(const CGeneralBitmap& bitmap);
47  bool operator==(const CGeneralBitmap& bitmap) const;
48  bool operator!=(const CGeneralBitmap& bitmap) const;
49 
50 protected:
58  virtual bool CreateBitmap(
59  const istd::CIndex2d& size,
60  int pixelBitsCount,
61  int componentsCount,
62  PixelFormat pixelFormat);
63 
74  virtual bool CreateBitmap(
75  const istd::CIndex2d& size,
76  void* dataPtr,
77  bool releaseFlag,
78  int linesDifference,
79  int pixelBitsCount,
80  int componentsCount,
81  PixelFormat pixelFormat);
82 
83 private:
85 
86  istd::CIndex2d m_size;
87  int m_linesDifference;
88  int m_pixelBitsCount;
89  int m_componentsCount;
90  PixelFormat m_pixelFormat;
91 };
92 
93 
94 // inline methods
95 
96 // reimplemented (iimg::IBitmap)
97 
99 {
100  return m_linesDifference;
101 }
102 
103 
105 {
106  return m_pixelBitsCount >> 3;
107 }
108 
109 
111 {
112  return m_pixelBitsCount;
113 }
114 
115 
116 inline const void* CGeneralBitmap::GetLinePtr(int positionY) const
117 {
118  Q_ASSERT(positionY >= 0);
119  Q_ASSERT(positionY < m_size.GetY());
120 
121  return m_buffer.GetPtr() + m_linesDifference * positionY;
122 }
123 
124 
125 inline void* CGeneralBitmap::GetLinePtr(int positionY)
126 {
127  Q_ASSERT(positionY >= 0);
128  Q_ASSERT(positionY < m_size.GetY());
129 
130  return m_buffer.GetPtr() + m_linesDifference * positionY;
131 }
132 
133 
134 // reimplemented (iimg::IRasterImage)
135 
137 {
138  return m_size;
139 }
140 
141 
143 {
144  return m_componentsCount;
145 }
146 
147 
148 } // namespace iimg
149 
150 
151 #endif // !iimg_CGeneralBitmap_included
152 
153 
virtual int GetComponentsCount() const
Get number of color components.
External references are simple ignored.
Definition: IChangeable.h:197
CompatibilityMode
Control how relationship betweeen objects are interpreted.
Definition: IChangeable.h:186
virtual int GetPixelsDifference() const
Get address difference between next and previous pixel.
virtual int GetPixelBitsCount() const
Get total number of bits per single pixel.
virtual PixelFormat GetPixelFormat() const
Get the bitmap's pixel format.
Index implementation for addressing elements in 2D-space.
Definition: CIndex2d.h:20
CGeneralBitmap & operator=(const CGeneralBitmap &bitmap)
PixelFormat
Bitmap pixel format description.
Definition: IBitmap.h:23
virtual bool CreateBitmap(PixelFormat pixelFormat, const istd::CIndex2d &size, int pixelBitsCount=0, int componentsCount=0)
Create bitmap with specified size and format.
virtual int GetLinesDifference() const
Get address difference between next and previous line.
bool operator==(const CGeneralBitmap &bitmap) const
virtual void ClearImage()
Cleat this image.
Standard device- and platform-independent bitmap definition.
virtual void ResetImage()
Reset this image.
Common interface for data model objects, which can be changed.
Definition: IChangeable.h:24
Type * GetPtr() const
Return access to internal stored pointer.
Definition: TPointerBase.h:129
Base implementation of some iimg::IBitmap methods.
Definition: CBitmapBase.h:17
bool operator!=(const CGeneralBitmap &bitmap) const
virtual istd::IChangeable * CloneMe(CompatibilityMode mode=CM_WITHOUT_REFS) const
Make a copy of this object.
virtual int GetSupportedOperations() const
Get set of flags for supported operations.
int GetY() const
Definition: CIndex2d.h:108
virtual bool IsFormatSupported(PixelFormat pixelFormat) const
Get true if the pixel format is supported by the bitmap implementation.
virtual const void * GetLinePtr(int positionY) const
Get pointer to buffer for single line.
virtual istd::CIndex2d GetImageSize() const
Get size of this raster image.
virtual bool CopyFrom(const istd::IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS)
Copy this object from another one.

© 2007-2017 Witold Gantzke and Kirill Lepskiy