2018-01-08 23:47:45 +01:00
|
|
|
#include "tifffile.h"
|
|
|
|
|
|
|
|
#define TIFF_II 0x4949
|
|
|
|
#define TIFF_MM 0x4D4D
|
|
|
|
#define TIFF_MAGIC 42
|
|
|
|
|
2019-03-13 00:25:46 +01:00
|
|
|
TIFFFile::TIFFFile(QIODevice *device) : _device(device), _ifd(0)
|
2018-01-08 23:47:45 +01:00
|
|
|
{
|
|
|
|
quint16 endian, magic;
|
|
|
|
|
2019-03-13 00:25:46 +01:00
|
|
|
if (_device->read((char*)&endian, sizeof(endian)) < (qint64)sizeof(endian))
|
|
|
|
return;
|
2018-01-08 23:47:45 +01:00
|
|
|
if (endian == TIFF_II)
|
|
|
|
_be = false;
|
|
|
|
else if (endian == TIFF_MM)
|
|
|
|
_be = true;
|
|
|
|
else
|
2019-03-13 00:25:46 +01:00
|
|
|
return;
|
2018-01-08 23:47:45 +01:00
|
|
|
|
|
|
|
if (!readValue(magic))
|
2019-03-13 00:25:46 +01:00
|
|
|
return;
|
2018-01-08 23:47:45 +01:00
|
|
|
if (magic != TIFF_MAGIC)
|
2019-03-13 00:25:46 +01:00
|
|
|
return;
|
|
|
|
if (!readValue(_ifd))
|
|
|
|
return;
|
2018-01-08 23:47:45 +01:00
|
|
|
}
|