-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathQImagePainter.cpp
45 lines (38 loc) · 1.19 KB
/
QImagePainter.cpp
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
#include "QImagePainter.h"
#include <QDateTime>
#include <QDebug>
QImagePainter::QImagePainter( QImage* image, QVideoFrame* videoFrame, const QVideoSurfaceFormat& surfaceFormat , int videoOutputOrientation) :
QPainter( image )
{
bool bottomToTop = false;
if ( image )
{
if ( videoFrame && videoFrame->handleType() == QAbstractVideoBuffer::NoHandle )
{
bottomToTop = ( surfaceFormat.scanLineDirection() == QVideoSurfaceFormat::BottomToTop );
}
}
switch ( videoOutputOrientation )
{
case 270:
rotate( 270 );
translate( -(image->height()-1), !bottomToTop ? 0 : (image->width()-1) );
scale( 1, !bottomToTop ? 1 : -1 );
break;
case 180:
rotate( 180 );
translate( -(image->width()-1), !bottomToTop ? -(image->height()-1) : 0 );
scale( 1, !bottomToTop ? 1 : -1 );
break;
case 90:
rotate( 90 );
translate( 0, !bottomToTop ? -(image->width()-1) : 0 );
scale( 1, !bottomToTop ? 1 : -1 );
break;
case 0:
default:
translate( 0, !bottomToTop ? 0 : (image->height()-1) );
scale( 1, !bottomToTop ? 1 : -1 );
break;
}
}