CameraGrabber/savetask.h

43 lines
1.2 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef SAVETASK_H
#define SAVETASK_H
#include <QByteArray>
#include <QDateTime>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QRunnable>
/**
* @brief SaveTask 封装了将原始图像字节数据异步保存到文件的任务。
* 继承自 QRunnable以便提交给 QThreadPool 运行。
*/
class SaveTask : public QRunnable
{
public:
/**
* @brief 构造函数。接收需要保存的原始图像数据的副本及元数据。
* @param data 原始图像数据的字节副本。
* @param width 图像宽度。
* @param height 图像高度。
* @param pixelType 图像的原始像素格式(例如 PvPixelMono8 的整数值)。
*/
SaveTask(const QByteArray &data, const QString &camName)
: m_rawData(data), m_camName(camName) // <<< 增加 camName 的初始化
{
// 设置为 true以便任务执行完成后QThreadPool 自动清理内存
setAutoDelete(true);
}
/**
* @brief 任务的实际执行入口,将在一个线程池线程中运行。
*/
void run() override;
private:
QByteArray m_rawData;
QString m_camName; // <<< 增加成员变量来存储相机名称
};
#endif // SAVETASK_H