diff --git a/source/app/SubWindowHandle.cpp b/source/app/SubWindowHandle.cpp index ad94ac3..a2e8a2d 100644 --- a/source/app/SubWindowHandle.cpp +++ b/source/app/SubWindowHandle.cpp @@ -235,12 +235,18 @@ Void SubWindowHandle::zoomToFit() scaleView( niceFit ); } -Void SubWindowHandle::scaleView( Double factor ) +Void SubWindowHandle::scaleViewFactor( Double factor ) { Q_ASSERT( m_cViewArea->image() ); m_cViewArea->zoomChangeEvent( factor ); } +Void SubWindowHandle::scaleView( Double scale ) +{ + Q_ASSERT( m_cViewArea->image() ); + m_cViewArea->setZoomFactor( scale ); +} + Void SubWindowHandle::scaleView( Int width, Int height ) { scaleView( QSize( width, height ) ); diff --git a/source/app/SubWindowHandle.h b/source/app/SubWindowHandle.h index 48fb532..0d58adf 100644 --- a/source/app/SubWindowHandle.h +++ b/source/app/SubWindowHandle.h @@ -106,7 +106,7 @@ public: * @param factor factor of scale. Ex: 1.2 scale the image up by 20% and * 0.8 scale the image down by 25% */ - Void scaleView( Double factor ); + Void scaleView( Double scale ); /** * The current image size is scaled to a rectangle as large as possible @@ -121,6 +121,8 @@ public: */ Void scaleView( const QSize & size ); + Void scaleViewFactor( Double factor ); + Double getScaleFactor() { return m_cViewArea->getZoomFactor(); diff --git a/source/app/ViewArea.cpp b/source/app/ViewArea.cpp index 3976621..bd544c7 100755 --- a/source/app/ViewArea.cpp +++ b/source/app/ViewArea.cpp @@ -37,6 +37,8 @@ #include "ViewArea.h" #include "GridManager.h" +#include "PlaYUVerFrame.h" +#include "InputStream.h" namespace plaYUVer { @@ -108,7 +110,7 @@ Double ViewArea::getZoomFactor() Void ViewArea::zoomChangeEvent(Double factor) { Double zoomFactor; - Double maxZoom = 10.0; + Double maxZoom = 100.0; Double minZoom = ( 32.0 / m_pixmap.width() ); if( ( m_zoomFactor == minZoom ) && (factor < 1 ) ) @@ -324,6 +326,60 @@ void ViewArea::paintEvent( QPaintEvent *event ) painter.restore(); + + if(m_zoomFactor>=25.0) + { + Int imageWidth = m_pixmap.width(); + Int imageHeight = m_pixmap.height(); + PlaYUVerFrame *curFrame = getInputStream()->getCurrFrame(); + Pixel sPixelValue; + + QFont font("Helvetica"); + font.setPixelSize(m_zoomFactor/4); + painter.setFont(font); + + QRect vr = windowToView( winRect ); + vr &= QRect( 0, 0, imageWidth, imageHeight ); + + for(Int i=vr.x() ; i<=vr.right() ; i++) + { + for(Int j=vr.y() ; j<=vr.bottom() ; j++) + { + QPoint pixelTopLeft(i,j); + sPixelValue = curFrame->getPixelValue( pixelTopLeft, COLOR_YUV ); + + QRect pixelRect(viewToWindow(pixelTopLeft), QSize(m_zoomFactor,m_zoomFactor)); + if( sPixelValue.Luma < 128 ) + painter.setPen(QColor(Qt::white)); + else + painter.setPen(QColor(Qt::black)); + painter.drawText(pixelRect, Qt::AlignCenter, QString::number(sPixelValue.Luma)); + } + } + + QColor color( Qt::white ); + QPen mainPen = QPen( color, 1, Qt::SolidLine ); + painter.setPen(mainPen); + + // Draw vertical line + for( Int x = vr.x(); x <= vr.right(); x ++ ) + { + // Always draw the full line otherwise the line stippling + // varies with the location of view area and we get glitchy + // patterns. + painter.drawLine( viewToWindow(QPoint(x,0)), viewToWindow(QPoint(x,imageHeight)) ); + qDebug() << "Line " << viewToWindow(QPoint(x,0)) << viewToWindow(QPoint(x,imageHeight)) << m_zoomFactor; + } + // Draw horizontal line + for( Int y = vr.y(); y <= vr.bottom(); y ++ ) + { + painter.drawLine( viewToWindow(QPoint(0,y)), viewToWindow(QPoint(imageWidth,y)) ); + } + } + + + + // Draw a border around the image. if( m_xOffset || m_yOffset ) { diff --git a/source/app/plaYUVerApp.cpp b/source/app/plaYUVerApp.cpp index a4d2bf6..a554572 100644 --- a/source/app/plaYUVerApp.cpp +++ b/source/app/plaYUVerApp.cpp @@ -289,7 +289,7 @@ void plaYUVerApp::scaleFrame( int ratio ) { if( activeSubWindow() ) { - activeSubWindow()->scaleView( ( Double )( ratio ) / 100.0 ); + activeSubWindow()->scaleViewFactor( ( Double )( ratio ) / 100.0 ); // actionZoomIn->setEnabled( activeSubWindow()->getScaleFactor() < 3.0 ); // actionZoomOut->setEnabled( activeSubWindow()->getScaleFactor() > 0.333 );