From 06783ab4aec157779c3097c4ba935a4cbd1f2b01 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Tue, 4 Nov 2014 02:57:52 +0000 Subject: [PATCH] Fix diff between color space and pel format when showing pel values --- source/app/ViewArea.cpp | 48 ++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/source/app/ViewArea.cpp b/source/app/ViewArea.cpp index 2986598..3d0c4a9 100644 --- a/source/app/ViewArea.cpp +++ b/source/app/ViewArea.cpp @@ -372,10 +372,9 @@ void ViewArea::paintEvent( QPaintEvent *event ) QPoint pixelTopLeft( i, j ); QRect pixelRect( viewToWindow( pixelTopLeft ), QSize( m_zoomFactor, m_zoomFactor ) ); + Int frFormat = m_pcCurrFrame->getColorSpace(); - Int frFormat = m_pcCurrFrame->getPelFormat(); - - if( (frFormat==PlaYUVerFrame::COLOR_YUV) || (frFormat==PlaYUVerFrame::COLOR_GRAY) ) + if( frFormat == PlaYUVerFrame::COLOR_YUV ) { sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft, PlaYUVerFrame::COLOR_YUV ); @@ -384,32 +383,41 @@ void ViewArea::paintEvent( QPaintEvent *event ) else painter.setPen( QColor( Qt::black ) ); - painter.drawText( pixelRect, Qt::AlignCenter, "Y: " + QString::number( sPixelValue.Luma ) + "\n" + - "U: " + QString::number( sPixelValue.ChromaU ) + "\n" + - "V: " + QString::number( sPixelValue.ChromaV )); + painter.drawText( pixelRect, Qt::AlignCenter, + "Y: " + QString::number( sPixelValue.Luma ) + "\n" + "U: " + QString::number( sPixelValue.ChromaU ) + "\n" + "V: " + + QString::number( sPixelValue.ChromaV ) ); } - else + if( frFormat == PlaYUVerFrame::COLOR_GRAY ) { - if( (frFormat==PlaYUVerFrame::COLOR_RGB) ) - { - sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft, PlaYUVerFrame::COLOR_RGB ); + sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft, PlaYUVerFrame::COLOR_YUV ); - if( ( sPixelValue.ColorR + sPixelValue.ColorG + sPixelValue.ColorB ) < 128*3 ) - painter.setPen( QColor( Qt::white ) ); - else - painter.setPen( QColor( Qt::black ) ); - - painter.drawText( pixelRect, Qt::AlignCenter, "R: " + QString::number( sPixelValue.ColorR ) + "\n" + - "G: " + QString::number( sPixelValue.ColorG ) + "\n" + - "B: " + QString::number( sPixelValue.ColorB )); - } + if( sPixelValue.Luma < 128 ) + painter.setPen( QColor( Qt::white ) ); else - assert(0); + painter.setPen( QColor( Qt::black ) ); + + painter.drawText( pixelRect, Qt::AlignCenter, + "Y: " + QString::number( sPixelValue.Luma ) ); } + if( ( frFormat == PlaYUVerFrame::COLOR_RGB ) ) + { + sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft, PlaYUVerFrame::COLOR_RGB ); + + if( ( sPixelValue.ColorR + sPixelValue.ColorG + sPixelValue.ColorB ) < 128 * 3 ) + painter.setPen( QColor( Qt::white ) ); + else + painter.setPen( QColor( Qt::black ) ); + + painter.drawText( pixelRect, Qt::AlignCenter, + "R: " + QString::number( sPixelValue.ColorR ) + "\n" + "G: " + QString::number( sPixelValue.ColorG ) + "\n" + "B: " + + QString::number( sPixelValue.ColorB ) ); + } } + } + QColor color( Qt::white ); QPen mainPen = QPen( color, 1, Qt::SolidLine ); painter.setPen( mainPen );