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
ddsheader.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2016 Ivan Komissarov.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4// Qt-Security score:critical reason:data-parser
5
6#include "ddsheader.h"
7
8#ifndef QT_NO_DATASTREAM
9
11
12QDataStream &operator>>(QDataStream &s, DDSPixelFormat &pixelFormat)
13{
14 s >> pixelFormat.size;
15 s >> pixelFormat.flags;
16 s >> pixelFormat.fourCC;
17 s >> pixelFormat.rgbBitCount;
18 s >> pixelFormat.rBitMask;
19 s >> pixelFormat.gBitMask;
20 s >> pixelFormat.bBitMask;
21 s >> pixelFormat.aBitMask;
22 return s;
23}
24
25QDataStream &operator<<(QDataStream &s, const DDSPixelFormat &pixelFormat)
26{
27 s << pixelFormat.size;
28 s << pixelFormat.flags;
29 s << pixelFormat.fourCC;
30 s << pixelFormat.rgbBitCount;
31 s << pixelFormat.rBitMask;
32 s << pixelFormat.gBitMask;
33 s << pixelFormat.bBitMask;
34 s << pixelFormat.aBitMask;
35 return s;
36}
37
38QDataStream &operator>>(QDataStream &s, DDSHeader &header)
39{
40 s >> header.magic;
41 s >> header.size;
42 s >> header.flags;
43 s >> header.height;
44 s >> header.width;
45 s >> header.pitchOrLinearSize;
46 s >> header.depth;
47 s >> header.mipMapCount;
48 for (int i = 0; i < DDSHeader::ReservedCount; i++)
49 s >> header.reserved1[i];
50 s >> header.pixelFormat;
51 s >> header.caps;
52 s >> header.caps2;
53 s >> header.caps3;
54 s >> header.caps4;
55 s >> header.reserved2;
56 return s;
57}
58
59QDataStream &operator<<(QDataStream &s, const DDSHeader &header)
60{
61 s << header.magic;
62 s << header.size;
63 s << header.flags;
64 s << header.height;
65 s << header.width;
66 s << header.pitchOrLinearSize;
67 s << header.depth;
68 s << header.mipMapCount;
69 for (int i = 0; i < DDSHeader::ReservedCount; i++)
70 s << header.reserved1[i];
71 s << header.pixelFormat;
72 s << header.caps;
73 s << header.caps2;
74 s << header.caps3;
75 s << header.caps4;
76 s << header.reserved2;
77 return s;
78}
79
80QDataStream &operator>>(QDataStream &s, DDSHeaderDX10 &header)
81{
82 s >> header.dxgiFormat;
83 s >> header.resourceDimension;
84 s >> header.miscFlag;
85 s >> header.arraySize;
86 s >> header.reserved;
87 return s;
88}
89
90QDataStream &operator<<(QDataStream &s, const DDSHeaderDX10 &header)
91{
92 s << header.dxgiFormat;
93 s << header.resourceDimension;
94 s << header.miscFlag;
95 s << header.arraySize;
96 s << header.reserved;
97 return s;
98}
99
100QT_END_NAMESPACE
101
102#endif // QT_NO_DATASTREAM
QDataStream & operator>>(QDataStream &s, DDSHeaderDX10 &header)
Definition ddsheader.cpp:80
QDataStream & operator>>(QDataStream &s, DDSHeader &header)
Definition ddsheader.cpp:38
QDataStream & operator<<(QDataStream &s, const DDSHeader &header)
Definition ddsheader.cpp:59
QDataStream & operator<<(QDataStream &s, const DDSPixelFormat &pixelFormat)
Definition ddsheader.cpp:25
QDataStream & operator<<(QDataStream &s, const DDSHeaderDX10 &header)
Definition ddsheader.cpp:90
@ ReservedCount
Definition ddsheader.h:165