Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qbmphandler_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:critical reason:data-parser
4
5#ifndef QBMPHANDLER_P_H
6#define QBMPHANDLER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtGui/private/qtguiglobal_p.h>
20#include "QtGui/qimageiohandler.h"
21
22#ifndef QT_NO_IMAGEFORMAT_BMP
23
24QT_BEGIN_NAMESPACE
25
26struct BMP_FILEHDR { // BMP file header
27 char bfType[2]; // "BM"
28 qint32 bfSize; // size of file
29 qint16 bfReserved1;
30 qint16 bfReserved2;
31 qint32 bfOffBits; // pointer to the pixmap bits
32};
33
34struct BMP_INFOHDR { // BMP information header
35 qint32 biSize; // size of this struct
36 qint32 biWidth; // pixmap width
37 qint32 biHeight; // pixmap height
38 qint16 biPlanes; // should be 1
39 qint16 biBitCount; // number of bits per pixel
40 qint32 biCompression; // compression method
41 qint32 biSizeImage; // size of image
42 qint32 biXPelsPerMeter; // horizontal resolution
43 qint32 biYPelsPerMeter; // vertical resolution
44 qint32 biClrUsed; // number of colors used
45 qint32 biClrImportant; // number of important colors
46 // V4:
56 // V5:
61};
62
63// BMP-Handler, which is also able to read and write the DIB
64// (Device-Independent-Bitmap) format used internally in the Windows operating
65// system for OLE/clipboard operations. DIB is a subset of BMP (without file
66// header). The Windows platform plugin accesses the DIB-functionality.
67
69{
70public:
75
76 explicit QBmpHandler(InternalFormat fmt = BmpFormat);
77 bool canRead() const override;
78 bool read(QImage *image) override;
79 bool write(const QImage &image) override;
80
81 static bool canRead(QIODevice *device);
82
83 QVariant option(ImageOption option) const override;
84 void setOption(ImageOption option, const QVariant &value) override;
85 bool supportsOption(ImageOption option) const override;
86
87private:
88 bool readHeader();
89 inline QByteArray formatName() const;
90
91 enum State {
92 Ready,
93 ReadHeader,
94 Error
95 };
96
97 const InternalFormat m_format;
98
99 State state;
100 BMP_FILEHDR fileHeader;
101 BMP_INFOHDR infoHeader;
102 qint64 startpos;
103};
104
105QT_END_NAMESPACE
106
107#endif // QT_NO_IMAGEFORMAT_BMP
108
109#endif // QBMPHANDLER_P_H
bool supportsOption(ImageOption option) const override
Returns true if the QImageIOHandler supports the option option; otherwise returns false.
QVariant option(ImageOption option) const override
Returns the value assigned to option as a QVariant.
QBmpHandler(InternalFormat fmt=BmpFormat)
bool canRead() const override
Returns true if an image can be read from the device (i.e., the image format is supported,...
static bool canRead(QIODevice *device)
bool write(const QImage &image) override
Writes the image image to the assigned device.
void setOption(ImageOption option, const QVariant &value) override
Sets the option option with the value value.
bool read(QImage *image) override
Read an image from the device, and stores it in image.
qint16 biPlanes
qint32 biSizeImage
qint32 biClrImportant
qint32 biCompression
qint32 biGammaGreen
qint32 biGammaRed
qint16 biBitCount
qint32 biCSType
qint32 biReserved
quint32 biGreenMask
qint32 biIntent
qint32 biClrUsed
qint32 biYPelsPerMeter
qint32 biXPelsPerMeter
qint32 biHeight
qint32 biGammaBlue
quint32 biAlphaMask
quint32 biRedMask
qint32 biProfileData
qint32 biProfileSize
quint32 biBlueMask
qint32 biEndpoints[9]