ACF $AcfVersion:0$
CBitmap.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
5// Qt includes
6#include <QtCore/QMutex>
7
8// ACF includes
9#include <istd/TOptDelPtr.h>
10#include <istd/TDelPtr.h>
12#include <iimg/CBitmapBase.h>
14
15
16namespace iimg
17{
18
19
26class CBitmap:
27 public iimg::CBitmapBase,
28 virtual public IQImageProvider
29{
31
32public:
33 static QByteArray GetTypeName();
34
36 CBitmap(const CBitmap& bitmap);
37 CBitmap(const QImage& image);
38
39 QImage& GetQImageRef();
40
41 // reimplemented (iimg::IQImageProvider)
42 virtual const QImage& GetQImage() const override;
43 virtual bool CopyImageFrom(const QImage& image) override;
44
45 // reimplemented (iimg::IBitmap)
46 virtual bool IsFormatSupported(PixelFormat pixelFormat) const override;
47 virtual PixelFormat GetPixelFormat() const override;
48 virtual bool CreateBitmap(PixelFormat pixelFormat, const istd::CIndex2d& size, int pixelBitsCount = 0, int componentsCount = 0) override;
49 virtual bool CreateBitmap(PixelFormat pixelFormat, const istd::CIndex2d& size, void* dataPtr, bool releaseFlag, int linesDifference = 0) override;
50 virtual int GetLinesDifference() const override;
51 virtual int GetPixelsDifference() const override;
52 virtual const void* GetLinePtr(int positionY) const override;
53 virtual void* GetLinePtr(int positionY) override;
54
55 // reimplemented (iimg::IRasterImage)
56 virtual void ResetImage() override;
57 virtual void ClearImage() override;
58 virtual istd::CIndex2d GetImageSize() const override;
59
60 // reimplemented (iser::IObject)
61 virtual QByteArray GetFactoryId() const override;
62
63 // reimplemented (istd::IChangeable)
64 virtual int GetSupportedOperations() const override;
65 virtual bool CopyFrom(const istd::IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS) override;
67 virtual bool ResetData(CompatibilityMode mode = CM_WITHOUT_REFS) override;
68
69protected:
70 QImage::Format CalcQtFormat(PixelFormat pixelFormat) const;
71 PixelFormat CalcFromQtFormat(QImage::Format imageFormat) const;
72 bool SetQImage(const QImage& image);
74
75private:
76 void Reset();
77
78private:
79 QImage m_image;
80 istd::TOptDelPtr<quint8, true> m_externalBuffer;
81
82 static QVector<QRgb> s_colorTableGray;
83 static QMutex s_colorTableLock;
84
86};
87
88
89// inline methods
90
91inline QImage& CBitmap::GetQImageRef()
92{
93 return m_image;
94}
95
96
97} // namespace iimg
98
99
100
101
Base implementation of some iimg::IBitmap methods.
Definition CBitmapBase.h:23
Bitmap implementation based on Qt QImage.
Definition CBitmap.h:29
virtual bool CreateBitmap(PixelFormat pixelFormat, const istd::CIndex2d &size, int pixelBitsCount=0, int componentsCount=0) override
Create bitmap with specified size and format.
virtual void ClearImage() override
Cleat this image.
CBitmap(const QImage &image)
static QByteArray GetTypeName()
virtual PixelFormat GetPixelFormat() const override
Get the bitmap's pixel format.
virtual const void * GetLinePtr(int positionY) const override
Get pointer to buffer for single line.
virtual QByteArray GetFactoryId() const override
virtual bool CopyImageFrom(const QImage &image) override
Copies the image data from a QImage object.
virtual bool CopyFrom(const istd::IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS) override
Copy this object from another one.
virtual bool IsFormatSupported(PixelFormat pixelFormat) const override
Get true if the pixel format is supported by the bitmap implementation.
virtual void * GetLinePtr(int positionY) override
Get pointer to buffer for single line.
virtual void ResetImage() override
Reset this image.
void InitializeColorModel()
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 int GetSupportedOperations() const override
Get set of flags for supported operations.
virtual istd::TUniqueInterfacePtr< istd::IChangeable > CloneMe(CompatibilityMode mode=CM_WITHOUT_REFS) const override
Make a copy of this object.
CBitmap(const CBitmap &bitmap)
virtual int GetLinesDifference() const override
Get address difference between next and previous line.
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.
bool SetQImage(const QImage &image)
QImage::Format CalcQtFormat(PixelFormat pixelFormat) const
QImage & GetQImageRef()
Definition CBitmap.h:91
virtual const QImage & GetQImage() const override
Gets a QImage object.
virtual bool ResetData(CompatibilityMode mode=CM_WITHOUT_REFS) override
Reset data to its default state.
PixelFormat CalcFromQtFormat(QImage::Format imageFormat) const
PixelFormat
Bitmap pixel format description.
Definition IBitmap.h:27
Interface for QImage object provider.
Index implementation for addressing elements in 2D-space.
Definition CIndex2d.h:21
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 automatic deleting pointed object during destruction.
Definition TDelPtr.h:21
Pointer wrapper providing activatable deleting pointed object during destruction.
Definition TOptDelPtr.h:21
Unique ownership smart pointer for interface types.
Contains the system indenendent definitions of image and related themes.
Definition CBitmap.h:17