-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGifView.h
63 lines (60 loc) · 1.37 KB
/
GifView.h
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
///
/// (C) 2019 CHIV
///
///
#pragma once
// CGifView
#include <mutex>
#include <thread>
class CGifView : public CStatic
{
DECLARE_DYNAMIC(CGifView)
public:
CGifView();
virtual ~CGifView();
//
enum PlayerStatus {
ePlaying,
ePaused,
eStopped
};
PlayerStatus GetPlayerStatus() const { return mCurrentStatus; }
//
bool Load(const CString& filename);
void Play();
void Stop();
void Pause();
void SetAutoScale(bool auto_scale)
{
mAutoScale = auto_scale;
}
void SetBackgroundColor(const COLORREF& background_color)
{
mBackgroundColor = background_color;
}
//
private:
PlayerStatus mCurrentStatus;
int mCurrentFrameIdx;
bool mAutoScale;
COLORREF mBackgroundColor;
struct Frame;
std::mutex mMutex; // protect current frame, cache, .etc
std::thread mThread; // decode thread.
volatile bool mShouldStop; // flag to exit the thread.
void* mGifFile; // GIF FILE HANDLE.
CDC mMemDc;
void* mMemDcBuffer;
//
CBitmap* mCanvas;
CBitmap* mOldCanvas;
void BuildMemDc(int sx, int sy);
void ReleaseMemDc();
//
void RenderToMemDc(const Frame& frame);
//
protected:
DECLARE_MESSAGE_MAP()
afx_msg void OnDestroy();
afx_msg void OnPaint();
};