Qt 4.8
Classes | Macros | Typedefs | Functions
qicohandler.cpp File Reference
#include "qicohandler.h"
#include <QtCore/qendian.h>
#include <QtGui/QImage>
#include <QtCore/QFile>
#include <QtCore/QBuffer>
#include <qvariant.h>

Go to the source code of this file.

Classes

struct  BMP_INFOHDR
 
struct  ICONDIR
 
struct  ICONDIRENTRY
 
class  ICOReader
 
struct  ICOReader::IcoAttrib
 

Macros

#define BMP_INFOHDR_SIZE   40
 
#define ICONDIR_SIZE   6
 
#define ICONDIRENTRY_SIZE   16
 

Typedefs

typedef struct BMP_INFOHDRLPBMP_INFOHDR
 
typedef struct ICONDIRLPICONDIR
 
typedef struct ICONDIRENTRYLPICONDIRENTRY
 

Functions

static bool readBMPInfoHeader (QIODevice *iodev, BMP_INFOHDR *pHeader)
 
static bool readIconDir (QIODevice *iodev, ICONDIR *iconDir)
 
static bool readIconDirEntry (QIODevice *iodev, ICONDIRENTRY *iconDirEntry)
 
static bool writeBMPInfoHeader (QIODevice *iodev, const BMP_INFOHDR &header)
 
static bool writeIconDir (QIODevice *iodev, const ICONDIR &iconDir)
 
static bool writeIconDirEntry (QIODevice *iodev, const ICONDIRENTRY &iconEntry)
 

Macro Definition Documentation

◆ BMP_INFOHDR_SIZE

#define BMP_INFOHDR_SIZE   40

Definition at line 100 of file qicohandler.cpp.

Referenced by readBMPInfoHeader(), ICOReader::write(), and writeBMPInfoHeader().

◆ ICONDIR_SIZE

#define ICONDIR_SIZE   6

◆ ICONDIRENTRY_SIZE

#define ICONDIRENTRY_SIZE   16

Typedef Documentation

◆ LPBMP_INFOHDR

typedef struct BMP_INFOHDR* LPBMP_INFOHDR

◆ LPICONDIR

typedef struct ICONDIR * LPICONDIR

◆ LPICONDIRENTRY

typedef struct ICONDIRENTRY * LPICONDIRENTRY

Function Documentation

◆ readBMPInfoHeader()

static bool readBMPInfoHeader ( QIODevice iodev,
BMP_INFOHDR pHeader 
)
static

Definition at line 209 of file qicohandler.cpp.

Referenced by ICOReader::readBMPHeader().

210 {
211  if (iodev) {
212  uchar header[BMP_INFOHDR_SIZE];
213  if (iodev->read((char*)header, BMP_INFOHDR_SIZE) == BMP_INFOHDR_SIZE) {
214  pHeader->biSize = qFromLittleEndian<quint32>(&header[0]);
215  pHeader->biWidth = qFromLittleEndian<quint32>(&header[4]);
216  pHeader->biHeight = qFromLittleEndian<quint32>(&header[8]);
217  pHeader->biPlanes = qFromLittleEndian<quint16>(&header[12]);
218  pHeader->biBitCount = qFromLittleEndian<quint16>(&header[14]);
219  pHeader->biCompression = qFromLittleEndian<quint32>(&header[16]);
220  pHeader->biSizeImage = qFromLittleEndian<quint32>(&header[20]);
221  pHeader->biXPelsPerMeter = qFromLittleEndian<quint32>(&header[24]);
222  pHeader->biYPelsPerMeter = qFromLittleEndian<quint32>(&header[28]);
223  pHeader->biClrUsed = qFromLittleEndian<quint32>(&header[32]);
224  pHeader->biClrImportant = qFromLittleEndian<quint32>(&header[36]);
225  return true;
226  }
227  }
228  return false;
229 }
quint16 qFromLittleEndian< quint16 >(const uchar *src)
Definition: qendian.h:157
qint32 biSize
Definition: qbmphandler_p.h:71
#define BMP_INFOHDR_SIZE
qint32 biSizeImage
Definition: qbmphandler_p.h:77
qint32 biClrUsed
Definition: qbmphandler_p.h:80
qint32 biWidth
Definition: qbmphandler_p.h:72
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read...
Definition: qiodevice.cpp:791
unsigned char uchar
Definition: qglobal.h:994
qint32 biYPelsPerMeter
Definition: qbmphandler_p.h:79
quint32 qFromLittleEndian< quint32 >(const uchar *src)
Definition: qendian.h:148
qint16 biBitCount
Definition: qbmphandler_p.h:75
qint32 biCompression
Definition: qbmphandler_p.h:76
qint32 biClrImportant
Definition: qbmphandler_p.h:81
qint32 biXPelsPerMeter
Definition: qbmphandler_p.h:78
qint16 biPlanes
Definition: qbmphandler_p.h:74
qint32 biHeight
Definition: qbmphandler_p.h:73

◆ readIconDir()

static bool readIconDir ( QIODevice iodev,
ICONDIR iconDir 
)
static

Definition at line 183 of file qicohandler.cpp.

Referenced by ICOReader::canRead(), and ICOReader::readHeader().

184 {
185  if (iodev) {
186  uchar tmp[ICONDIR_SIZE];
187  if (iodev->read((char*)tmp, ICONDIR_SIZE) == ICONDIR_SIZE) {
188  iconDir->idReserved = qFromLittleEndian<quint16>(&tmp[0]);
189  iconDir->idType = qFromLittleEndian<quint16>(&tmp[2]);
190  iconDir->idCount = qFromLittleEndian<quint16>(&tmp[4]);
191  return true;
192  }
193  }
194  return false;
195 }
#define ICONDIR_SIZE
Definition: qicohandler.cpp:85
quint16 qFromLittleEndian< quint16 >(const uchar *src)
Definition: qendian.h:157
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read...
Definition: qiodevice.cpp:791
unsigned char uchar
Definition: qglobal.h:994
quint16 idReserved
Definition: qicohandler.cpp:80
quint16 idType
Definition: qicohandler.cpp:81
quint16 idCount
Definition: qicohandler.cpp:82

◆ readIconDirEntry()

static bool readIconDirEntry ( QIODevice iodev,
ICONDIRENTRY iconDirEntry 
)
static

Definition at line 145 of file qicohandler.cpp.

Referenced by ICOReader::canRead(), QtIcoHandler::option(), and ICOReader::readIconEntry().

146 {
147  if (iodev) {
149  if (iodev->read((char*)tmp, ICONDIRENTRY_SIZE) == ICONDIRENTRY_SIZE) {
150  iconDirEntry->bWidth = tmp[0];
151  iconDirEntry->bHeight = tmp[1];
152  iconDirEntry->bColorCount = tmp[2];
153  iconDirEntry->bReserved = tmp[3];
154 
155  iconDirEntry->wPlanes = qFromLittleEndian<quint16>(&tmp[4]);
156  iconDirEntry->wBitCount = qFromLittleEndian<quint16>(&tmp[6]);
157  iconDirEntry->dwBytesInRes = qFromLittleEndian<quint32>(&tmp[8]);
158  iconDirEntry->dwImageOffset = qFromLittleEndian<quint32>(&tmp[12]);
159  return true;
160  }
161  }
162  return false;
163 }
quint32 dwBytesInRes
Definition: qicohandler.cpp:73
quint8 bHeight
Definition: qicohandler.cpp:68
quint16 qFromLittleEndian< quint16 >(const uchar *src)
Definition: qendian.h:157
quint8 bColorCount
Definition: qicohandler.cpp:69
quint16 wBitCount
Definition: qicohandler.cpp:72
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read...
Definition: qiodevice.cpp:791
#define ICONDIRENTRY_SIZE
Definition: qicohandler.cpp:76
unsigned char uchar
Definition: qglobal.h:994
quint32 qFromLittleEndian< quint32 >(const uchar *src)
Definition: qendian.h:148
quint16 wPlanes
Definition: qicohandler.cpp:71
quint8 bReserved
Definition: qicohandler.cpp:70
quint32 dwImageOffset
Definition: qicohandler.cpp:74

◆ writeBMPInfoHeader()

static bool writeBMPInfoHeader ( QIODevice iodev,
const BMP_INFOHDR header 
)
static

Definition at line 231 of file qicohandler.cpp.

Referenced by ICOReader::write().

232 {
233  if (iodev) {
234  uchar tmp[BMP_INFOHDR_SIZE];
235  qToLittleEndian<quint32>(header.biSize, &tmp[0]);
236  qToLittleEndian<quint32>(header.biWidth, &tmp[4]);
237  qToLittleEndian<quint32>(header.biHeight, &tmp[8]);
238  qToLittleEndian<quint16>(header.biPlanes, &tmp[12]);
239  qToLittleEndian<quint16>(header.biBitCount, &tmp[14]);
240  qToLittleEndian<quint32>(header.biCompression, &tmp[16]);
241  qToLittleEndian<quint32>(header.biSizeImage, &tmp[20]);
242  qToLittleEndian<quint32>(header.biXPelsPerMeter, &tmp[24]);
243  qToLittleEndian<quint32>(header.biYPelsPerMeter, &tmp[28]);
244  qToLittleEndian<quint32>(header.biClrUsed, &tmp[32]);
245  qToLittleEndian<quint32>(header.biClrImportant, &tmp[36]);
246 
247  return (iodev->write((char*)tmp, BMP_INFOHDR_SIZE) == BMP_INFOHDR_SIZE) ? true : false;
248  }
249  return false;
250 }
qint32 biSize
Definition: qbmphandler_p.h:71
#define BMP_INFOHDR_SIZE
qint32 biSizeImage
Definition: qbmphandler_p.h:77
qint32 biClrUsed
Definition: qbmphandler_p.h:80
qint32 biWidth
Definition: qbmphandler_p.h:72
unsigned char uchar
Definition: qglobal.h:994
qint32 biYPelsPerMeter
Definition: qbmphandler_p.h:79
qint16 biBitCount
Definition: qbmphandler_p.h:75
qint32 biCompression
Definition: qbmphandler_p.h:76
qint32 biClrImportant
Definition: qbmphandler_p.h:81
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342
qint32 biXPelsPerMeter
Definition: qbmphandler_p.h:78
qint16 biPlanes
Definition: qbmphandler_p.h:74
qint32 biHeight
Definition: qbmphandler_p.h:73

◆ writeIconDir()

static bool writeIconDir ( QIODevice iodev,
const ICONDIR iconDir 
)
static

Definition at line 197 of file qicohandler.cpp.

Referenced by ICOReader::write().

198 {
199  if (iodev) {
200  uchar tmp[6];
201  qToLittleEndian(iconDir.idReserved, tmp);
202  qToLittleEndian(iconDir.idType, &tmp[2]);
203  qToLittleEndian(iconDir.idCount, &tmp[4]);
204  return (iodev->write((char*)tmp, 6) == 6) ? true : false;
205  }
206  return false;
207 }
unsigned char uchar
Definition: qglobal.h:994
quint16 idReserved
Definition: qicohandler.cpp:80
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342
quint16 idType
Definition: qicohandler.cpp:81
T qToLittleEndian(T source)
Definition: qendian.h:341
quint16 idCount
Definition: qicohandler.cpp:82

◆ writeIconDirEntry()

static bool writeIconDirEntry ( QIODevice iodev,
const ICONDIRENTRY iconEntry 
)
static

Definition at line 165 of file qicohandler.cpp.

Referenced by ICOReader::write().

166 {
167  if (iodev) {
169  tmp[0] = iconEntry.bWidth;
170  tmp[1] = iconEntry.bHeight;
171  tmp[2] = iconEntry.bColorCount;
172  tmp[3] = iconEntry.bReserved;
173  qToLittleEndian<quint16>(iconEntry.wPlanes, &tmp[4]);
174  qToLittleEndian<quint16>(iconEntry.wBitCount, &tmp[6]);
175  qToLittleEndian<quint32>(iconEntry.dwBytesInRes, &tmp[8]);
176  qToLittleEndian<quint32>(iconEntry.dwImageOffset, &tmp[12]);
177  return (iodev->write((char*)tmp, ICONDIRENTRY_SIZE) == ICONDIRENTRY_SIZE) ? true : false;
178  }
179 
180  return false;
181 }
quint32 dwBytesInRes
Definition: qicohandler.cpp:73
quint8 bHeight
Definition: qicohandler.cpp:68
quint8 bColorCount
Definition: qicohandler.cpp:69
quint16 wBitCount
Definition: qicohandler.cpp:72
#define ICONDIRENTRY_SIZE
Definition: qicohandler.cpp:76
unsigned char uchar
Definition: qglobal.h:994
quint16 wPlanes
Definition: qicohandler.cpp:71
quint8 bReserved
Definition: qicohandler.cpp:70
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342
quint32 dwImageOffset
Definition: qicohandler.cpp:74