ACF $AcfVersion:0$
CGeneralBitmap.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4// ACF includes
5#include <istd/TOptDelPtr.h>
6#include <iimg/CBitmapBase.h>
7
8
9namespace iimg
10{
11
12
20{
21public:
23
26
27 // reimplemented (iimg::IBitmap)
28 virtual bool IsFormatSupported(PixelFormat pixelFormat) const override;
29 virtual PixelFormat GetPixelFormat() const override;
30 virtual bool CreateBitmap(PixelFormat pixelFormat, const istd::CIndex2d& size, int pixelBitsCount = 0, int componentsCount = 0) override;
31 virtual bool CreateBitmap(PixelFormat pixelFormat, const istd::CIndex2d& size, void* dataPtr, bool releaseFlag, int linesDifference = 0) override;
32 virtual int GetLinesDifference() const override;
33 virtual int GetPixelsDifference() const override;
34 virtual const void* GetLinePtr(int positionY) const override;
35 virtual void* GetLinePtr(int positionY) override;
36
37 // reimplemented (iimg::IRasterImage)
38 virtual void ResetImage() override;
39 virtual void ClearImage() override;
40 virtual istd::CIndex2d GetImageSize() const override;
41
42 // reimplemented (istd::IChangeable)
43 virtual int GetSupportedOperations() const override;
44 virtual bool CopyFrom(const istd::IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS) override;
46 virtual bool ResetData(CompatibilityMode mode = CM_WITHOUT_REFS) override;
47
48 // operators
50 bool operator==(const CGeneralBitmap& bitmap) const;
51 bool operator!=(const CGeneralBitmap& bitmap) const;
52
53protected:
61 virtual bool CreateBitmap(
62 const istd::CIndex2d& size,
63 int pixelBitsCount,
64 int componentsCount,
65 PixelFormat pixelFormat);
66
77 virtual bool CreateBitmap(
78 const istd::CIndex2d& size,
79 void* dataPtr,
80 bool releaseFlag,
81 int linesDifference,
82 int pixelBitsCount,
83 int componentsCount,
84 PixelFormat pixelFormat);
85
86private:
87 void Reset();
88
89private:
91
92 istd::CIndex2d m_size;
93 int m_linesDifference;
94 PixelFormat m_pixelFormat;
95};
96
97
98// inline methods
99
100// reimplemented (iimg::IBitmap)
101
103{
104 return m_linesDifference;
105}
106
107
109{
110 return GetPixelBitsCount() >> 3;
111}
112
113
114inline const void* CGeneralBitmap::GetLinePtr(int positionY) const
115{
116 Q_ASSERT(positionY >= 0);
117 Q_ASSERT(positionY < m_size.GetY());
118
119 return m_buffer.GetPtr() + quint64(m_linesDifference) * quint64(positionY);
120}
121
122
123inline void* CGeneralBitmap::GetLinePtr(int positionY)
124{
125 Q_ASSERT(positionY >= 0);
126 Q_ASSERT(positionY < m_size.GetY());
127
128 return m_buffer.GetPtr() + quint64(m_linesDifference) * quint64(positionY);
129}
130
131
132// reimplemented (iimg::IRasterImage)
133
135{
136 return m_size;
137}
138
139
140} // namespace iimg
141
142
143
144
Base implementation of some iimg::IBitmap methods.
Definition CBitmapBase.h:23
virtual int GetPixelBitsCount() const override
Get total number of bits per single pixel.
Standard device- and platform-independent bitmap definition.
virtual bool ResetData(CompatibilityMode mode=CM_WITHOUT_REFS) override
Reset data to its default state.
virtual const void * GetLinePtr(int positionY) const override
Get pointer to buffer for single line.
bool operator==(const CGeneralBitmap &bitmap) const
virtual PixelFormat GetPixelFormat() const override
Get the bitmap's pixel format.
virtual void ClearImage() override
Cleat this image.
virtual int GetLinesDifference() const override
Get address difference between next and previous line.
bool operator!=(const CGeneralBitmap &bitmap) const
virtual bool CreateBitmap(PixelFormat pixelFormat, const istd::CIndex2d &size, void *dataPtr, bool releaseFlag, int linesDifference=0) override
Create bitmap with specified size and format using external image data buffer.
virtual bool CreateBitmap(const istd::CIndex2d &size, int pixelBitsCount, int componentsCount, PixelFormat pixelFormat)
Create bitmap with specified size, number of bits per pixel and components number per pixel.
virtual istd::TUniqueInterfacePtr< istd::IChangeable > CloneMe(CompatibilityMode mode=CM_WITHOUT_REFS) const override
Make a copy of this object.
virtual istd::CIndex2d GetImageSize() const override
Get size of this raster image.
virtual int GetPixelsDifference() const override
Get address difference between next and previous pixel.
CGeneralBitmap(const CGeneralBitmap &bitmap)
virtual void ResetImage() override
Reset this image.
virtual int GetSupportedOperations() const override
Get set of flags for supported operations.
virtual bool CopyFrom(const istd::IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS) override
Copy this object from another one.
CGeneralBitmap & operator=(const CGeneralBitmap &bitmap)
virtual bool IsFormatSupported(PixelFormat pixelFormat) const override
Get true if the pixel format is supported by the bitmap implementation.
virtual bool CreateBitmap(const istd::CIndex2d &size, void *dataPtr, bool releaseFlag, int linesDifference, int pixelBitsCount, int componentsCount, PixelFormat pixelFormat)
Create bitmap using external image buffer.
virtual bool CreateBitmap(PixelFormat pixelFormat, const istd::CIndex2d &size, int pixelBitsCount=0, int componentsCount=0) override
Create bitmap with specified size and format.
PixelFormat
Bitmap pixel format description.
Definition IBitmap.h:27
Index implementation for addressing elements in 2D-space.
Definition CIndex2d.h:21
int GetY() const
Definition CIndex2d.h:108
Common interface for data model objects, which can be changed.
Definition IChangeable.h:28
CompatibilityMode
Control how relationship betweeen objects are interpreted.
@ CM_WITHOUT_REFS
External references are simple ignored.
Pointer wrapper providing activatable deleting pointed object during destruction.
Definition TOptDelPtr.h:21
Type * GetPtr() const
Return access to internal stored pointer.
Unique ownership smart pointer for interface types.
Contains the system indenendent definitions of image and related themes.
Definition CBitmap.h:17