mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-22 04:21:44 +00:00
feat: resize images
This commit is contained in:
parent
2dfb92a160
commit
d613014606
@ -105,6 +105,8 @@ DOS_API DosQNetworkConfigurationManager *DOS_CALL dos_qncm_create();
|
||||
|
||||
DOS_API void DOS_CALL dos_qncm_delete(DosQNetworkConfigurationManager *vptr);
|
||||
|
||||
DOS_API char * DOS_CALL dos_image_resizer(char* imagePath, int maxSize);
|
||||
|
||||
/// \brief Sets the application icon
|
||||
DOS_API void DOS_CALL dos_qapplication_icon(const char *filename);
|
||||
|
||||
|
25
vendor/DOtherSide/lib/src/DOtherSide.cpp
vendored
25
vendor/DOtherSide/lib/src/DOtherSide.cpp
vendored
@ -32,6 +32,11 @@
|
||||
#include <QtQml/QQmlContext>
|
||||
#include <QtCore>
|
||||
#include <QClipboard>
|
||||
#include <QtGui/QPixmap>
|
||||
#include <QtGui/QImage>
|
||||
#include <QtGui/QColorSpace>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QUuid>
|
||||
#include <QtQml/QQmlApplicationEngine>
|
||||
#include <QtQuick/QQuickView>
|
||||
#include <QtQuick/QQuickImageProvider>
|
||||
@ -1113,3 +1118,23 @@ void dos_qncm_delete(::DosQNetworkConfigurationManager *vptr)
|
||||
}
|
||||
|
||||
#include "DOtherSide.moc"
|
||||
|
||||
char *dos_image_resizer(char* imagePath, int maxSize)
|
||||
{
|
||||
QImage img(imagePath);
|
||||
img.setColorSpace(QColorSpace::SRgb);
|
||||
int w = img.width();
|
||||
int h = img.height();
|
||||
|
||||
QPixmap pixmap;
|
||||
pixmap = pixmap.fromImage(img.scaled(maxSize < w ? maxSize : w, maxSize < h ? maxSize : h, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
|
||||
auto newFilePath = QDir::tempPath() + "/" + QUuid::createUuid().toString() + ".jpg";
|
||||
|
||||
QFile file(newFilePath);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
pixmap.save(&file, "jpeg", 75);
|
||||
file.close();
|
||||
|
||||
return convert_to_cstring(newFilePath.toUtf8());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user