From 16401d145463245fb06e2272805f70f27ba8d88a Mon Sep 17 00:00:00 2001 From: Luis Lucas Date: Sat, 22 Mar 2014 15:23:23 +0000 Subject: [PATCH] Very initial implementation to track pixel coordinates and value using mouse. --- external_lib/scode/viewarea.cpp | 1 - external_lib/scode/viewarea.h | 1 + source/InputStream.h | 5 +++++ source/PlaYUVerFrame.cpp | 6 ++++++ source/PlaYUVerFrame.h | 3 +++ source/SubWindowHandle.cpp | 2 +- source/SubWindowHandle.h | 5 +++++ source/TypeDef.h | 15 +++++++++++++++ source/plaYUVerApp.cpp | 26 ++++++++++++++++++++++++-- source/plaYUVerApp.h | 1 + 10 files changed, 61 insertions(+), 4 deletions(-) diff --git a/external_lib/scode/viewarea.cpp b/external_lib/scode/viewarea.cpp index 5843b59..7fdf86e 100755 --- a/external_lib/scode/viewarea.cpp +++ b/external_lib/scode/viewarea.cpp @@ -220,7 +220,6 @@ void ViewArea::updateSize() // perform the necessary updates (updateOffset). resize( p->width(), p->height() ); } - if( w <= width() && h <= height() ) updateOffset(); } diff --git a/external_lib/scode/viewarea.h b/external_lib/scode/viewarea.h index c1eb0b7..e207186 100755 --- a/external_lib/scode/viewarea.h +++ b/external_lib/scode/viewarea.h @@ -103,6 +103,7 @@ public: signals: void selectionChanged( const QRect &rect ); void positionChanged( const QPoint &pos ); + void updateStatusBar( const QPoint &actualPos, int &luma, int &chromaU, int &chromaV ); void zoomFactorChanged( double ); public slots: diff --git a/source/InputStream.h b/source/InputStream.h index 7935d41..466aa0c 100755 --- a/source/InputStream.h +++ b/source/InputStream.h @@ -160,6 +160,11 @@ public: } } + PlaYUVerFrame *getCurrentFrame() + { + return m_cCurrFrame; + } + }; } // NAMESPACE diff --git a/source/PlaYUVerFrame.cpp b/source/PlaYUVerFrame.cpp index 7f93389..6be9d63 100755 --- a/source/PlaYUVerFrame.cpp +++ b/source/PlaYUVerFrame.cpp @@ -207,4 +207,10 @@ UInt64 PlaYUVerFrame::getBytesPerFrame() return 0; } +Pel PlaYUVerFrame::getPixelValueFromYUV(const QPoint &pos, YUVcomponent color) +{ + return m_pppcInputPel[color][0][pos.y()*m_uiWidth+pos.x()]; +} + + } // NAMESPACE diff --git a/source/PlaYUVerFrame.h b/source/PlaYUVerFrame.h index 5823561..47e5910 100755 --- a/source/PlaYUVerFrame.h +++ b/source/PlaYUVerFrame.h @@ -56,6 +56,9 @@ public: { return m_pppcRGBPel; } + + Pel getPixelValueFromYUV(const QPoint &pos, YUVcomponent color); + private: Void YUV420toRGB(); diff --git a/source/SubWindowHandle.cpp b/source/SubWindowHandle.cpp index 9ea4ca6..f128e93 100644 --- a/source/SubWindowHandle.cpp +++ b/source/SubWindowHandle.cpp @@ -249,7 +249,7 @@ QSize SubWindowHandle::sizeHint() const maxSize = p->size(); } - QSize isize = QSize( m_pCurrStream->getWidth() + 500, m_pCurrStream->getHeight() + 500 ); + QSize isize = QSize( m_pCurrStream->getWidth() + 50, m_pCurrStream->getHeight() + 50 ); // If the SubWindowHandle needs more space that the avaiable, we'll give // to the subwindow a reasonable size preserving the image aspect ratio. diff --git a/source/SubWindowHandle.h b/source/SubWindowHandle.h index e92233b..f3f57b9 100644 --- a/source/SubWindowHandle.h +++ b/source/SubWindowHandle.h @@ -75,6 +75,11 @@ public: return m_pCurrStream; } + ViewArea* getViewArea() + { + return m_cViewArea; + } + /** * Show the image at its original size */ diff --git a/source/TypeDef.h b/source/TypeDef.h index 4f21545..152a043 100644 --- a/source/TypeDef.h +++ b/source/TypeDef.h @@ -115,6 +115,21 @@ enum InputStreamColorSpace NO_FMT = -1, YUV420, YUV400, YUV422, RGB, }; +enum YUVcomponent +{ + LUMA = 0, + CHROMA_U, + CHROMA_V, +}; + +enum RGBcomponent +{ + COLOR_R = 0, + COLOR_G, + COLOR_B, +}; + + } diff --git a/source/plaYUVerApp.cpp b/source/plaYUVerApp.cpp index 53580c5..c9e9324 100644 --- a/source/plaYUVerApp.cpp +++ b/source/plaYUVerApp.cpp @@ -117,6 +117,8 @@ void plaYUVerApp::open() addSubWindow( interfaceChild ); statusBar()->showMessage( tr( "File loaded" ), 2000 ); interfaceChild->show(); + connect( interfaceChild->getViewArea(), SIGNAL( positionChanged(const QPoint &) ), this, SLOT( updatePixelValueStatusBar(const QPoint &) ) ); + } else { @@ -576,8 +578,8 @@ QMdiSubWindow *plaYUVerApp::findSubWindow( const QString &fileName ) foreach( QMdiSubWindow * window, mdiArea->subWindowList() ){ SubWindowHandle *mdiChild = qobject_cast( window); if( mdiChild->currentFile() == canonicalFilePath ) - return window; -} + return window; + } return 0; } @@ -588,4 +590,24 @@ void plaYUVerApp::setActiveSubWindow( QWidget *window ) mdiArea->setActiveSubWindow( qobject_cast( window ) ); } +void plaYUVerApp::updatePixelValueStatusBar(const QPoint & pos) +{ + Pel pixel; + Int iWidth, iHeight; + Int posX = pos.x(), posY = pos.y(); + QString strStatus = QString("X=%1 Y=%2 ").arg(posX).arg(posY); + + SubWindowHandle *currentSubWindow = activeSubWindow(); + iWidth = currentSubWindow->getInputStream()->getWidth(); + iHeight = currentSubWindow->getInputStream()->getHeight(); + + if( (posX=0) && (posY=0) ) + { + pixel = currentSubWindow->getInputStream()->getCurrentFrame()->getPixelValueFromYUV(pos, LUMA); + QString strAux = QString("Luma= %1").arg(pixel); + strStatus.append(strAux); + statusBar()->showMessage( strStatus , 0 ); + } +} + } // NAMESPACE diff --git a/source/plaYUVerApp.h b/source/plaYUVerApp.h index bd3b8db..71d8d68 100644 --- a/source/plaYUVerApp.h +++ b/source/plaYUVerApp.h @@ -84,6 +84,7 @@ private Q_SLOTS: void dropEvent(QDropEvent *event); void setActiveSubWindow( QWidget *window ); + void updatePixelValueStatusBar(const QPoint & pos); private: QMdiArea *mdiArea;