Commit c4c279fe authored by scuq's avatar scuq

image scaling instead of cropping again

parent 18f11b32
Pipeline #397 failed with stage
in 2 minutes and 22 seconds
......@@ -640,14 +640,21 @@ void dialogChat::insertChatImageSkeleton(QMap<QString, QVariant> imageProperties
int _scaledWidth;
int _scaledHeight;
if ( this->ui->textBrowserChatOutput->width() < imageProperties["width"].toInt() ) {
_scaledWidth = qCeil(this->ui->textBrowserChatOutput->width() * 0.4);
_scaledHeight = qCeil(_scaledWidth / aspectRatio);
QImage _image(QSize( imageProperties["width"].toInt(),imageProperties["height"].toInt()),QImage::Format_RGB32);
QImage scaled = _image.scaledToWidth(_scaledWidth,Qt::SmoothTransformation);
_scaledWidth = scaled.width();
_scaledHeight = scaled.height();
} else {
_scaledWidth = imageProperties["width"].toInt();
_scaledHeight = imageProperties["height"].toInt();
}
qDebug() << QString("%1: scaling image with %2 from %3x%4 to %5x%6").arg( this->metaObject()->className(),
QString::number(aspectRatio),
imageProperties["width"].toString(),
......@@ -660,6 +667,7 @@ void dialogChat::insertChatImageSkeleton(QMap<QString, QVariant> imageProperties
QPainter paint;
paint.setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing);
paint.begin(&image);
......@@ -733,10 +741,10 @@ void dialogChat::slUpdateFromDownloadedFile(const QString &fileid, QByteArray fi
_scaledHeight = image.height();
}
//QImage scaled = image.scaled(_scaledWidth,_scaledHeight);
QImage scaled = image.scaledToWidth(_scaledWidth,Qt::SmoothTransformation);
QRect rect(0, 0, _scaledWidth, _scaledHeight);
QImage scaled = image.copy(rect);
//QRect rect(0, 0, _scaledWidth, _scaledHeight);
//QImage scaled = image.copy(rect);
......
......@@ -307,9 +307,7 @@ bool ImSession::newChannelPost(QString channelid, QString message)
bool ImSession::uploadFile(QString channelid, QString filename, QByteArray content)
{
QUrl url ( this->m_account->getServer() + QString("/api/v4/files") );
// QString boundary = QString("---------------------------%1_%2").arg(channelid,filename);
QNetworkRequest req ( url );
......@@ -329,14 +327,6 @@ bool ImSession::uploadFile(QString channelid, QString filename, QByteArray conte
contentbuffer->open(QIODevice::ReadOnly);
//QFile *file = new QFile("c:/aic_alt.png");
//file->open(QIODevice::ReadOnly);
filePart.setBodyDevice(contentbuffer);
contentbuffer->setParent(multiPart); // we cannot delete the file now, so delete it with the multiPart
......@@ -344,20 +334,15 @@ bool ImSession::uploadFile(QString channelid, QString filename, QByteArray conte
multiPart->append(filePart);
// req.setRawHeader("Content-Type", "multipart/form-data");
// req.setRawHeader("X-Requested-With", "XMLHttpRequest");
req.setRawHeader("Authorization", "Bearer "+this->getAuthtoken().toUtf8());
qDebug() << QString("Uploading file %1 to %2 for channel %3").arg(filename, url.toString(), channelid);
qDebug() << QString("Uploading file %1 to %2 for channel %3").arg(filename, url.toString(), channelid);
QNetworkReply *reply = m_WebCtrlProgress.post(req,multiPart);
multiPart->setParent(reply);
netReplies[reply] = QString("mmapi::uploadFile__%1").arg( channelid );
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment