Switch readImage to take a reference instead of a pointer
There was nowhere that an actual pointer was passed, and I wanted to do references for something else.
This commit is contained in:
parent
8b33b1f08b
commit
fda6d7629a
@ -35,7 +35,7 @@ resolve(const QString &avatarUrl, int size, QObject *receiver, AvatarCallback ca
|
|||||||
|
|
||||||
auto data = cache::image(cacheKey);
|
auto data = cache::image(cacheKey);
|
||||||
if (!data.isNull()) {
|
if (!data.isNull()) {
|
||||||
pixmap = QPixmap::fromImage(utils::readImage(&data));
|
pixmap = QPixmap::fromImage(utils::readImage(data));
|
||||||
avatar_cache.insert(cacheKey, pixmap);
|
avatar_cache.insert(cacheKey, pixmap);
|
||||||
callback(pixmap);
|
callback(pixmap);
|
||||||
return;
|
return;
|
||||||
@ -46,7 +46,7 @@ resolve(const QString &avatarUrl, int size, QObject *receiver, AvatarCallback ca
|
|||||||
&AvatarProxy::avatarDownloaded,
|
&AvatarProxy::avatarDownloaded,
|
||||||
receiver,
|
receiver,
|
||||||
[callback, cacheKey](QByteArray data) {
|
[callback, cacheKey](QByteArray data) {
|
||||||
QPixmap pm = QPixmap::fromImage(utils::readImage(&data));
|
QPixmap pm = QPixmap::fromImage(utils::readImage(data));
|
||||||
avatar_cache.insert(cacheKey, pm);
|
avatar_cache.insert(cacheKey, pm);
|
||||||
callback(pm);
|
callback(pm);
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,7 @@ MxcImageResponse::run()
|
|||||||
|
|
||||||
auto data = cache::image(fileName);
|
auto data = cache::image(fileName);
|
||||||
if (!data.isNull()) {
|
if (!data.isNull()) {
|
||||||
m_image = utils::readImage(&data);
|
m_image = utils::readImage(data);
|
||||||
|
|
||||||
if (!m_image.isNull()) {
|
if (!m_image.isNull()) {
|
||||||
m_image = m_image.scaled(
|
m_image = m_image.scaled(
|
||||||
@ -54,7 +54,7 @@ MxcImageResponse::run()
|
|||||||
|
|
||||||
auto data = QByteArray(res.data(), (int)res.size());
|
auto data = QByteArray(res.data(), (int)res.size());
|
||||||
cache::saveImage(fileName, data);
|
cache::saveImage(fileName, data);
|
||||||
m_image = utils::readImage(&data);
|
m_image = utils::readImage(data);
|
||||||
if (!m_image.isNull()) {
|
if (!m_image.isNull()) {
|
||||||
m_image = m_image.scaled(
|
m_image = m_image.scaled(
|
||||||
m_requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
m_requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
@ -67,7 +67,7 @@ MxcImageResponse::run()
|
|||||||
auto data = cache::image(m_id);
|
auto data = cache::image(m_id);
|
||||||
|
|
||||||
if (!data.isNull()) {
|
if (!data.isNull()) {
|
||||||
m_image = utils::readImage(&data);
|
m_image = utils::readImage(data);
|
||||||
m_image.setText("mxc url", "mxc://" + m_id);
|
m_image.setText("mxc url", "mxc://" + m_id);
|
||||||
|
|
||||||
if (!m_image.isNull()) {
|
if (!m_image.isNull()) {
|
||||||
@ -98,7 +98,7 @@ MxcImageResponse::run()
|
|||||||
|
|
||||||
auto data = QByteArray(temp.data(), (int)temp.size());
|
auto data = QByteArray(temp.data(), (int)temp.size());
|
||||||
cache::saveImage(m_id, data);
|
cache::saveImage(m_id, data);
|
||||||
m_image = utils::readImage(&data);
|
m_image = utils::readImage(data);
|
||||||
m_image.setText("original filename",
|
m_image.setText("original filename",
|
||||||
QString::fromStdString(originalFilename));
|
QString::fromStdString(originalFilename));
|
||||||
m_image.setText("mxc url", "mxc://" + m_id);
|
m_image.setText("mxc url", "mxc://" + m_id);
|
||||||
|
@ -689,10 +689,10 @@ utils::restoreCombobox(QComboBox *combo, const QString &value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QImage
|
QImage
|
||||||
utils::readImage(const QByteArray *data)
|
utils::readImage(const QByteArray &data)
|
||||||
{
|
{
|
||||||
QBuffer buf;
|
QBuffer buf;
|
||||||
buf.setData(*data);
|
buf.setData(data);
|
||||||
QImageReader reader(&buf);
|
QImageReader reader(&buf);
|
||||||
reader.setAutoTransform(true);
|
reader.setAutoTransform(true);
|
||||||
return reader.read();
|
return reader.read();
|
||||||
|
@ -309,7 +309,7 @@ restoreCombobox(QComboBox *combo, const QString &value);
|
|||||||
|
|
||||||
//! Read image respecting exif orientation
|
//! Read image respecting exif orientation
|
||||||
QImage
|
QImage
|
||||||
readImage(const QByteArray *data);
|
readImage(const QByteArray &data);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isReply(const mtx::events::collections::TimelineEvents &e);
|
isReply(const mtx::events::collections::TimelineEvents &e);
|
||||||
|
@ -574,7 +574,7 @@ InputBar::showPreview(const QMimeData &source, QString path, const QStringList &
|
|||||||
auto mimeClass = mime.split("/")[0];
|
auto mimeClass = mime.split("/")[0];
|
||||||
nhlog::ui()->debug("Mime: {}", mime.toStdString());
|
nhlog::ui()->debug("Mime: {}", mime.toStdString());
|
||||||
if (mimeClass == "image") {
|
if (mimeClass == "image") {
|
||||||
QImage img = utils::readImage(&data);
|
QImage img = utils::readImage(data);
|
||||||
|
|
||||||
dimensions = img.size();
|
dimensions = img.size();
|
||||||
if (img.height() > 200 && img.width() > 360)
|
if (img.height() > 200 && img.width() > 360)
|
||||||
|
Loading…
Reference in New Issue
Block a user