From 875b625abb7ef86e21dcf34069e39591b8a7c91e Mon Sep 17 00:00:00 2001 From: Angela Mazzurco Date: Tue, 18 Jul 2017 18:09:35 +0200 Subject: [PATCH] Scale image before base64 encoding --- retroshare-qml-app/src/androidimagepicker.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/retroshare-qml-app/src/androidimagepicker.h b/retroshare-qml-app/src/androidimagepicker.h index 0b486eb34..b30c6c18c 100644 --- a/retroshare-qml-app/src/androidimagepicker.h +++ b/retroshare-qml-app/src/androidimagepicker.h @@ -9,6 +9,7 @@ #include #include + #ifdef __ANDROID__ # include # include @@ -39,21 +40,25 @@ public slots: QUrl url (path); QString localPath = url.toLocalFile(); + qDebug() << "imageToBase64() local path:" << localPath ; + // Read the image QImageReader reader; reader.setFileName(localPath); QImage image = reader.read(); + image = image.scaled(96,96,Qt::KeepAspectRatio,Qt::SmoothTransformation); + // Transform image into PNG format QByteArray ba; QBuffer buffer( &ba ); buffer.open( QIODevice::WriteOnly ); - image.save( &buffer, "PNG" ); + image.save( &buffer, "png" ); // Get Based 64 image string QString encoded = QString(ba.toBase64()); - qDebug() << "imageToBase64() " ; + qDebug() << "imageToBase64() " << encoded ; return encoded;