Debian Codegraph @

src/plugins/imageformats/dds/ddsheader.cpp

raw symbols SCIP
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Copyright (C) 2016 Ivan Komissarov.
5 ** Contact: https://www.qt.io/licensing/
6 **
7 ** This file is part of the DDS plugin in the Qt ImageFormats module.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** Commercial License Usage
11 ** Licensees holding valid commercial Qt licenses may use this file in
12 ** accordance with the commercial license agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and The Qt Company. For licensing terms
15 ** and conditions see https://www.qt.io/terms-conditions. For further
16 ** information use the contact form at https://www.qt.io/contact-us.
17 **
18 ** GNU Lesser General Public License Usage
19 ** Alternatively, this file may be used under the terms of the GNU Lesser
20 ** General Public License version 3 as published by the Free Software
21 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
22 ** packaging of this file. Please review the following information to
23 ** ensure the GNU Lesser General Public License version 3 requirements
24 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25 **
26 ** GNU General Public License Usage
27 ** Alternatively, this file may be used under the terms of the GNU
28 ** General Public License version 2.0 or (at your option) the GNU General
29 ** Public license version 3 or any later version approved by the KDE Free
30 ** Qt Foundation. The licenses are as published by the Free Software
31 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32 ** included in the packaging of this file. Please review the following
33 ** information to ensure the GNU General Public License requirements will
34 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35 ** https://www.gnu.org/licenses/gpl-3.0.html.
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40
41 #include "ddsheader.h"
42
43 #ifndef QT_NO_DATASTREAM
44
45 QT_BEGIN_NAMESPACE
46
47 QDataStream &operator>>(QDataStream &s, DDSPixelFormat &pixelFormat)
48 {
49 s >> pixelFormat.size;
50 s >> pixelFormat.flags;
51 s >> pixelFormat.fourCC;
52 s >> pixelFormat.rgbBitCount;
53 s >> pixelFormat.rBitMask;
54 s >> pixelFormat.gBitMask;
55 s >> pixelFormat.bBitMask;
56 s >> pixelFormat.aBitMask;
57 return s;
58 }
59
60 QDataStream &operator<<(QDataStream &s, const DDSPixelFormat &pixelFormat)
61 {
62 s << pixelFormat.size;
63 s << pixelFormat.flags;
64 s << pixelFormat.fourCC;
65 s << pixelFormat.rgbBitCount;
66 s << pixelFormat.rBitMask;
67 s << pixelFormat.gBitMask;
68 s << pixelFormat.bBitMask;
69 s << pixelFormat.aBitMask;
70 return s;
71 }
72
73 QDataStream &operator>>(QDataStream &s, DDSHeader &header)
74 {
75 s >> header.magic;
76 s >> header.size;
77 s >> header.flags;
78 s >> header.height;
79 s >> header.width;
80 s >> header.pitchOrLinearSize;
81 s >> header.depth;
82 s >> header.mipMapCount;
83 for (int i = 0; i < DDSHeader::ReservedCount; i++)
84 s >> header.reserved1[i];
85 s >> header.pixelFormat;
86 s >> header.caps;
87 s >> header.caps2;
88 s >> header.caps3;
89 s >> header.caps4;
90 s >> header.reserved2;
91 return s;
92 }
93
94 QDataStream &operator<<(QDataStream &s, const DDSHeader &header)
95 {
96 s << header.magic;
97 s << header.size;
98 s << header.flags;
99 s << header.height;
100 s << header.width;
101 s << header.pitchOrLinearSize;
102 s << header.depth;
103 s << header.mipMapCount;
104 for (int i = 0; i < DDSHeader::ReservedCount; i++)
105 s << header.reserved1[i];
106 s << header.pixelFormat;
107 s << header.caps;
108 s << header.caps2;
109 s << header.caps3;
110 s << header.caps4;
111 s << header.reserved2;
112 return s;
113 }
114
115 QDataStream &operator>>(QDataStream &s, DDSHeaderDX10 &header)
116 {
117 s >> header.dxgiFormat;
118 s >> header.resourceDimension;
119 s >> header.miscFlag;
120 s >> header.arraySize;
121 s >> header.reserved;
122 return s;
123 }
124
125 QDataStream &operator<<(QDataStream &s, const DDSHeaderDX10 &header)
126 {
127 s << header.dxgiFormat;
128 s << header.resourceDimension;
129 s << header.miscFlag;
130 s << header.arraySize;
131 s << header.reserved;
132 return s;
133 }
134
135 QT_END_NAMESPACE
136
137 #endif // QT_NO_DATASTREAM