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

© 2007-2017 Witold Gantzke and Kirill Lepskiy