[go: up one dir, main page]

Menu

[184078]: / src / ImgViewer.h  Maximize  Restore  History

Download this file

99 lines (82 with data), 2.4 kB

 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* @file ImgViewer.h
* @brief 图像显示界面
* @version 1.0
* @date 2020-04-14
*/
#ifndef IMGVIEWER_H
#define IMGVIEWER_H
#include <QWidget>
#include <QThread>
#include <QString>
#include <QImage>
#include <QPainter>
#include <QCloseEvent>
#include <QPaintEvent>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QResizeEvent>
#include "TTFdecoder.h"
namespace Ui {
class ImgViewerWindow;
}
class TTFDecodeThread : public QThread
{
Q_OBJECT
public:
explicit TTFDecodeThread(QWidget *parent = nullptr,
QString ttffilename = nullptr,
QString TTFFormat = nullptr,
int W = 0, int H = 0, int codepoint = 0);
protected:
void run();
signals:
void finsh_signal(QList<SvgInfo> frame_RGB_list,QString str);
private:
QWidget *window;
QString ttffilename;
int W;
int H;
int codepoint;
ttfdecoder_t decoder;
};
class ImgViewer : public QWidget
{
Q_OBJECT
public:
explicit ImgViewer(QWidget *parent = nullptr,QWidget *parentWindow = nullptr);
~ImgViewer();
bool setFileList(QStringList filelist,QString TTFFormat, int W, int H, int codepoint);
bool setFileList_multithreading(QStringList filenamelist, QString TTFFormat, int W, int H, int codepoint);
private slots:
void reciveimgdata(QList<SvgInfo> img_RGB_list, QString filename);
void previousImg();
void nextImg();
protected:
void closeEvent(QCloseEvent *event);
void paintEvent(QPaintEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent *event);
void resizeEvent(QResizeEvent *event);
private:
void currentImg2scaledImg(SvgInfo &currentImg,QPixmap &QPixmap,const QSize &size);
void draw_img(QPainter *painter);
Ui::ImgViewerWindow *ui;
QWidget *parentWindow;
bool left_click;
QList<QList<SvgInfo>> img_list;
QStringList filelist;
QList<TTFDecodeThread*> decode_thread;
QList<TTFDecodeThread*> decode_thread_finsh;
QList<SvgInfo> currentImg_RGB_list;
SvgInfo currentImg;
QPixmap scaled_img;
QPoint point;
QPoint startPos;
QPoint endPos;
bool flipRGB = false;
};
#endif // IMGVIEWER_H