| 97 | } |
| 98 | |
| 99 | void ThumbnailGeneratorThread::createThumbnail() |
| 100 | { |
| 101 | QImage tmpImage, thumbnail; |
| 102 | Image my_image; |
| 103 | |
| 104 | int img_width = 0; |
| 105 | int img_height = 0; |
| 106 | |
| 107 | double img_dens_x = 0.0; |
| 108 | double img_dens_y = 0.0; |
| 109 | |
| 110 | int orientation = 0; |
| 111 | |
| 112 | my_image.quiet(true); |
| 113 | |
| 114 | if (Formats::isNativeReadable(m_fileName)) { |
| 115 | QImageReader imgReader(m_fileName); |
| 116 | tmpImage = imgReader.read(); |
| 117 | |
| 118 | img_width = tmpImage.width(); |
| 119 | img_height = tmpImage.height(); |
| 120 | |
| 121 | try { |
| 122 | my_image.ping(m_fileName.toStdString()); |
| 123 | |
| 124 | orientation = my_image.orientation(); |
| 125 | my_image.autoOrient(); |
| 126 | |
| 127 | img_dens_x = my_image.xResolution(); |
| 128 | img_dens_y = my_image.yResolution(); |
| 129 | } |
| 130 | catch (Error &error) { |
| 131 | QString err_read_status = QString("Error in reading metadata (Generating preview): %1").arg(QString::fromStdString(error.what())); |
| 132 | qWarning() << "Read Error: " << err_read_status; |
| 133 | |
| 134 | int dpiX = tmpImage.dotsPerMeterX(); |
| 135 | int dpiY = tmpImage.dotsPerMeterY(); |
| 136 | |
| 137 | img_dens_x = qRound(dpiX * 0.0254); |
| 138 | img_dens_y = qRound(dpiY * 0.0254); |
| 139 | } |
| 140 | catch( Magick::WarningCoder &warning ) |
| 141 | { |
| 142 | qWarning() << "Read Warning: " << QString("Warning : %1").arg(QString::fromStdString(warning.what()));; |
| 143 | } |
| 144 | catch( Magick::Warning &warning ) |
| 145 | { |
| 146 | qWarning() << "Read Warning: " << QString("Warning : %1").arg(QString::fromStdString(warning.what()));; |
| 147 | } |
| 148 | |
| 149 | if (m_generateThumbnail) { |
| 150 | qreal scaleFactor = globals::Globals::scaleFactor(); |
| 151 | |
| 152 | tmpImage = autoOrientImage(tmpImage, orientation); |
| 153 | |
| 154 | thumbnail = tmpImage.scaled(QSize(MAX_THUMB_W, MAX_THUMB_H) * scaleFactor, |
| 155 | Qt::KeepAspectRatio, |
| 156 | Qt::SmoothTransformation); |
nothing calls this directly
no outgoing calls
no test coverage detected