减小 QPixmap 的文件大小
当我使用scaledToHeight调整QPixmap的大小然后将其转换为QByteArray时,该ByteArray的大小恰好是未缩放的QPixmap的ByteArray的大小。是否有可能缩小 QPixmap 的像素大小和文件大小?
此致
when i resize a QPixmap with scaledToHeight and then transform it to an QByteArray, the size of this ByteArray is exactly the size of ByteArray from the unscaled QPixmap. Is there a possibility to shrink QPixmap in pixel-size and file-size?
Best regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个概念验证,表明您正在做的事情肯定是可能的。也许你可以看到你在做什么不同?
两种猜测:
scaledToHeight
返回原始图像的缩放副本。它不直接缩放像素图实例。QByteArray
,您可能必须先截断它,然后才能看到大小差异。也就是说,即使实际内容小得多,QByteArray的容量仍可能保持较大。Here is a proof-of-concept that shows that what you are doing is certainly possible. Maybe you can see what you are doing different?
Two guesses:
scaledToHeight
returns a scaled copy of the original image. It does not scale the pixmap instance directly.QByteArray
, you may have to truncate it before seeing the difference in size. That is, the capacity of the QByteArray may remain larger even through the actual content is much smaller.