mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-27 00:15:51 -04:00
Encode base64 via c++ code
This commit is contained in:
parent
404469b0a7
commit
75180f2a01
2 changed files with 101 additions and 38 deletions
|
@ -9,6 +9,8 @@
|
|||
#include <QImageReader>
|
||||
#include <QBuffer>
|
||||
|
||||
#include "qpainter.h"
|
||||
|
||||
|
||||
#ifdef __ANDROID__
|
||||
# include <QtAndroid>
|
||||
|
@ -60,7 +62,65 @@ public slots:
|
|||
|
||||
qDebug() << "imageToBase64() encoded" ;
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
static QString faceImage (QVariantList onloads, int size)
|
||||
{
|
||||
QImage result(size, size, QImage::Format_ARGB32_Premultiplied);
|
||||
QPainter painter(&result);
|
||||
|
||||
|
||||
int counter = 0;
|
||||
for (QVariantList::iterator j = onloads.begin(); j != onloads.end(); j++)
|
||||
{
|
||||
QString path = (*j).toString();
|
||||
QImageReader reader;
|
||||
reader.setFileName(path);
|
||||
QImage image = reader.read();
|
||||
painter.drawImage(0, 0, image); // xi, yi is the position for imagei
|
||||
// if (counter == 0)
|
||||
// {
|
||||
// base = QImage(bg.size(), QImage::Format_ARGB32_Premultiplied);
|
||||
// qDebug() << "FIIIRST ";
|
||||
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
// }
|
||||
qDebug() << "iterating through QVariantList ";
|
||||
qDebug() << (*j).toString(); // Print QVariant
|
||||
counter++;
|
||||
}
|
||||
painter.end();
|
||||
|
||||
// Transform image into PNG format
|
||||
QByteArray ba;
|
||||
QBuffer buffer( &ba );
|
||||
buffer.open( QIODevice::WriteOnly );
|
||||
result.save( &buffer, "png" );
|
||||
|
||||
// Get Based 64 image string
|
||||
QString encoded = QString(ba.toBase64());
|
||||
|
||||
qDebug() << "@@@@@ encoded avatar " << encoded ;
|
||||
|
||||
return encoded;
|
||||
|
||||
}
|
||||
|
||||
QImage getImageFromPath (QString localPath)
|
||||
{
|
||||
qDebug() << "getImageFromPath() local path:" << localPath ;
|
||||
|
||||
// Read the image
|
||||
QImageReader reader;
|
||||
reader.setFileName(localPath);
|
||||
QImage image = reader.read();
|
||||
return image;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue