更新代码

This commit is contained in:
feiyangqingyun
2021-08-12 11:20:10 +08:00
parent 5c8e032955
commit 0705ee10a3
14 changed files with 80 additions and 2 deletions

41
core_common/base64.cpp Normal file
View File

@@ -0,0 +1,41 @@
#include "base64.h"
#include "qbuffer.h"
#include "qdebug.h"
QString Base64::imageToBase64(const QImage &image)
{
return QString(imageToBase64x(image));
}
QByteArray Base64::imageToBase64x(const QImage &image)
{
//这个转换可能比较耗时建议在线程中执行
QByteArray data;
QBuffer buffer(&data);
image.save(&buffer, "JPG");
data = data.toBase64();
return data;
}
QImage Base64::base64ToImage(const QString &data)
{
return base64ToImagex(data.toUtf8());
}
QImage Base64::base64ToImagex(const QByteArray &data)
{
//这个转换可能比较耗时建议在线程中执行
QImage image;
image.loadFromData(QByteArray::fromBase64(data));
return image;
}
QString Base64::textToBase64(const QString &text)
{
return QString(text.toLocal8Bit().toBase64());
}
QString Base64::base64ToText(const QString &text)
{
return QString(QByteArray::fromBase64(text.toLocal8Bit()));
}

37
core_common/base64.h Normal file
View File

@@ -0,0 +1,37 @@
#ifndef BASE64_H
#define BASE64_H
/**
* base64编码转换类 作者:feiyangqingyun(QQ:517216493) 2016-12-16
* 1. 图片转base64字符串
* 2. base64字符串转图片
* 3. 字符转base64字符串
* 4. base64字符串转字符
* 5. 后期增加数据压缩
* 6. Qt6对base64编码转换进行了重写效率提升至少200%
*/
#include <QImage>
#ifdef quc
class Q_DECL_EXPORT Base64
#else
class Base64
#endif
{
public:
//图片转base64字符串
static QString imageToBase64(const QImage &image);
static QByteArray imageToBase64x(const QImage &image);
//base64字符串转图片
static QImage base64ToImage(const QString &data);
static QImage base64ToImagex(const QByteArray &data);
//字符串与base64互转
static QString textToBase64(const QString &text);
static QString base64ToText(const QString &text);
};
#endif // BASE64_H

View File

@@ -22,11 +22,13 @@ include ($$PWD/h3.pri)
HEADERS += \
$$PWD/appinit.h \
$$PWD/base64.h \
$$PWD/iconhelper.h \
$$PWD/quihelper.h
SOURCES += \
$$PWD/appinit.cpp \
$$PWD/base64.cpp \
$$PWD/iconhelper.cpp \
$$PWD/quihelper.cpp

View File

@@ -171,10 +171,8 @@ void QUIHelper::setFont(int fontSize)
#endif
#ifndef rk3399
#if (QT_VERSION < QT_VERSION_CHECK(6,0,0))
qApp->setFont(font);
#endif
#endif
}
void QUIHelper::setCode(bool utf8)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 KiB

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 94 KiB