mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 03:40:20 +02:00
Update TextureCache to store original image dimensions (pre-scale)
This commit is contained in:
parent
4c10f6f23b
commit
1f6932bdcb
2 changed files with 13 additions and 3 deletions
|
@ -459,6 +459,9 @@ void ImageReader::run() {
|
||||||
_reply->deleteLater();
|
_reply->deleteLater();
|
||||||
}
|
}
|
||||||
QImage image = QImage::fromData(_content);
|
QImage image = QImage::fromData(_content);
|
||||||
|
|
||||||
|
int originalWidth = image.width();
|
||||||
|
int originalHeight = image.height();
|
||||||
|
|
||||||
// enforce a fixed maximum
|
// enforce a fixed maximum
|
||||||
const int MAXIMUM_SIZE = 1024;
|
const int MAXIMUM_SIZE = 1024;
|
||||||
|
@ -519,7 +522,8 @@ void ImageReader::run() {
|
||||||
}
|
}
|
||||||
QMetaObject::invokeMethod(texture.data(), "setImage", Q_ARG(const QImage&, image),
|
QMetaObject::invokeMethod(texture.data(), "setImage", Q_ARG(const QImage&, image),
|
||||||
Q_ARG(bool, translucentPixels >= imageArea / 2), Q_ARG(const QColor&, QColor(redTotal / imageArea,
|
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) {
|
void NetworkTexture::downloadFinished(QNetworkReply* reply) {
|
||||||
|
@ -531,9 +535,11 @@ void NetworkTexture::loadContent(const QByteArray& content) {
|
||||||
QThreadPool::globalInstance()->start(new ImageReader(_self, NULL, _url, 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;
|
_translucent = translucent;
|
||||||
_averageColor = averageColor;
|
_averageColor = averageColor;
|
||||||
|
_originalWidth = originalWidth;
|
||||||
|
_originalHeight = originalHeight;
|
||||||
_width = image.width();
|
_width = image.width();
|
||||||
_height = image.height();
|
_height = image.height();
|
||||||
|
|
||||||
|
|
|
@ -150,6 +150,8 @@ public:
|
||||||
/// Returns the lazily-computed average texture color.
|
/// Returns the lazily-computed average texture color.
|
||||||
const QColor& getAverageColor() const { return _averageColor; }
|
const QColor& getAverageColor() const { return _averageColor; }
|
||||||
|
|
||||||
|
int getOriginalWidth() const { return _originalWidth; }
|
||||||
|
int getOriginalHeight() const { return _originalHeight; }
|
||||||
int getWidth() const { return _width; }
|
int getWidth() const { return _width; }
|
||||||
int getHeight() const { return _height; }
|
int getHeight() const { return _height; }
|
||||||
|
|
||||||
|
@ -158,7 +160,7 @@ protected:
|
||||||
virtual void downloadFinished(QNetworkReply* reply);
|
virtual void downloadFinished(QNetworkReply* reply);
|
||||||
|
|
||||||
Q_INVOKABLE void loadContent(const QByteArray& content);
|
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);
|
virtual void imageLoaded(const QImage& image);
|
||||||
|
|
||||||
|
@ -166,6 +168,8 @@ private:
|
||||||
TextureType _type;
|
TextureType _type;
|
||||||
bool _translucent;
|
bool _translucent;
|
||||||
QColor _averageColor;
|
QColor _averageColor;
|
||||||
|
int _originalWidth;
|
||||||
|
int _originalHeight;
|
||||||
int _width;
|
int _width;
|
||||||
int _height;
|
int _height;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue