問題描述
我不明白 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?
推薦答案
通過閱讀 QImage 和 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 有什么區別?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!