From 3e21e3cdfca1f5ae8fe76f62c777d6cfc4de2092 Mon Sep 17 00:00:00 2001 From: Luis Lucas Date: Tue, 4 Nov 2014 01:14:32 +0000 Subject: [PATCH] Add chroma value to pixel information representation when zooming image. Add support for RGB pixel information. --- source/app/ViewArea.cpp | 45 +++++++++++++++++++++++++++++------- source/lib/PlaYUVerFrame.cpp | 26 +++++++++++++++++++++ source/lib/PlaYUVerFrame.h | 1 + 3 files changed, 64 insertions(+), 8 deletions(-) diff --git a/source/app/ViewArea.cpp b/source/app/ViewArea.cpp index 53bf361..2986598 100644 --- a/source/app/ViewArea.cpp +++ b/source/app/ViewArea.cpp @@ -352,14 +352,14 @@ void ViewArea::paintEvent( QPaintEvent *event ) } // Draw pixel values in grid - if( m_zoomFactor >= 25.0 ) + if( m_zoomFactor >= 50.0 ) { Int imageWidth = m_pixmap.width(); Int imageHeight = m_pixmap.height(); Pixel sPixelValue; QFont font( "Helvetica" ); - font.setPixelSize( m_zoomFactor / 4 ); + font.setPixelSize( 12 ); painter.setFont( font ); QRect vr = windowToView( winRect ); @@ -370,14 +370,43 @@ void ViewArea::paintEvent( QPaintEvent *event ) for( Int j = vr.y(); j <= vr.bottom(); j++ ) { QPoint pixelTopLeft( i, j ); - sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft, PlaYUVerFrame::COLOR_YUV ); - QRect pixelRect( viewToWindow( pixelTopLeft ), QSize( m_zoomFactor, m_zoomFactor ) ); - if( sPixelValue.Luma < 128 ) - painter.setPen( QColor( Qt::white ) ); + + + Int frFormat = m_pcCurrFrame->getPelFormat(); + + if( (frFormat==PlaYUVerFrame::COLOR_YUV) || (frFormat==PlaYUVerFrame::COLOR_GRAY) ) + { + sPixelValue = m_pcCurrFrame->getPixelValue( pixelTopLeft, PlaYUVerFrame::COLOR_YUV ); + + if( sPixelValue.Luma < 128 ) + painter.setPen( QColor( Qt::white ) ); + 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 )); + } else - painter.setPen( QColor( Qt::black ) ); - painter.drawText( pixelRect, Qt::AlignCenter, 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 )); + } + else + assert(0); + } + } } diff --git a/source/lib/PlaYUVerFrame.cpp b/source/lib/PlaYUVerFrame.cpp index 6d0c47b..5717018 100644 --- a/source/lib/PlaYUVerFrame.cpp +++ b/source/lib/PlaYUVerFrame.cpp @@ -670,6 +670,32 @@ Pixel PlaYUVerFrame::getPixelValue( const QPoint &pos, Int color_space ) return pixel_value; } +Int PlaYUVerFrame::getColorSpace() const +{ + Int iColorSpace; + + switch (m_iPixelFormat) { + case YUV420p: + case YUV422p: + case YUV444p: + case YUYV422: + iColorSpace = COLOR_YUV ; + break; + case RGB8: + iColorSpace = COLOR_RGB ; + break; + case GRAY: + iColorSpace = COLOR_GRAY ; + break; + default: + iColorSpace = COLOR_INVALID ; + break; + } + + return iColorSpace; +} + + Pixel PlaYUVerFrame::ConvertPixel( Pixel sInputPixel, Int eOutputSpace ) { Int outA, outB, outC; diff --git a/source/lib/PlaYUVerFrame.h b/source/lib/PlaYUVerFrame.h index 3ee9dc9..1ba22c2 100644 --- a/source/lib/PlaYUVerFrame.h +++ b/source/lib/PlaYUVerFrame.h @@ -133,6 +133,7 @@ public: } Pixel getPixelValue( const QPoint&, Int ); + Int getColorSpace() const; UChar* getQImageBuffer() const {