Commit bcbaec05 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

tiff: Stop using deprecated types

parent 21f96680
Pipeline #79633 passed with stage
in 9 minutes and 12 seconds
......@@ -102,20 +102,20 @@ static QDateTime convertTIFFDateTime(const char *tiffdate)
return QDateTime::fromString(QString::fromLatin1(tiffdate), QStringLiteral("yyyy:MM:dd HH:mm:ss"));
}
static void adaptSizeToResolution(TIFF *tiff, ttag_t whichres, double dpi, uint32 *size)
static void adaptSizeToResolution(TIFF *tiff, ttag_t whichres, double dpi, uint32_t *size)
{
float resvalue = 1.0;
uint16 resunit = 0;
uint16_t resunit = 0;
if (!TIFFGetField(tiff, whichres, &resvalue) || !TIFFGetFieldDefaulted(tiff, TIFFTAG_RESOLUTIONUNIT, &resunit))
return;
float newsize = *size / resvalue;
switch (resunit) {
case RESUNIT_INCH:
*size = (uint32)(newsize * dpi);
*size = (uint32_t)(newsize * dpi);
break;
case RESUNIT_CENTIMETER:
*size = (uint32)(newsize * 10.0 / 25.4 * dpi);
*size = (uint32_t)(newsize * 10.0 / 25.4 * dpi);
break;
case RESUNIT_NONE:
break;
......@@ -124,7 +124,7 @@ static void adaptSizeToResolution(TIFF *tiff, ttag_t whichres, double dpi, uint3
static Okular::Rotation readTiffRotation(TIFF *tiff)
{
uint32 tiffOrientation = 0;
uint32_t tiffOrientation = 0;
if (!TIFFGetField(tiff, TIFFTAG_ORIENTATION, &tiffOrientation))
return Okular::Rotation0;
......@@ -229,9 +229,9 @@ QImage TIFFGenerator::image(Okular::PixmapRequest *request)
if (TIFFSetDirectory(d->tiff, mapPage(request->page()->number()))) {
int rotation = request->page()->rotation();
uint32 width = 1;
uint32 height = 1;
uint32 orientation = 0;
uint32_t width = 1;
uint32_t height = 1;
uint32_t orientation = 0;
TIFFGetField(d->tiff, TIFFTAG_IMAGEWIDTH, &width);
TIFFGetField(d->tiff, TIFFTAG_IMAGELENGTH, &height);
......@@ -239,15 +239,15 @@ QImage TIFFGenerator::image(Okular::PixmapRequest *request)
orientation = ORIENTATION_TOPLEFT;
QImage image(width, height, QImage::Format_RGB32);
uint32 *data = reinterpret_cast<uint32 *>(image.bits());
uint32_t *data = reinterpret_cast<uint32_t *>(image.bits());
// read data
if (TIFFReadRGBAImageOriented(d->tiff, width, height, data, orientation) != 0) {
// an image read by ReadRGBAImage is ABGR, we need ARGB, so swap red and blue
uint32 size = width * height;
for (uint32 i = 0; i < size; ++i) {
uint32 red = (data[i] & 0x00FF0000) >> 16;
uint32 blue = (data[i] & 0x000000FF) << 16;
uint32_t size = width * height;
for (uint32_t i = 0; i < size; ++i) {
uint32_t red = (data[i] & 0x00FF0000) >> 16;
uint32_t blue = (data[i] & 0x000000FF) << 16;
data[i] = (data[i] & 0xFF00FF00) + red + blue;
}
......@@ -320,8 +320,8 @@ void TIFFGenerator::loadPages(QVector<Okular::Page *> &pagesVector)
pagesVector.resize(dirs);
tdir_t realdirs = 0;
uint32 width = 0;
uint32 height = 0;
uint32_t width = 0;
uint32_t height = 0;
const QSizeF dpi = Okular::Utils::realDpi(nullptr);
for (tdir_t i = 0; i < dirs; ++i) {
......@@ -347,8 +347,8 @@ void TIFFGenerator::loadPages(QVector<Okular::Page *> &pagesVector)
bool TIFFGenerator::print(QPrinter &printer)
{
uint32 width = 0;
uint32 height = 0;
uint32_t width = 0;
uint32_t height = 0;
QPainter p(&printer);
......@@ -362,15 +362,15 @@ bool TIFFGenerator::print(QPrinter &printer)
continue;
QImage image(width, height, QImage::Format_RGB32);
uint32 *data = reinterpret_cast<uint32 *>(image.bits());
uint32_t *data = reinterpret_cast<uint32_t *>(image.bits());
// read data
if (TIFFReadRGBAImageOriented(d->tiff, width, height, data, ORIENTATION_TOPLEFT) != 0) {
// an image read by ReadRGBAImage is ABGR, we need ARGB, so swap red and blue
uint32 size = width * height;
for (uint32 j = 0; j < size; ++j) {
uint32 red = (data[j] & 0x00FF0000) >> 16;
uint32 blue = (data[j] & 0x000000FF) << 16;
uint32_t size = width * height;
for (uint32_t j = 0; j < size; ++j) {
uint32_t red = (data[j] & 0x00FF0000) >> 16;
uint32_t blue = (data[j] & 0x000000FF) << 16;
data[j] = (data[j] & 0xFF00FF00) + red + blue;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment