1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include <queue>
#include <mutex>
#include <condition_variable>
#include <thread>
#include <atomic>
#include <vector>
#include <string>
#include <Windows.h>
 
struct SaveImgJob
{
    std::string        strPath;
    std::vector<BYTE>  vData;
    int                nWidth = 0;
    int                nHeight = 0;
    int                nStride = 0;
    int                nBpp = 1;
    int                nStartY = 0;
    int                nDimension = 0;
    int                nQuality = 80;
};
 
class CThread_SaveFullImg
{
public:
    CThread_SaveFullImg();
    ~CThread_SaveFullImg();
 
    void CreateThread();
    void StopThread();
    void Enqueue(SaveImgJob&& oJob);
    size_t GetPendingCount() const;
 
private:
    void ThreadProc();
    BOOL SaveFullImageModern(const SaveImgJob& job);
 
private:
    mutable std::mutex              m_Mtx;
    std::condition_variable         m_Cv;
    std::queue<SaveImgJob>          m_Q;
    std::thread                     m_Thread;
    std::atomic<bool>               m_bStop;
};