diff --git a/src/imageformats/pic_read.cpp b/src/imageformats/pic_read.cpp index 4243218..484c634 100644 --- a/src/imageformats/pic_read.cpp +++ b/src/imageformats/pic_read.cpp @@ -26,7 +26,8 @@ */ #include "pic_rw.h" -#include + +#include #include #include #include @@ -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; diff --git a/src/imageformats/pic_write.cpp b/src/imageformats/pic_write.cpp index 99cd6a1..0632eeb 100644 --- a/src/imageformats/pic_write.cpp +++ b/src/imageformats/pic_write.cpp @@ -26,9 +26,9 @@ */ #include "pic_rw.h" -#include #include #include +#include /** * 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(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(width); + h.height = qToBigEndian(height); h.ratio = 1.0f; - h.fields = htons(BOTH); + h.fields = qToBigEndian(BOTH); count = dev->write((const char *) & h, sizeof(PICHeader)); if (count != sizeof(PICHeader)) { return false;