QImage和QPixmap有什么区别? [英] What is the difference between QImage and QPixmap?
问题描述
我不明白QImage和QPixmap之间的区别,它们似乎提供相同的功能。我应该在什么时候使用QImage和何时使用QPixmap?
I do not understand what is the difference between QImage and QPixmap, they seem to offer the same functionality. When should I use a QImage and when should I use a QPixmap?
推荐答案
Easilly通过阅读 QImage 和 QPixmap :
Easilly answered by reading the docs on QImage and QPixmap:
QPixmap 类是
The QPixmap class is an off-screen image representation that can be used as a paint device.
QImage 类提供与硬件无关的图像
The QImage class provides a hardware-independent image representation that allows direct access to the pixel data, and can be used as a paint device.
编辑:允许直接访问像素数据, >另外,从@ Dave的回答:
Also, from @Dave's answer:
你不能在GUI线程之外操作QPixmap,但QImage没有这样的限制。
You can't manipulate a QPixmap outside the GUI-thread, but QImage has no such restriction.
并从@Arnold:
以下是一个通常(并不总是)适用的简短摘要:
Here's a short summary that usually (not always) applies:
- 如果您打算操作图片,修改图片,
等,使用QImage。 - 如果您计划在屏幕上多次绘制相同的图像
,请将其转换为QPixmap。
这篇关于QImage和QPixmap有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!