mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-05-28 00:30:23 -04:00
Use q{To,From}BigEndian instead of hton* and ntoh*
These functions don't seem to be available as inline functions on win32 REVIEW: 115345
This commit is contained in:
parent
bfea0e0e7c
commit
a533bcd418
@ -26,7 +26,8 @@
|
||||
*/
|
||||
|
||||
#include "pic_rw.h"
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <qendian.h>
|
||||
#include <iostream>
|
||||
#include <qimage.h>
|
||||
#include <algorithm>
|
||||
@ -47,10 +48,10 @@ bool picReadHeader(QIODevice *dev, PICHeader *hdr, bool peek)
|
||||
result = dev->read((char *) hdr, HEADER_SIZE);
|
||||
}
|
||||
|
||||
hdr->magic = ntohl(hdr->magic);
|
||||
hdr->width = ntohs(hdr->width);
|
||||
hdr->height = ntohs(hdr->height);
|
||||
hdr->fields = ntohs(hdr->fields);
|
||||
hdr->magic = qFromBigEndian(hdr->magic);
|
||||
hdr->width = qFromBigEndian(hdr->width);
|
||||
hdr->height = qFromBigEndian(hdr->height);
|
||||
hdr->fields = qFromBigEndian(hdr->fields);
|
||||
|
||||
if (hdr->magic != PIC_MAGIC_NUMBER || strncmp(hdr->id, "PICT", 4)) {
|
||||
return false;
|
||||
|
@ -26,9 +26,9 @@
|
||||
*/
|
||||
|
||||
#include "pic_rw.h"
|
||||
#include <netinet/in.h>
|
||||
#include <iostream>
|
||||
#include <qimage.h>
|
||||
#include <qendian.h>
|
||||
|
||||
/**
|
||||
* Writes the PIC header info.
|
||||
@ -46,14 +46,14 @@ static bool writeHeader(QIODevice *dev, std::string msg, unsigned width, unsigne
|
||||
unsigned count = 0;
|
||||
|
||||
memset(&h, 0, sizeof(PICHeader));
|
||||
h.magic = htonl(PIC_MAGIC_NUMBER);
|
||||
h.magic = qToBigEndian<qint32>(PIC_MAGIC_NUMBER);
|
||||
h.version = 3.71f;
|
||||
strcpy(h.comment, msg.c_str());
|
||||
strncpy(h.id, "PICT", 4);
|
||||
h.width = htons(width);
|
||||
h.height = htons(height);
|
||||
h.width = qToBigEndian<qint16>(width);
|
||||
h.height = qToBigEndian<qint16>(height);
|
||||
h.ratio = 1.0f;
|
||||
h.fields = htons(BOTH);
|
||||
h.fields = qToBigEndian<qint16>(BOTH);
|
||||
count = dev->write((const char *) & h, sizeof(PICHeader));
|
||||
if (count != sizeof(PICHeader)) {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user