From d4b46a4bb6f70111bb155accfc69236489e175ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Wed, 22 Aug 2018 00:14:07 +0200 Subject: [PATCH] Broken OpenGL image part drawing workaround --- src/map/geotiffmap.cpp | 11 ++++++++--- src/map/ozimap.cpp | 8 ++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/map/geotiffmap.cpp b/src/map/geotiffmap.cpp index 63125d1e..6f439594 100644 --- a/src/map/geotiffmap.cpp +++ b/src/map/geotiffmap.cpp @@ -79,7 +79,12 @@ void GeoTIFFMap::draw(QPainter *painter, const QRectF &rect, bool block) { Q_UNUSED(block) - if (_img && !_img->isNull()) - painter->drawImage(rect.topLeft(), *_img, QRectF(rect.topLeft() - * _ratio, rect.size() * _ratio)); + if (_img && !_img->isNull()) { + /* Drawing directly a sub-rectangle without an image copy does not work + for big images under OpenGL. The image is most probably loaded as + whole which exceeds the texture size limit. */ + QRectF sr(rect.topLeft() * _ratio, rect.size() * _ratio); + QImage img(_img->copy(sr.toRect())); + painter->drawImage(rect.topLeft(), img); + } } diff --git a/src/map/ozimap.cpp b/src/map/ozimap.cpp index 55649d8d..0f1ab262 100644 --- a/src/map/ozimap.cpp +++ b/src/map/ozimap.cpp @@ -302,8 +302,12 @@ void OziMap::drawOZF(QPainter *painter, const QRectF &rect) const void OziMap::drawImage(QPainter *painter, const QRectF &rect) const { - painter->drawImage(rect.topLeft(), *_img, QRectF(rect.topLeft() * _ratio, - rect.size() * _ratio)); + /* Drawing directly a sub-rectangle without an image copy does not work + for big images under OpenGL. The image is most probably loaded as + whole which exceeds the texture size limit. */ + QRectF sr(rect.topLeft() * _ratio, rect.size() * _ratio); + QImage img(_img->copy(sr.toRect())); + painter->drawImage(rect.topLeft(), img); } void OziMap::draw(QPainter *painter, const QRectF &rect, bool block)