]> git.sesse.net Git - nageru/blob - jpeg_frame_view.h
Make the JPEG frames update on demand.
[nageru] / jpeg_frame_view.h
1 #ifndef _JPEG_FRAME_VIEW_H
2 #define _JPEG_FRAME_VIEW_H 1
3
4 #include <QGraphicsView>
5 #include <QGraphicsPixmapItem>
6 #include <QGraphicsScene>
7
8 #include <stdint.h>
9
10 class JPEGFrameView : public QGraphicsView {
11         Q_OBJECT
12
13 public:
14         JPEGFrameView(QWidget *parent);
15
16         void setFrame(unsigned stream_idx, int64_t pts)
17         {
18                 this->stream_idx = stream_idx;
19                 this->pts = pts;
20                 update_frame();
21         }
22
23 protected:
24         void resizeEvent(QResizeEvent *event) override;
25         void paintEvent(QPaintEvent *event) override;
26
27 private:
28         void update_frame();
29
30         QGraphicsPixmapItem item;
31         QGraphicsScene scene;
32
33         unsigned stream_idx;
34         int64_t pts;
35         bool dirty = false;
36 };
37
38 #endif  // !defined(_JPEG_FRAME_VIEW_H)