做完base64后,发现总是报错image format error
发现:https://developer.baidu.com/forum/topic/show/244140
Qt中需要稍微转换一下
QByteArray toBase64(QString imgPath) {
QImage image(imgPath);
QByteArray ba;
QBuffer buf(&ba);
image.save(&buf, "png");
QByteArray hexed = ba.toBase64();
buf.close();
return hexed;
}
toBase64(imgPath).toPercentEncoding()
核心是toPercentEncoding