Krita Source Code Documentation
Loading...
Searching...
No Matches
psd_utils.h File Reference
#include <QtEndian>
#include <QtGlobal>
#include <QIODevice>
#include <array>
#include <psd.h>
#include <resources/KoPattern.h>
#include <type_traits>

Go to the source code of this file.

Functions

template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>
bool psd_read_blendmode (QIODevice &io, QString &blendModeKey)
 
bool psdpad (QIODevice &io, quint32 padding)
 
template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian, typename T >
std::enable_if_t< std::is_arithmetic< T >::value, bool > psdread (QIODevice &io, T &v)
 
template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>
bool psdread_pascalstring (QIODevice &io, QString &s, qint64 padding)
 
template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>
bool psdread_unicodestring (QIODevice &io, QString &s)
 
bool psdreadBE (QIODevice &io, quint16 &v)
 
bool psdreadBE (QIODevice &io, quint32 &v)
 
bool psdreadBE (QIODevice &io, quint64 &v)
 
bool psdreadBE (QIODevice &io, quint8 &v)
 
template<typename T >
bool psdreadBE (QIODevice &io, std::enable_if_t< sizeof(T)==sizeof(quint16), T & > v)
 
template<typename T >
bool psdreadBE (QIODevice &io, std::enable_if_t< sizeof(T)==sizeof(quint32), T & > v)
 
template<typename T >
bool psdreadBE (QIODevice &io, std::enable_if_t< sizeof(T)==sizeof(quint64), T & > v)
 
template<typename T >
bool psdreadBE (QIODevice &io, std::enable_if_t< sizeof(T)==sizeof(quint8), T & > v)
 
template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>
QByteArray psdreadBytes (QIODevice &io, qint64 v)
 
template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>
double psdreadFixedPoint (QIODevice &io)
 
bool psdreadLE (QIODevice &io, quint16 &v)
 
bool psdreadLE (QIODevice &io, quint32 &v)
 
bool psdreadLE (QIODevice &io, quint64 &v)
 
bool psdreadLE (QIODevice &io, quint8 &v)
 
template<typename T >
bool psdreadLE (QIODevice &io, std::enable_if_t< sizeof(T)==sizeof(quint16), T & > v)
 
template<typename T >
bool psdreadLE (QIODevice &io, std::enable_if_t< sizeof(T)==sizeof(quint32), T & > v)
 
template<typename T >
bool psdreadLE (QIODevice &io, std::enable_if_t< sizeof(T)==sizeof(quint64), T & > v)
 
template<typename T >
bool psdreadLE (QIODevice &io, std::enable_if_t< sizeof(T)==sizeof(quint8), T & > v)
 
bool psdwrite (QIODevice &io, const QString &s)
 
template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian, typename T >
std::enable_if_t< std::is_arithmetic< T >::value, bool > psdwrite (QIODevice &io, T v)
 
template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>
bool psdwrite_pascalstring (QIODevice &io, const QString &s)
 
template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>
bool psdwrite_pascalstring (QIODevice &io, const QString &s, int padding)
 
bool psdwriteBE (QIODevice &io, const quint16 &v)
 
bool psdwriteBE (QIODevice &io, const quint32 &v)
 
bool psdwriteBE (QIODevice &io, const quint64 &v)
 
bool psdwriteBE (QIODevice &io, const quint8 &v)
 
template<typename T >
bool psdwriteBE (QIODevice &io, std::enable_if_t< sizeof(T)==sizeof(quint16), T & > v)
 
template<typename T >
bool psdwriteBE (QIODevice &io, std::enable_if_t< sizeof(T)==sizeof(quint32), T & > v)
 
template<typename T >
bool psdwriteBE (QIODevice &io, std::enable_if_t< sizeof(T)==sizeof(quint64), T & > v)
 
template<typename T >
bool psdwriteBE (QIODevice &io, std::enable_if_t< sizeof(T)==sizeof(quint8), T & > v)
 
template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>
void psdwriteFixedPoint (QIODevice &io, double val)
 
bool psdwriteLE (QIODevice &io, const quint16 &v)
 
bool psdwriteLE (QIODevice &io, const quint32 &v)
 
bool psdwriteLE (QIODevice &io, const quint64 &v)
 
bool psdwriteLE (QIODevice &io, const quint8 &v)
 
template<typename T >
bool psdwriteLE (QIODevice &io, std::enable_if_t< sizeof(T)==sizeof(quint16), T & > v)
 
template<typename T >
bool psdwriteLE (QIODevice &io, std::enable_if_t< sizeof(T)==sizeof(quint32), T & > v)
 
template<typename T >
bool psdwriteLE (QIODevice &io, std::enable_if_t< sizeof(T)==sizeof(quint64), T & > v)
 
template<typename T >
bool psdwriteLE (QIODevice &io, std::enable_if_t< sizeof(T)==sizeof(quint8), T & > v)
 

Function Documentation

◆ psd_read_blendmode()

template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>
bool psd_read_blendmode ( QIODevice & io,
QString & blendModeKey )
inline

Definition at line 485 of file psd_utils.h.

486{
487 QByteArray b(psdreadBytes<byteOrder>(io, 4));
488 if (b.size() != 4 || QString(b) != "8BIM") {
489 return false;
490 }
491 blendModeKey = QString(psdreadBytes<byteOrder>(io, 4));
492 if (blendModeKey.size() != 4) {
493 return false;
494 }
495 return true;
496}

◆ psdpad()

bool psdpad ( QIODevice & io,
quint32 padding )
inline

Definition at line 248 of file psd_utils.h.

249{
250 for (quint32 i = 0; i < padding; i++) {
251 const bool written = io.putChar('\0');
252 if (!written)
253 return false;
254 }
255 return true;
256}

◆ psdread()

template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian, typename T >
std::enable_if_t< std::is_arithmetic< T >::value, bool > psdread ( QIODevice & io,
T & v )
inline

Definition at line 397 of file psd_utils.h.

398{
399 if (byteOrder == psd_byte_order::psdLittleEndian) {
400 return psdreadLE<T>(io, v);
401 } else {
402 return psdreadBE<T>(io, v);
403 }
404}
qreal v

References psdLittleEndian, and v.

◆ psdread_pascalstring()

template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>
bool psdread_pascalstring ( QIODevice & io,
QString & s,
qint64 padding )
inline

Definition at line 417 of file psd_utils.h.

418{
419 quint8 length;
420 if (!psdread<byteOrder>(io, length)) {
421 return false;
422 }
423
424 if (length == 0) {
425 // read the padding
426 for (qint64 i = 0; i < padding - 1; ++i) {
427 io.seek(io.pos() + 1);
428 }
429 return true;
430 }
431
432 QByteArray chars = io.read(length);
433 if (chars.length() != length) {
434 return false;
435 }
436
437 // read padding byte
438 quint32 paddedLength = length + 1;
439 if (padding > 0) {
440 while (paddedLength % padding != 0) {
441 if (!io.seek(io.pos() + 1)) {
442 return false;
443 }
444 paddedLength++;
445 }
446 }
447
448 s.append(QString::fromLatin1(chars));
449 if (s.endsWith(QChar::Space)) {
450 s.chop(1);
451 }
452
453 return true;
454}
qreal length(const QPointF &vec)
Definition Ellipse.cc:82

References length().

◆ psdread_unicodestring()

template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>
bool psdread_unicodestring ( QIODevice & io,
QString & s )
inline

Definition at line 457 of file psd_utils.h.

458{
459 quint32 stringlen;
460 if (!psdread<byteOrder>(io, stringlen)) {
461 return false;
462 }
463
464 s.fill(QChar::Space, static_cast<int>(stringlen));
465
466 for (quint32 i = 0; i < stringlen; ++i) {
467 quint16 ch(0);
468 if (!psdread<byteOrder>(io, ch)) {
469 return false;
470 }
471
472 // XXX: this makes it possible to append garbage
473 if (ch != 0) {
474 s[i] = QChar(ch);
475 }
476 }
477 if (s.endsWith(QChar::Space)) {
478 s.chop(1);
479 }
480
481 return true;
482}

◆ psdreadBE() [1/8]

bool psdreadBE ( QIODevice & io,
quint16 & v )
inline

Definition at line 282 of file psd_utils.h.

283{
284 std::array<quint8, 2> data;
285 qint64 read = io.read(reinterpret_cast<char *>(data.data()), 2);
286 if (read != 2)
287 return false;
288 v = quint16((quint16(data[0]) << 8U) | data[1]);
289 return true;
290}

References v.

◆ psdreadBE() [2/8]

bool psdreadBE ( QIODevice & io,
quint32 & v )
inline

Definition at line 302 of file psd_utils.h.

303{
304 std::array<quint8, 4> data;
305 qint64 read = io.read(reinterpret_cast<char *>(data.data()), 4);
306 if (read != 4)
307 return false;
308 v = (quint32(data[0]) << 24U) | (quint32(data[1]) << 16U) | (quint32(data[2]) << 8U) | data[3];
309 return true;
310}

References v.

◆ psdreadBE() [3/8]

bool psdreadBE ( QIODevice & io,
quint64 & v )
inline

Definition at line 322 of file psd_utils.h.

323{
324 std::array<quint8, 8> data;
325 qint64 read = io.read(reinterpret_cast<char *>(data.data()), 8);
326 if (read != 8)
327 return false;
328 v = (quint64(data[0]) << 56U) | (quint64(data[1]) << 48U) | (quint64(data[2]) << 40U) | (quint64(data[3]) << 32U) | (quint64(data[4]) << 24U)
329 | (quint64(data[5]) << 16U) | (quint64(data[6]) << 8U) | data[7];
330 return true;
331}

References v.

◆ psdreadBE() [4/8]

bool psdreadBE ( QIODevice & io,
quint8 & v )
inline

Reading functions.

Definition at line 262 of file psd_utils.h.

263{
264 std::array<quint8, 1> data;
265 qint64 read = io.read(reinterpret_cast<char *>(data.data()), 1);
266 if (read != 1)
267 return false;
268 v = data[0];
269 return true;
270}

References v.

◆ psdreadBE() [5/8]

template<typename T >
bool psdreadBE ( QIODevice & io,
std::enable_if_t< sizeof(T)==sizeof(quint16), T & > v )
inline

Definition at line 355 of file psd_utils.h.

356{
357 return psdreadBE(io, reinterpret_cast<quint16 &>(v));
358}
bool psdreadBE(QIODevice &io, quint8 &v)
Definition psd_utils.h:262

References psdreadBE(), and v.

◆ psdreadBE() [6/8]

template<typename T >
bool psdreadBE ( QIODevice & io,
std::enable_if_t< sizeof(T)==sizeof(quint32), T & > v )
inline

Definition at line 361 of file psd_utils.h.

362{
363 return psdreadBE(io, reinterpret_cast<quint32 &>(v));
364}

References psdreadBE(), and v.

◆ psdreadBE() [7/8]

template<typename T >
bool psdreadBE ( QIODevice & io,
std::enable_if_t< sizeof(T)==sizeof(quint64), T & > v )
inline

Definition at line 367 of file psd_utils.h.

368{
369 return psdreadBE(io, reinterpret_cast<quint64 &>(v));
370}

References psdreadBE(), and v.

◆ psdreadBE() [8/8]

template<typename T >
bool psdreadBE ( QIODevice & io,
std::enable_if_t< sizeof(T)==sizeof(quint8), T & > v )
inline

Templated reading fallbacks for non-integral types.

Definition at line 349 of file psd_utils.h.

350{
351 return psdreadBE(io, reinterpret_cast<quint8 &>(v));
352}

References psdreadBE(), and v.

◆ psdreadBytes()

template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>
QByteArray psdreadBytes ( QIODevice & io,
qint64 v )
inline

Definition at line 407 of file psd_utils.h.

408{
409 QByteArray b = io.read(v);
410 if (byteOrder == psd_byte_order::psdLittleEndian) {
411 std::reverse(b.begin(), b.end());
412 }
413 return b;
414}

References psdLittleEndian, and v.

◆ psdreadFixedPoint()

template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>
double psdreadFixedPoint ( QIODevice & io)
inline

Definition at line 500 of file psd_utils.h.

501{
502 quint32 data;
503 double ret = 0.0;
504
505 if (psdread<byteOrder>(io, data)) {
506 char man = (data & 0xFF000000) >> 24;
507 if (man >= 0)
508 {
509 ret = (data & 0x00FFFFFF) / 16777215.0;
510 ret = (ret + man);
511 }
512 else
513 {
514 ret = (~data & 0x00FFFFFF) / 16777215.0;
515 ret = (ret + ~man) * -1;
516 }
517 }
518 return ret;
519}

◆ psdreadLE() [1/8]

bool psdreadLE ( QIODevice & io,
quint16 & v )
inline

Definition at line 292 of file psd_utils.h.

293{
294 std::array<quint8, 2> data;
295 qint64 read = io.read(reinterpret_cast<char *>(data.data()), 2);
296 if (read != 2)
297 return false;
298 v = quint16((quint16(data[1]) << 8U) | data[0]);
299 return true;
300}

References v.

◆ psdreadLE() [2/8]

bool psdreadLE ( QIODevice & io,
quint32 & v )
inline

Definition at line 312 of file psd_utils.h.

313{
314 std::array<quint8, 4> data;
315 qint64 read = io.read(reinterpret_cast<char *>(data.data()), 4);
316 if (read != 4)
317 return false;
318 v = (quint32(data[3]) << 24U) | (quint32(data[2]) << 16U) | (quint32(data[1]) << 8U) | data[0];
319 return true;
320}

References v.

◆ psdreadLE() [3/8]

bool psdreadLE ( QIODevice & io,
quint64 & v )
inline

Definition at line 333 of file psd_utils.h.

334{
335 std::array<quint8, 8> data;
336 qint64 read = io.read(reinterpret_cast<char *>(data.data()), 8);
337 if (read != 8)
338 return false;
339 v = (quint64(data[7]) << 56U) | (quint64(data[6]) << 48U) | (quint64(data[5]) << 40U) | (quint64(data[4]) << 32U) | (quint64(data[3]) << 24U)
340 | (quint64(data[2]) << 16U) | (quint64(data[1]) << 8U) | data[0];
341 return true;
342}

References v.

◆ psdreadLE() [4/8]

bool psdreadLE ( QIODevice & io,
quint8 & v )
inline

Definition at line 272 of file psd_utils.h.

273{
274 std::array<quint8, 1> data;
275 qint64 read = io.read(reinterpret_cast<char *>(data.data()), 1);
276 if (read != 1)
277 return false;
278 v = data[0];
279 return true;
280}

References v.

◆ psdreadLE() [5/8]

template<typename T >
bool psdreadLE ( QIODevice & io,
std::enable_if_t< sizeof(T)==sizeof(quint16), T & > v )
inline

Definition at line 379 of file psd_utils.h.

380{
381 return psdreadLE(io, reinterpret_cast<quint16 &>(v));
382}
bool psdreadLE(QIODevice &io, quint8 &v)
Definition psd_utils.h:272

References psdreadLE(), and v.

◆ psdreadLE() [6/8]

template<typename T >
bool psdreadLE ( QIODevice & io,
std::enable_if_t< sizeof(T)==sizeof(quint32), T & > v )
inline

Definition at line 385 of file psd_utils.h.

386{
387 return psdreadLE(io, reinterpret_cast<quint32 &>(v));
388}

References psdreadLE(), and v.

◆ psdreadLE() [7/8]

template<typename T >
bool psdreadLE ( QIODevice & io,
std::enable_if_t< sizeof(T)==sizeof(quint64), T & > v )
inline

Definition at line 391 of file psd_utils.h.

392{
393 return psdreadLE(io, reinterpret_cast<quint64 &>(v));
394}

References psdreadLE(), and v.

◆ psdreadLE() [8/8]

template<typename T >
bool psdreadLE ( QIODevice & io,
std::enable_if_t< sizeof(T)==sizeof(quint8), T & > v )
inline

Definition at line 373 of file psd_utils.h.

374{
375 return psdreadLE(io, reinterpret_cast<quint8 &>(v));
376}

References psdreadLE(), and v.

◆ psdwrite() [1/2]

bool psdwrite ( QIODevice & io,
const QString & s )
inline

Definition at line 179 of file psd_utils.h.

180{
181 const QByteArray b = s.toLatin1();
182 int l = b.size();
183 const qint64 written = io.write(reinterpret_cast<const char *>(b.data()), l);
184 return written == l;
185}

◆ psdwrite() [2/2]

template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian, typename T >
std::enable_if_t< std::is_arithmetic< T >::value, bool > psdwrite ( QIODevice & io,
T v )
inline

Definition at line 170 of file psd_utils.h.

171{
172 if (byteOrder == psd_byte_order::psdLittleEndian) {
173 return psdwriteLE<T>(io, v);
174 } else {
175 return psdwriteBE<T>(io, v);
176 }
177}

References psdLittleEndian, and v.

◆ psdwrite_pascalstring() [1/2]

template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>
bool psdwrite_pascalstring ( QIODevice & io,
const QString & s )
inline

Definition at line 188 of file psd_utils.h.

189{
190 Q_ASSERT(s.length() < 256);
191 Q_ASSERT(s.length() >= 0);
192 if (s.length() < 0 || s.length() > 255)
193 return false;
194
195 if (s.isNull()) {
196 psdwrite<byteOrder>(io, quint8(0));
197 psdwrite<byteOrder>(io, quint8(0));
198 return true;
199 }
200
201 quint8 length = static_cast<quint8>(s.length());
202 psdwrite<byteOrder>(io, length);
203
204 const QByteArray b = s.toLatin1();
205 const qint64 written = io.write(reinterpret_cast<const char *>(b.data()), length);
206 if (written != length)
207 return false;
208
209 if ((length & 0x01) != 0) {
210 return psdwrite<byteOrder>(io, quint8(0));
211 }
212
213 return true;
214}

References length().

◆ psdwrite_pascalstring() [2/2]

template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>
bool psdwrite_pascalstring ( QIODevice & io,
const QString & s,
int padding )
inline

Definition at line 217 of file psd_utils.h.

218{
219 Q_ASSERT(s.length() < 256);
220 Q_ASSERT(s.length() >= 0);
221 if (s.length() < 0 || s.length() > 255)
222 return false;
223
224 if (s.isNull()) {
225 psdwrite<byteOrder>(io, quint8(0));
226 psdwrite<byteOrder>(io, quint8(0));
227 return true;
228 }
229 quint8 length = static_cast<quint8>(s.length());
230 psdwrite<byteOrder>(io, length);
231
232 QByteArray b = s.toLatin1();
233 const qint64 written = io.write(b.data(), length);
234 if (written != length)
235 return false;
236
237 // If the total length (length byte + content) is not a multiple of padding, add zeroes to pad
238 length++;
239 if ((length % padding) != 0) {
240 for (int i = 0; i < (padding - (length % padding)); i++) {
241 psdwrite<byteOrder>(io, quint8(0));
242 }
243 }
244
245 return true;
246}

References length().

◆ psdwriteBE() [1/8]

bool psdwriteBE ( QIODevice & io,
const quint16 & v )
inline

Definition at line 41 of file psd_utils.h.

42{
43 const std::array<quint8, 2> val = {
44 quint8(v >> 8U),
45 quint8(v),
46 };
47 const qint64 written = io.write(reinterpret_cast<const char *>(val.data()), 2);
48 return written == 2;
49}

References v.

◆ psdwriteBE() [2/8]

bool psdwriteBE ( QIODevice & io,
const quint32 & v )
inline

Definition at line 61 of file psd_utils.h.

62{
63 const std::array<quint8, 4> val = {
64 quint8(v >> 24U),
65 quint8(v >> 16U),
66 quint8(v >> 8U),
67 quint8(v),
68 };
69 const qint64 written = io.write(reinterpret_cast<const char *>(val.data()), 4);
70 return written == 4;
71}

References v.

◆ psdwriteBE() [3/8]

bool psdwriteBE ( QIODevice & io,
const quint64 & v )
inline

Definition at line 85 of file psd_utils.h.

86{
87 const std::array<quint8, 8> val = {
88 quint8(v >> 56U),
89 quint8(v >> 48U),
90 quint8(v >> 40U),
91 quint8(v >> 32U),
92 quint8(v >> 24U),
93 quint8(v >> 16U),
94 quint8(v >> 8U),
95 quint8(v),
96 };
97 const qint64 written = io.write(reinterpret_cast<const char *>(val.data()), 8);
98 return written == 8;
99}

References v.

◆ psdwriteBE() [4/8]

bool psdwriteBE ( QIODevice & io,
const quint8 & v )
inline

Writing functions.

Definition at line 27 of file psd_utils.h.

28{
29 const std::array<quint8, 2> val = {v};
30 const qint64 written = io.write(reinterpret_cast<const char *>(val.data()), 1);
31 return written == 1;
32}

References v.

◆ psdwriteBE() [5/8]

template<typename T >
bool psdwriteBE ( QIODevice & io,
std::enable_if_t< sizeof(T)==sizeof(quint16), T & > v )
inline

Definition at line 128 of file psd_utils.h.

129{
130 return psdwriteBE(io, reinterpret_cast<quint16 &>(v));
131}
bool psdwriteBE(QIODevice &io, const quint8 &v)
Definition psd_utils.h:27

References psdwriteBE(), and v.

◆ psdwriteBE() [6/8]

template<typename T >
bool psdwriteBE ( QIODevice & io,
std::enable_if_t< sizeof(T)==sizeof(quint32), T & > v )
inline

Definition at line 134 of file psd_utils.h.

135{
136 return psdwriteBE(io, reinterpret_cast<quint32 &>(v));
137}

References psdwriteBE(), and v.

◆ psdwriteBE() [7/8]

template<typename T >
bool psdwriteBE ( QIODevice & io,
std::enable_if_t< sizeof(T)==sizeof(quint64), T & > v )
inline

Definition at line 140 of file psd_utils.h.

141{
142 return psdwriteBE(io, reinterpret_cast<quint64 &>(v));
143}

References psdwriteBE(), and v.

◆ psdwriteBE() [8/8]

template<typename T >
bool psdwriteBE ( QIODevice & io,
std::enable_if_t< sizeof(T)==sizeof(quint8), T & > v )
inline

Templated writing fallbacks for non-integral types.

Definition at line 122 of file psd_utils.h.

123{
124 return psdwriteBE(io, reinterpret_cast<quint8 &>(v));
125}

References psdwriteBE(), and v.

◆ psdwriteFixedPoint()

template<psd_byte_order byteOrder = psd_byte_order::psdBigEndian>
void psdwriteFixedPoint ( QIODevice & io,
double val )
inline

Definition at line 522 of file psd_utils.h.

523{
524 qint32 data;
525 double max24 = 16777215.0;
526 // val is bound to -16 to +16
527
528 qint32 man = qint32(val);
529 quint32 frac= quint32(fabs(val - man) * max24);
530 data = (qAbs(man) << 24) | frac;
531 if (val < 0) {
532 data *= -1;
533 };
534
535 psdwrite<byteOrder>(io, data);
536}

◆ psdwriteLE() [1/8]

bool psdwriteLE ( QIODevice & io,
const quint16 & v )
inline

Definition at line 51 of file psd_utils.h.

52{
53 const std::array<quint8, 2> val = {
54 quint8(v),
55 quint8(v >> 8U),
56 };
57 const qint64 written = io.write(reinterpret_cast<const char *>(val.data()), 2);
58 return written == 2;
59}

References v.

◆ psdwriteLE() [2/8]

bool psdwriteLE ( QIODevice & io,
const quint32 & v )
inline

Definition at line 73 of file psd_utils.h.

74{
75 const std::array<quint8, 4> val = {
76 quint8(v),
77 quint8(v >> 8U),
78 quint8(v >> 16U),
79 quint8(v >> 24U),
80 };
81 const qint64 written = io.write(reinterpret_cast<const char *>(val.data()), 4);
82 return written == 4;
83}

References v.

◆ psdwriteLE() [3/8]

bool psdwriteLE ( QIODevice & io,
const quint64 & v )
inline

Definition at line 101 of file psd_utils.h.

102{
103 const std::array<quint8, 8> val = {
104 quint8(v),
105 quint8(v >> 8U),
106 quint8(v >> 16U),
107 quint8(v >> 24U),
108 quint8(v >> 32U),
109 quint8(v >> 40U),
110 quint8(v >> 48U),
111 quint8(v >> 56U),
112 };
113 const qint64 written = io.write(reinterpret_cast<const char *>(val.data()), 8);
114 return written == 8;
115}

References v.

◆ psdwriteLE() [4/8]

bool psdwriteLE ( QIODevice & io,
const quint8 & v )
inline

Definition at line 34 of file psd_utils.h.

35{
36 const std::array<quint8, 2> val = {v};
37 const qint64 written = io.write(reinterpret_cast<const char *>(val.data()), 1);
38 return written == 1;
39}

References v.

◆ psdwriteLE() [5/8]

template<typename T >
bool psdwriteLE ( QIODevice & io,
std::enable_if_t< sizeof(T)==sizeof(quint16), T & > v )
inline

Definition at line 152 of file psd_utils.h.

153{
154 return psdwriteLE(io, reinterpret_cast<quint16 &>(v));
155}
bool psdwriteLE(QIODevice &io, const quint8 &v)
Definition psd_utils.h:34

References psdwriteLE(), and v.

◆ psdwriteLE() [6/8]

template<typename T >
bool psdwriteLE ( QIODevice & io,
std::enable_if_t< sizeof(T)==sizeof(quint32), T & > v )
inline

Definition at line 158 of file psd_utils.h.

159{
160 return psdwriteLE(io, reinterpret_cast<quint32 &>(v));
161}

References psdwriteLE(), and v.

◆ psdwriteLE() [7/8]

template<typename T >
bool psdwriteLE ( QIODevice & io,
std::enable_if_t< sizeof(T)==sizeof(quint64), T & > v )
inline

Definition at line 164 of file psd_utils.h.

165{
166 return psdwriteLE(io, reinterpret_cast<quint64 &>(v));
167}

References psdwriteLE(), and v.

◆ psdwriteLE() [8/8]

template<typename T >
bool psdwriteLE ( QIODevice & io,
std::enable_if_t< sizeof(T)==sizeof(quint8), T & > v )
inline

Definition at line 146 of file psd_utils.h.

147{
148 return psdwriteLE(io, reinterpret_cast<quint8 &>(v));
149}

References psdwriteLE(), and v.