-
Notifications
You must be signed in to change notification settings - Fork 10
/
QImageScanlines.cpp
42 lines (32 loc) · 1.14 KB
/
QImageScanlines.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
#include "QImageScanLines.h"
//----------------------------------------------------------------------
QImageScanLines::QImageScanLines( QImage* image, QVideoFrame* videoFrame, const QVideoSurfaceFormat& surfaceFormat ) :
m_Image( nullptr ),
m_BottomToTop( false )
{
setSource( image, videoFrame, surfaceFormat );
}
//----------------------------------------------------------------------
uchar* QImageScanLines::scanLine( int y )
{
if ( !m_Image )
{
return nullptr;
}
if ( m_BottomToTop )
{
return m_Image->scanLine( m_Image->height() - 1 - y );
}
return m_Image->scanLine( y );
}
//----------------------------------------------------------------------
void QImageScanLines::setSource( QImage* image, QVideoFrame* videoFrame, const QVideoSurfaceFormat& surfaceFormat )
{
m_Image = image;
m_BottomToTop = false;
if ( videoFrame && videoFrame->handleType() == QAbstractVideoBuffer::NoHandle )
{
m_BottomToTop = ( surfaceFormat.scanLineDirection() == QVideoSurfaceFormat::Direction::BottomToTop );
}
}
//----------------------------------------------------------------------