feat: Adding API's for copying/downloading an image
This commit is contained in:
parent
08a8c0cc98
commit
2bf1bfb30d
|
@ -88,6 +88,10 @@ DOS_API void dos_qapplication_clipboard_setText(const char* text);
|
|||
|
||||
DOS_API void dos_qapplication_installEventFilter(DosStatusEventObject *vptr);
|
||||
|
||||
DOS_API void dos_qapplication_clipboard_setImage(const char *text);
|
||||
|
||||
DOS_API void dos_qapplication_download_image(const char *imageSource, const char* filePath);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \defgroup QApplication QApplication
|
||||
|
|
|
@ -147,6 +147,30 @@ void dos_qapplication_clipboard_setText(const char* text)
|
|||
QApplication::clipboard()->setText(text);
|
||||
}
|
||||
|
||||
void dos_qapplication_clipboard_setImage(const char* text)
|
||||
{
|
||||
QByteArray btArray = QString(text).split("base64,")[1].toUtf8();
|
||||
QImage image;
|
||||
image.loadFromData(QByteArray::fromBase64(btArray));
|
||||
Q_ASSERT(!image.isNull());
|
||||
QApplication::clipboard()->setImage(image);
|
||||
}
|
||||
|
||||
void dos_qapplication_download_image(const char *imageSource, const char *filePath)
|
||||
{
|
||||
// Extract file path that can be used to save the image
|
||||
QString fileL = QString(filePath).replace(QRegExp("^(file:/{2})|(qrc:/{2})|(http:/{2})"), "");
|
||||
|
||||
// Get current Date/Time information to use in naming of the image file
|
||||
QString dateTimeString = QDateTime::currentDateTime().toString("dd-MM-yyyy_ hh-mm-ss");
|
||||
|
||||
// Extract the image data to be able to load and save into a QImage
|
||||
QByteArray btArray = QString(imageSource).split("base64,")[1].toUtf8();
|
||||
QImage image;
|
||||
image.loadFromData(QByteArray::fromBase64(btArray));
|
||||
image.save(QString(fileL) + "/image_" + dateTimeString + ".png");
|
||||
}
|
||||
|
||||
void dos_qguiapplication_delete()
|
||||
{
|
||||
delete qGuiApp;
|
||||
|
|
Loading…
Reference in New Issue