diff --git a/libraries/render-utils/src/TextureCache.cpp b/libraries/render-utils/src/TextureCache.cpp index 4c9abc74a1..58032a0916 100644 --- a/libraries/render-utils/src/TextureCache.cpp +++ b/libraries/render-utils/src/TextureCache.cpp @@ -459,6 +459,9 @@ void ImageReader::run() { _reply->deleteLater(); } QImage image = QImage::fromData(_content); + + int originalWidth = image.width(); + int originalHeight = image.height(); // enforce a fixed maximum const int MAXIMUM_SIZE = 1024; @@ -519,7 +522,8 @@ void ImageReader::run() { } QMetaObject::invokeMethod(texture.data(), "setImage", Q_ARG(const QImage&, image), Q_ARG(bool, translucentPixels >= imageArea / 2), Q_ARG(const QColor&, QColor(redTotal / imageArea, - greenTotal / imageArea, blueTotal / imageArea, alphaTotal / imageArea))); + greenTotal / imageArea, blueTotal / imageArea, alphaTotal / imageArea)), + Q_ARG(int, originalWidth), Q_ARG(int, originalHeight)); } void NetworkTexture::downloadFinished(QNetworkReply* reply) { @@ -531,9 +535,11 @@ void NetworkTexture::loadContent(const QByteArray& content) { QThreadPool::globalInstance()->start(new ImageReader(_self, NULL, _url, content)); } -void NetworkTexture::setImage(const QImage& image, bool translucent, const QColor& averageColor) { +void NetworkTexture::setImage(const QImage& image, bool translucent, const QColor& averageColor, int originalWidth, int originalHeight) { _translucent = translucent; _averageColor = averageColor; + _originalWidth = originalWidth; + _originalHeight = originalHeight; _width = image.width(); _height = image.height(); diff --git a/libraries/render-utils/src/TextureCache.h b/libraries/render-utils/src/TextureCache.h index efcccc4b8c..6d115223a2 100644 --- a/libraries/render-utils/src/TextureCache.h +++ b/libraries/render-utils/src/TextureCache.h @@ -150,6 +150,8 @@ public: /// Returns the lazily-computed average texture color. const QColor& getAverageColor() const { return _averageColor; } + int getOriginalWidth() const { return _originalWidth; } + int getOriginalHeight() const { return _originalHeight; } int getWidth() const { return _width; } int getHeight() const { return _height; } @@ -158,7 +160,7 @@ protected: virtual void downloadFinished(QNetworkReply* reply); Q_INVOKABLE void loadContent(const QByteArray& content); - Q_INVOKABLE void setImage(const QImage& image, bool translucent, const QColor& averageColor); + Q_INVOKABLE void setImage(const QImage& image, bool translucent, const QColor& averageColor, int originalWidth, int originalHeight); virtual void imageLoaded(const QImage& image); @@ -166,6 +168,8 @@ private: TextureType _type; bool _translucent; QColor _averageColor; + int _originalWidth; + int _originalHeight; int _width; int _height; };