diff --git a/imagescrollareagl.cpp b/imagescrollareagl.cpp index f87188d..08c0fb7 100644 --- a/imagescrollareagl.cpp +++ b/imagescrollareagl.cpp @@ -99,6 +99,7 @@ void ImageWidget::setImage(std::shared_ptr image, int index) if(image == nullptr)return; makeCurrent(); m_rawImage = image; + m_rawImage->downscaleTo(m_maxTextureSize); m_imgWidth = image->width(); m_imgHeight = image->height(); @@ -398,9 +399,12 @@ void ImageWidget::initializeGL() qDebug() << message; }); - qDebug() << (char*)f->glGetString(GL_VENDOR); - qDebug() << (char*)f->glGetString(GL_RENDERER); - qDebug() << (char*)f->glGetString(GL_VERSION); + qDebug() << "Vendor:" << (char*)f->glGetString(GL_VENDOR); + qDebug() << "Renderer:" << (char*)f->glGetString(GL_RENDERER); + qDebug() << "Version:" << (char*)f->glGetString(GL_VERSION); + f->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize); + f->glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &m_maxArrayLayers); + qDebug() << "Max texture size:" << m_maxTextureSize << "max layers:" << m_maxArrayLayers; //MANUAL_MIPMAP_GEN = QString((const char*)f->glGetString(GL_VENDOR)).startsWith("ATI Technologies Inc", Qt::CaseInsensitive); diff --git a/imagescrollareagl.h b/imagescrollareagl.h index f9de4e0..0de769d 100644 --- a/imagescrollareagl.h +++ b/imagescrollareagl.h @@ -62,6 +62,8 @@ class ImageWidget : public QOpenGLWidget bool m_sizesDirty; bool m_srgb; int m_thumbnailCount; + int m_maxTextureSize; + int m_maxArrayLayers; QVector m_thumnails; Database *m_database; public: diff --git a/rawimage.cpp b/rawimage.cpp index 8fc4e4a..f43117e 100644 --- a/rawimage.cpp +++ b/rawimage.cpp @@ -410,3 +410,13 @@ void RawImage::scaleToUnit() } } } + +void RawImage::downscaleTo(uint32_t size) +{ + if(size < width() || size < height()) + { + double s = (double)size / std::max(width(), height()); + cv::Size dsize(std::floor(width() * s), std::floor(height() * s)); + cv::resize(m_img, m_img, dsize, 0, 0, cv::INTER_AREA); + } +} diff --git a/rawimage.h b/rawimage.h index 4604214..70f385c 100644 --- a/rawimage.h +++ b/rawimage.h @@ -86,6 +86,7 @@ public: const cv::Mat& mat() const; bool pixel(int x, int y, QVector3D &rgb) const; void scaleToUnit(); + void downscaleTo(uint32_t size); }; #endif // RAWIMAGE_H