Qt 4.8
Functions
qtiffhandler.cpp File Reference
#include "qtiffhandler_p.h"
#include <qvariant.h>
#include <qdebug.h>
#include <qimage.h>
#include <qglobal.h>
#include "tiffio.h"

Go to the source code of this file.

Functions

static bool checkGrayscale (const QVector< QRgb > &colorTable)
 
int qtiffCloseProc (thandle_t)
 
int qtiffMapProc (thandle_t, tdata_t *, toff_t *)
 
tsize_t qtiffReadProc (thandle_t fd, tdata_t buf, tsize_t size)
 
toff_t qtiffSeekProc (thandle_t fd, toff_t off, int whence)
 
toff_t qtiffSizeProc (thandle_t fd)
 
void qtiffUnmapProc (thandle_t, tdata_t, toff_t)
 
tsize_t qtiffWriteProc (thandle_t fd, tdata_t buf, tsize_t size)
 
void rotate_right_mirror_horizontal (QImage *const image)
 
void rotate_right_mirror_vertical (QImage *const image)
 

Function Documentation

◆ checkGrayscale()

static bool checkGrayscale ( const QVector< QRgb > &  colorTable)
static

Definition at line 391 of file qtiffhandler.cpp.

Referenced by QTiffHandler::write().

392 {
393  if (colorTable.size() != 256)
394  return false;
395 
396  const bool increasing = (colorTable.at(0) == 0xff000000);
397  for (int i = 0; i < 256; ++i) {
398  if ((increasing && colorTable.at(i) != qRgb(i, i, i))
399  || (!increasing && colorTable.at(i) != qRgb(255 - i, 255 - i, 255 - i)))
400  return false;
401  }
402  return true;
403 }
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QRgb qRgb(int r, int g, int b)
Returns the ARGB quadruplet (255, {r}, {g}, {b}).
Definition: qrgb.h:69
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ qtiffCloseProc()

int qtiffCloseProc ( thandle_t  )

Definition at line 82 of file qtiffhandler.cpp.

Referenced by QTiffHandler::option(), QTiffHandler::read(), and QTiffHandler::write().

83 {
84  return 0;
85 }

◆ qtiffMapProc()

int qtiffMapProc ( thandle_t  ,
tdata_t *  ,
toff_t *   
)

Definition at line 92 of file qtiffhandler.cpp.

Referenced by QTiffHandler::option(), QTiffHandler::read(), and QTiffHandler::write().

93 {
94  return 0;
95 }

◆ qtiffReadProc()

tsize_t qtiffReadProc ( thandle_t  fd,
tdata_t  buf,
tsize_t  size 
)

Definition at line 53 of file qtiffhandler.cpp.

Referenced by QTiffHandler::option(), QTiffHandler::read(), and QTiffHandler::write().

54 {
55  QIODevice* device = static_cast<QTiffHandler*>(fd)->device();
56  return device->isReadable() ? device->read(static_cast<char *>(buf), size) : -1;
57 }
bool isReadable() const
Returns true if data can be read from the device; otherwise returns false.
Definition: qiodevice.cpp:544
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
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66

◆ qtiffSeekProc()

toff_t qtiffSeekProc ( thandle_t  fd,
toff_t  off,
int  whence 
)

Definition at line 64 of file qtiffhandler.cpp.

Referenced by QTiffHandler::option(), QTiffHandler::read(), and QTiffHandler::write().

65 {
66  QIODevice *device = static_cast<QTiffHandler*>(fd)->device();
67  switch (whence) {
68  case SEEK_SET:
69  device->seek(off);
70  break;
71  case SEEK_CUR:
72  device->seek(device->pos() + off);
73  break;
74  case SEEK_END:
75  device->seek(device->size() + off);
76  break;
77  }
78 
79  return device->pos();
80 }
virtual qint64 size() const
For open random-access devices, this function returns the size of the device.
Definition: qiodevice.cpp:642
virtual qint64 pos() const
For random-access devices, this function returns the position that data is written to or read from...
Definition: qiodevice.cpp:624
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
virtual bool seek(qint64 pos)
For random-access devices, this function sets the current position to pos, returning true on success...
Definition: qiodevice.cpp:659

◆ qtiffSizeProc()

toff_t qtiffSizeProc ( thandle_t  fd)

Definition at line 87 of file qtiffhandler.cpp.

Referenced by QTiffHandler::option(), QTiffHandler::read(), and QTiffHandler::write().

88 {
89  return static_cast<QTiffHandler*>(fd)->device()->size();
90 }

◆ qtiffUnmapProc()

void qtiffUnmapProc ( thandle_t  ,
tdata_t  ,
toff_t   
)

Definition at line 97 of file qtiffhandler.cpp.

Referenced by QTiffHandler::option(), QTiffHandler::read(), and QTiffHandler::write().

98 {
99 }

◆ qtiffWriteProc()

tsize_t qtiffWriteProc ( thandle_t  fd,
tdata_t  buf,
tsize_t  size 
)

Definition at line 59 of file qtiffhandler.cpp.

Referenced by QTiffHandler::option(), QTiffHandler::read(), and QTiffHandler::write().

60 {
61  return static_cast<QTiffHandler*>(fd)->device()->write(static_cast<char *>(buf), size);
62 }
bool write(const QImage &image)
Writes the image image to the assigned device.

◆ rotate_right_mirror_horizontal()

void rotate_right_mirror_horizontal ( QImage *const  image)
inline

Definition at line 102 of file qtiffhandler.cpp.

Referenced by QTiffHandler::read().

103 {
104  const int height = image->height();
105  const int width = image->width();
106  QImage generated(/* width = */ height, /* height = */ width, image->format());
107  const uint32 *originalPixel = reinterpret_cast<const uint32*>(image->bits());
108  uint32 *const generatedPixels = reinterpret_cast<uint32*>(generated.bits());
109  for (int row=0; row < height; ++row) {
110  for (int col=0; col < width; ++col) {
111  int idx = col * height + row;
112  generatedPixels[idx] = *originalPixel;
113  ++originalPixel;
114  }
115  }
116  *image = generated;
117 }
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572

◆ rotate_right_mirror_vertical()

void rotate_right_mirror_vertical ( QImage *const  image)
inline

Definition at line 119 of file qtiffhandler.cpp.

Referenced by QTiffHandler::read().

120 {
121  const int height = image->height();
122  const int width = image->width();
123  QImage generated(/* width = */ height, /* height = */ width, image->format());
124  const int lastCol = width - 1;
125  const int lastRow = height - 1;
126  const uint32 *pixel = reinterpret_cast<const uint32*>(image->bits());
127  uint32 *const generatedBits = reinterpret_cast<uint32*>(generated.bits());
128  for (int row=0; row < height; ++row) {
129  for (int col=0; col < width; ++col) {
130  int idx = (lastCol - col) * height + (lastRow - row);
131  generatedBits[idx] = *pixel;
132  ++pixel;
133  }
134  }
135  *image = generated;
136 }
Format format() const
Returns the format of the image.
Definition: qimage.cpp:2305
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572