Qt提供四个类来处理图像数据:QImage、QPixmap、QBitmap和QPicture。
(1)QImage:针对I/O和直接像素访问和操作进行设计和优化的类。
(2)QPixmap:针对屏幕上显示的图像进行设计和优化的类。
(3)QBitmap:一个继承自QPixmap的便捷类,确保深度为1。
(4)QPicture:该类是一个绘画设备,可以记录和回放QPainter命令。
大概是说QPixmap主要用于显示,而QImage则是图像的物理存储信息。
接下来我们要对QImage进行像素级的图片读写,可用的函数很多
QImage(const QSize &size, Format format);
QImage(int width, int height, Format format);
QImage(uchar *data, int width, int height, Format format, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr);
QImage(const uchar *data, int width, int height, Format format, QImageCleanupFunction cleanupFunction = nullptr, void *cleanupInfo = nullptr);
QImage(uchar *data, int width, int height, int bytesPerLine, Format format, QImageCleanupFunction cleanupFunction = nullptr, void *cl