gpt4 book ai didi

c++ - Qt toBase64 和 Linux base64 的区别

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:41:04 29 4
gpt4 key购买 nike

主题。为什么可以呢?我已经尝试了 Qt toBase64 的所有标志,但没有任何改变。

bash :

cat Invader_1.png | base64

输出:

iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz AAALEwAACxMBAJqcGAAAA0JJREFUeJzt3MFt20AURdHnQIWoFLoSq5S4E7uSsBR24mxiIIsgSDIT cex3DjBLjT5J4ULcTAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAACcY0vyNmFt9x27yhbPaKovZw8AnEcAoJgAQDEBgGICAMUEAIoJABQTACgm AFBMAKCYAEAxAYBiAgDFBACKCQAUEwAodjl7gIUcSZ4n7fV18PNHkpfhKdZyS3Id3GPPnGd0TNgD fmnP+Ik1+51nvoc97styvAJAMQGAYgIAxQQAigkAFBMAKCYAUEwAoJgAQDEBgGICAMUEAIoJABQT ACgmAFBMAACSbBk/sML6GGsLSfwDgGoCAMUEAIoJABQTACgmAFBMAKCYAEAxAYBiAgDFBACKCQAU EwAoJgBQTACgmABAscvZA0xyS3Id3GP08+9ekxyDe1yTPA1PspaV7sst44eCHEleBvdgkj3nnzIz 87SZbYHrcF9+v/YJ13M6rwBQTACgmABAMQGAYgIAxQQAigkAFBMAKCYAUEwAoJgAQDEBgGICAMUE AIoJABQTACj2cPL3b0m+nTwDnOkxJx4u4h8AFBMAKCYAUEwAoJgAQDEBgGICAMUEAIoJABQTACgm AFBMAKCYAEAxAYBiAgDFBACKXc4eYJLXJMfgHtckT8OT8BH4vSxiS/I2YW0LzWKtv7aM2xaa5Z95 BYBiAgDFBACKCQAUEwAoJgBQTACgmABAMQGAYgIAxQQAigkAFBMAKCYAUEwAoJgAQDEBmO8xyYP1 X9bjXzwH/oAAQDEBgGICAMUEAIoJABQTACgmAFBMAKCYAEAxAYBiAgDFBACKCQAUEwAoJgBQTACg 2OXk7z+SPE/aZ8YeM2bZfqwVvGT83lyT3Ab3mGXP5/u9HBP2YCF7krdF1jbherYFruN97ROuh594 BYBiAgDFBACKCQAUEwAoJgBQTACgmABAMQGAYgIAxQQAigkAFBMAKCYAUEwAoJgAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAn3wG6mDu8 W58tNgAAAABJRU5ErkJggg==

Qt:

QImage image;
image.load("/home/undead/Pictures/1489180309_Invader_1.png");
image.save(&buffer, "PNG");
buffer.close();
bytes_array = bytes_array.toBase64();

输出:

iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAACXBIWXMAAAsTAAALEwEAmpwYAAADQklEQVR4nO3cwW3bQBRF0edAhagUuhKrlLgTu5KwFHbibGIgiyBIMhNx7HcOMEuNPknhQtxMAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJxjS_I2YW33HbvKFs9oqi9nDwCcRwCgmABAMQGAYgIAxQQAigkAFBMAKCYAUEwAoJgAQDEBgGICAMUEAIoJABQTACh2OXuAhRxJnift9XXw80eSl-Ep1nJLch3cY8-cZ3RM2AN-ac_4iTX7nWe-hz3uy3K8AkAxAYBiAgDFBACKCQAUEwAoJgBQTACgmABAMQGAYgIAxQQAigkAFBMAKCYAUEwAAJJsGT-wwvoYawtJ_AOAagIAxQQAigkAFBMAKCYAUEwAoJgAQDEBgGICAMUEAIoJABQTACgmAFBMAKCYAECxy9kDTHJLch3cY_Tz716THIN7XJM8DU-ylpXuyy3jh4IcSV4G92CSPeefMjPztJltgetwX36_9gnXczqvAFBMAKCYAEAxAYBiAgDFBACKCQAUEwAoJgBQTACgmABAMQGAYgIAxQQAigkAFBMAKPZw8vdvSb6dPAOc6TEnHi7iHwAUEwAoJgBQTACgmABAMQGAYgIAxQQAigkAFBMAKCYAUEwAoJgAQDEBgGICAMUEAIpdzh5gktckx-Ae1yRPw5PwEfi9LGJL8jZhbQvNYq2_tozbFprln3kFgGICAMUEAIoJABQTACgmAFBMAKCYAEAxAYBiAgDFBACKCQAUEwAoJgBQTACgmABAMQGY7zHJg_Vf1uNfPAf-gABAMQGAYgIAxQQAigkAFBMAKCYAUEwAoJgAQDEBgGICAMUEAIoJABQTACgmAFBMAKDY5eTvP5I8T9pnxh4zZtl-rBW8ZPzeXJPcBveYZc_n-70cE_ZgIXuSt0XWNuF6tgWu433tE66Hn3gFgGICAMUEAIoJABQTACgmAFBMAKCYAEAxAYBiAgDFBACKCQAUEwAoJgBQTACgmAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcCffAbqYO7xbny02AAAAAElFTkSuQmCC

最佳答案

您正在比较 2 个不同的事物。

cat Invader_1.png | base64

输出 Invader_1.png 的 base64 二进制内容。

同时

QImage image;
image.load("/home/undead/Pictures/1489180309_Invader_1.png");
image.save(&buffer, "PNG");
buffer.close();
bytes_array = bytes_array.toBase64();

1489180309_Invader_1.png 转换为像素图像并返回 PNG,然后输出新 PNG 的 base64 二进制内容。

正如@JustRufus 和@TobySpeight 所述,可以使用不同的设置(例如压缩级别)和/或导致不同二进制内容的元数据来创建同一图像的 PNG。

如果你想比较东西,你应该修复你的 Qt 代码以只读取文件:

QFile file("/home/undead/Pictures/1489180309_Invader_1.png");
file.open(QFile::ReadOnly);
QByteArray data = file.readAll();
file.close();
data = data.toBase64();

关于c++ - Qt toBase64 和 Linux base64 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42770140/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com