From 6ed37c880adff20302be8d209fba1ac6faf72ce7 Mon Sep 17 00:00:00 2001 From: Nathaniel MacArthur-Warner Date: Wed, 23 Dec 2020 17:32:31 -0800 Subject: [PATCH] When creating composite orthophoto, only scale sub images when necessary --- simgear/scene/util/OrthophotoManager.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/simgear/scene/util/OrthophotoManager.cxx b/simgear/scene/util/OrthophotoManager.cxx index 617138e5..9dca6ac2 100644 --- a/simgear/scene/util/OrthophotoManager.cxx +++ b/simgear/scene/util/OrthophotoManager.cxx @@ -18,6 +18,7 @@ // Boston, MA 02110-1301, USA. #include "OrthophotoManager.hxx" +#include namespace simgear { @@ -285,16 +286,20 @@ namespace simgear { const int s_offset = degs_to_pixels_x * _bbox.getLonOffset(bounds); const int t_offset = degs_to_pixels_y * _bbox.getLatOffset(bounds); - // Make a deep copy of the orthophoto's image so that we don't modify the original when scaling - ImageRef sub_image = new osg::Image(*orthophoto->_texture->getImage(), osg::CopyOp::DEEP_COPY_ALL); + ImageRef sub_image = orthophoto->_texture->getImage(); if (sub_image->getPixelFormat() != pixel_format) { SG_LOG(SG_OSG, SG_ALERT, "Pixel format mismatch. Not creating part of composite orthophoto."); continue; } - sub_image->scaleImage(width, height, depth); - + if (sub_image->s() != width || sub_image->t() != height) { + SG_LOG(SG_OSG, SG_WARN, "Orthophoto resolution mismatch. Automatic scaling will be performed."); + // Make a deep copy of the orthophoto's image so that we don't modify the original when scaling + sub_image = new osg::Image(*sub_image, osg::CopyOp::DEEP_COPY_ALL); + sub_image->scaleImage(width, height, depth); + } + composite_image->copySubImage(s_offset, t_offset, 0, sub_image); }