ICF 3.1.1.10
Technical documentation of ICF Libraries
CBitmap.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#ifndef iimg_CBitmap_included
7#define iimg_CBitmap_included
8
9
10// Qt includes
11#include <QtCore/QMutex>
12
13// ICF includes
14#include <istd/COptMemory.h>
16#include <iimg/CBitmapBase.h>
18
19
20namespace iimg
21{
22
23
27class CBitmap:
28 public iimg::CBitmapBase,
29 virtual public IQImageProvider
30{
32
33public:
34 static QByteArray GetTypeName();
35
37 CBitmap(const CBitmap& bitmap);
38 CBitmap(const QImage& image);
39
40 QImage& GetQImageRef();
41
42 // reimplemented (iimg::IQImageProvider)
43 const QImage& GetQImage() const override;
44 bool CopyImageFrom(const QImage& image) override;
45
46 // reimplemented (iimg::IBitmap)
47 bool IsFormatSupported(PixelFormat pixelFormat) const override;
48 PixelFormat GetPixelFormat() const override;
49 bool CreateBitmap(PixelFormat pixelFormat, const istd::CIndex2d& size, int pixelBitsCount = 0, int componentsCount = 0) override;
50 bool CreateBitmap(PixelFormat pixelFormat, const istd::CIndex2d& size, istd::COptMemory&& data, int linesDifference = 0) override;
51 int GetLinesDifference() const override;
52 int GetPixelsDifference() const override;
53 int GetPixelBitsCount() const override;
54 const void* GetLinePtr(int positionY) const override;
55 void* GetLinePtr(int positionY) override;
56
57 // reimplemented (iimg::IRasterImage)
58 void ResetImage() override;
59 void ClearImage() override;
60 istd::CIndex2d GetImageSize() const override;
61 int GetComponentsCount() const override;
62 icmm::CVarColor GetColorAt(const istd::CIndex2d& position) const override;
63
64 // reimplemented (iser::IObject)
65 QByteArray GetFactoryId() const override;
66
67 // reimplemented (istd::IChangeable)
68 int GetSupportedOperations() const override;
69 bool CopyFrom(const istd::IChangeable& object, CompatibilityMode mode = CM_WITHOUT_REFS) override;
70 std::unique_ptr<istd::IChangeable> CloneMe(CompatibilityMode mode = CM_WITHOUT_REFS) const override;
71
72protected:
73 QImage::Format CalcQtFormat(PixelFormat pixelFormat) const;
74 PixelFormat CalcFromQtFormat(QImage::Format imageFormat) const;
75 bool SetQImage(const QImage& image);
76
77private:
78 QImage m_image;
79 istd::COptMemory m_externalBuffer;
80
81 static QVector<QRgb> s_colorTableGray;
82 static QMutex s_colorTableLock;
83};
84
85
86// inline methods
87
88inline QImage& CBitmap::GetQImageRef()
89{
90 return m_image;
91}
92
93
94} // namespace iimg
95
96
97#endif
98
99
Generic color implementation with variable number of color components.
Definition CVarColor.h:26
Base implementation of some iimg::IBitmap methods.
Definition CBitmapBase.h:25
Bitmap implementation based on Qt QImage.
Definition CBitmap.h:30
QByteArray GetFactoryId() const override
int GetPixelsDifference() const override
Get address difference between next and previous pixel.
bool CreateBitmap(PixelFormat pixelFormat, const istd::CIndex2d &size, istd::COptMemory &&data, int linesDifference=0) override
Create bitmap with specified size and format using external image data buffer.
CBitmap(const QImage &image)
bool CopyFrom(const istd::IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS) override
Copy this object from another one.
static QByteArray GetTypeName()
bool CreateBitmap(PixelFormat pixelFormat, const istd::CIndex2d &size, int pixelBitsCount=0, int componentsCount=0) override
Create bitmap with specified size and format.
istd::CIndex2d GetImageSize() const override
Get size of this raster image.
std::unique_ptr< istd::IChangeable > CloneMe(CompatibilityMode mode=CM_WITHOUT_REFS) const override
Make a copy of this object.
int GetPixelBitsCount() const override
Get total number of bits per single pixel.
bool IsFormatSupported(PixelFormat pixelFormat) const override
Get true if the pixel format is supported by the bitmap implementation.
icmm::CVarColor GetColorAt(const istd::CIndex2d &position) const override
Get color at specified pixel.
const QImage & GetQImage() const override
Gets a QImage object.
int GetComponentsCount() const override
Get number of color components.
const void * GetLinePtr(int positionY) const override
Get pointer to buffer for single line.
int GetLinesDifference() const override
Get address difference between next and previous line.
bool CopyImageFrom(const QImage &image) override
Copies the image data from a QImage object.
void ClearImage() override
Cleat this image.
CBitmap(const CBitmap &bitmap)
PixelFormat GetPixelFormat() const override
Get the bitmap's pixel format.
int GetSupportedOperations() const override
Get set of flags for supported operations.
void * GetLinePtr(int positionY) override
Get pointer to buffer for single line.
bool SetQImage(const QImage &image)
QImage::Format CalcQtFormat(PixelFormat pixelFormat) const
QImage & GetQImageRef()
Definition CBitmap.h:88
void ResetImage() override
Reset this image.
PixelFormat CalcFromQtFormat(QImage::Format imageFormat) const
PixelFormat
Bitmap pixel format description.
Definition IBitmap.h:30
Interface for QImage object provider.
Index implementation for addressing elements in 2D-space.
Definition CIndex2d.h:25
Memory block with optional deleting function used during destruction.
Definition COptMemory.h:21
Common interface for data model objects, which can be changed.
Definition IChangeable.h:32
CompatibilityMode
Control how relationship betweeen objects are interpreted.
@ CM_WITHOUT_REFS
External references are simple ignored.
Contains the system indenendent definitions of image and related themes.
Definition CBitmap.h:21

© Witold Gantzke and Kirill Lepskiy