Downscale image to max OpenGL texture
This commit is contained in:
@@ -99,6 +99,7 @@ void ImageWidget::setImage(std::shared_ptr<RawImage> image, int index)
|
|||||||
if(image == nullptr)return;
|
if(image == nullptr)return;
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
m_rawImage = image;
|
m_rawImage = image;
|
||||||
|
m_rawImage->downscaleTo(m_maxTextureSize);
|
||||||
|
|
||||||
m_imgWidth = image->width();
|
m_imgWidth = image->width();
|
||||||
m_imgHeight = image->height();
|
m_imgHeight = image->height();
|
||||||
@@ -398,9 +399,12 @@ void ImageWidget::initializeGL()
|
|||||||
qDebug() << message;
|
qDebug() << message;
|
||||||
});
|
});
|
||||||
|
|
||||||
qDebug() << (char*)f->glGetString(GL_VENDOR);
|
qDebug() << "Vendor:" << (char*)f->glGetString(GL_VENDOR);
|
||||||
qDebug() << (char*)f->glGetString(GL_RENDERER);
|
qDebug() << "Renderer:" << (char*)f->glGetString(GL_RENDERER);
|
||||||
qDebug() << (char*)f->glGetString(GL_VERSION);
|
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);
|
//MANUAL_MIPMAP_GEN = QString((const char*)f->glGetString(GL_VENDOR)).startsWith("ATI Technologies Inc", Qt::CaseInsensitive);
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ class ImageWidget : public QOpenGLWidget
|
|||||||
bool m_sizesDirty;
|
bool m_sizesDirty;
|
||||||
bool m_srgb;
|
bool m_srgb;
|
||||||
int m_thumbnailCount;
|
int m_thumbnailCount;
|
||||||
|
int m_maxTextureSize;
|
||||||
|
int m_maxArrayLayers;
|
||||||
QVector<ImageThumb> m_thumnails;
|
QVector<ImageThumb> m_thumnails;
|
||||||
Database *m_database;
|
Database *m_database;
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ public:
|
|||||||
const cv::Mat& mat() const;
|
const cv::Mat& mat() const;
|
||||||
bool pixel(int x, int y, QVector3D &rgb) const;
|
bool pixel(int x, int y, QVector3D &rgb) const;
|
||||||
void scaleToUnit();
|
void scaleToUnit();
|
||||||
|
void downscaleTo(uint32_t size);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RAWIMAGE_H
|
#endif // RAWIMAGE_H
|
||||||
|
|||||||
Reference in New Issue
Block a user