diff --git a/include/utils/ImageData.h b/include/utils/ImageData.h index aad49876..f1cc3f59 100644 --- a/include/utils/ImageData.h +++ b/include/utils/ImageData.h @@ -136,7 +136,9 @@ public: void toRgb(ImageData& image) { - image.resize(_width, _height); + if (image.width() != _width || image.height() != _height) + image.resize(_width, _height); + const unsigned imageSize = _width * _height; for (unsigned idx = 0; idx < imageSize; idx++) diff --git a/libsrc/grabber/qt/QtGrabber.cpp b/libsrc/grabber/qt/QtGrabber.cpp index 1f24aa13..75803f27 100644 --- a/libsrc/grabber/qt/QtGrabber.cpp +++ b/libsrc/grabber/qt/QtGrabber.cpp @@ -101,6 +101,7 @@ int QtGrabber::grabFrame(Image & image) QPixmap originalPixmap = _screen->grabWindow(0, _src_x, _src_y, _src_x_max, _src_y_max); QPixmap resizedPixmap = originalPixmap.scaled(_width,_height); QImage imageFrame = resizedPixmap.toImage().convertToFormat( QImage::Format_RGB888); + image.resize(imageFrame.width(), imageFrame.height()); for (int y=0; y> 1) + _horizontalDecimation - 1) / _horizontalDecimation; int outputHeight = (height - _cropTop - cropBottom - (_verticalDecimation >> 1) + _verticalDecimation - 1) / _verticalDecimation; - outputImage.resize(outputWidth, outputHeight); + + if (outputImage.width() != outputWidth || outputImage.height() != outputHeight) + outputImage.resize(outputWidth, outputHeight); for (int yDest = 0, ySource = _cropTop + (_verticalDecimation >> 1); yDest < outputHeight; ySource += _verticalDecimation, ++yDest) {