QImage和QPixmap有什么区别? [英] What is the difference between QImage and QPixmap?

查看:1500
本文介绍了QImage和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屋!

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