QImage/QPixmap 大小限制? [英] QImage/QPixmap size limitations?

查看:89
本文介绍了QImage/QPixmap 大小限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否记录了 QPixmap 和/或 QImage 对象的任何已知大小/空间限制?我没有找到任何关于此的有用信息.我目前在 OSX 和 Windows 上使用 Qt 4.7.3.我特别感兴趣:

Are there any known size/space limitation of QPixmap and/or QImage objects documented? I did not find any useful information regarding this. I'm currently using Qt 4.7.3 on OSX and Windows. Particulary I'm interested in:

  • 宽度/高度限制?
  • 限制取决于颜色格式?
  • 32/64 位机器之间的区别?
  • 关于操作系统的差异?

我天真地怀疑内存是唯一的限制,因此可以通过

I would naively suspect that memory is the only limitation, so one could calculate max size by

宽 x 高 x byte_per_pixel

width x height x byte_per_pixel

我认为有更详细的经验法则;当您遇到 GB 维度时,32 位机器也可能存在寻址问题.

I assume that there is a more elaborate rule of thumb; also 32 bit machines may have addressing problems when you run into GB dimensions.

最后,我想存储多个大小约为 16000x16000 像素的 RGBA 图像,并在 QGraphicsScene 中使用透明度相互渲染它们.可用的工作站可以有很多 RAM,比如 16GB.

In the end I want to store multiple RGBA images of about 16000x16000 pixel in size and render them using transparency onto each other within a QGraphicsScene. The workstation available can have a lot of RAM, let's say 16GB.

tl;dr:您知道 QImage/QPixmap 的大小限制是多少,或者我在哪里可以找到此类信息?

我知道平铺方法,我对此很满意.了解上述内容还是很棒的.

I'm aware of the tiling approach and I'm fine with that. Still it would be great to know the things described above.

谢谢!

推荐答案

两者都限制为 32767x32767 像素.也就是说,您可以将它们视为 X 和 Y 分辨率都使用有符号的 16 位值.

Both are limited to 32767x32767 pixels. That is, you can think of them as using a signed 16-bit value for both the X and Y resolution.

没有一个轴可以超过 32767 像素,即使另一个轴只有 1 个像素.操作系统位数"不影响限制.在创建如此巨大的图像之前,底层系统可能会遇到其他限制,例如您提到的内存限制.

No axis can ever exceed 32767 pixels, even if the other axis is only 1 pixel. Operating system "bitness" does not affect the limitation. The underlying system may run into other limits, such as memory as you mentioned, before such a huge image can be created.

您可以在以下源代码中看到此限制的示例:http://git.zx2c4.com/qt/plain/src/gui/image/qpixmap_x11.cpp

You can see an example of this limitation in the following source code: http://git.zx2c4.com/qt/plain/src/gui/image/qpixmap_x11.cpp

if (uint(w) >= 32768 || uint(h) >= 32768) {
    w = h = 0;
    is_null = true;
    return;
}

这篇关于QImage/QPixmap 大小限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆