C++ (Qt)int dx = (newImg.width() - oldImg.width()) / 2;int dy = (newImg.height() - oldImg.height()) / 2;oldImg = newImg.copy(dx, dy, oldImg.width(), oldImg.height());