-rw-r--r-- | noncore/multimedia/camera/mainwindow.cpp | 11 | ||||
-rw-r--r-- | noncore/multimedia/camera/mainwindow.h | 6 | ||||
-rw-r--r-- | noncore/multimedia/camera/zcameraio.cpp | 35 | ||||
-rw-r--r-- | noncore/multimedia/camera/zcameraio.h | 3 |
4 files changed, 49 insertions, 6 deletions
diff --git a/noncore/multimedia/camera/mainwindow.cpp b/noncore/multimedia/camera/mainwindow.cpp index 6431dfa..2cca9f9 100644 --- a/noncore/multimedia/camera/mainwindow.cpp +++ b/noncore/multimedia/camera/mainwindow.cpp @@ -16,2 +16,3 @@ #include "mainwindow.h" +#include "zcameraio.h" @@ -28,3 +29,3 @@ CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags QVBox* v = new QVBox( this ); - QLabel* l = new QLabel( v ); + l = new QLabel( v ); l->setFixedSize( QSize( 240, 160 ) ); @@ -47,3 +48,9 @@ void CameraMainWindow::clickedSnapShot() { - qDebug( "Hello!" ); + QImage i; + QPixmap p; + if ( ZCameraIO::instance()->snapshot( &i ) ) + { + p.convertFromImage( i ); + l->setPixmap( p ); + } } diff --git a/noncore/multimedia/camera/mainwindow.h b/noncore/multimedia/camera/mainwindow.h index a349652..521107b 100644 --- a/noncore/multimedia/camera/mainwindow.h +++ b/noncore/multimedia/camera/mainwindow.h @@ -20,6 +20,5 @@ -class Wellenreiter; -class WellenreiterConfigWindow; class QIconSet; class QToolButton; +class QLabel; @@ -37,2 +36,5 @@ class CameraMainWindow: public QMainWindow void clickedSnapShot(); + + private: + QLabel* l; }; diff --git a/noncore/multimedia/camera/zcameraio.cpp b/noncore/multimedia/camera/zcameraio.cpp index aa6cbe3..e74136f 100644 --- a/noncore/multimedia/camera/zcameraio.cpp +++ b/noncore/multimedia/camera/zcameraio.cpp @@ -28,2 +28,4 @@ +ZCameraIO* ZCameraIO::_instance = 0; + ZCameraIO::ZCameraIO() @@ -34,2 +36,3 @@ ZCameraIO::ZCameraIO() + ZCameraIO::_instance = this; }; @@ -44,4 +47,6 @@ ZCameraIO::~ZCameraIO() -bool ZCameraIO::snapshot( QImage* img ) +bool ZCameraIO::snapshot( QImage* image ) { + /* + char buf[76800]; @@ -55,2 +60,30 @@ bool ZCameraIO::snapshot( QImage* img ) return result == sizeof buf; + + */ + + uchar buf[76800]; + uchar* bp = buf; + uchar* p; + + + int fd = open( "/tmp/cam", O_RDONLY ); + if ( read( fd, buf, sizeof buf ) != sizeof buf ) + qDebug( "WARNING: couldn't read image!" ); + + image->create( 240, 160, 16 ); + for ( int i = 0; i < 160; ++i ) + { + p = image->scanLine( i ); + for ( int j = 0; j < 240; j++ ) + { + *p = *bp; + p++; + bp++; + *p = *bp; + p++; + bp++; + } + } + + return true; } diff --git a/noncore/multimedia/camera/zcameraio.h b/noncore/multimedia/camera/zcameraio.h index 817d3b4..1690aa6 100644 --- a/noncore/multimedia/camera/zcameraio.h +++ b/noncore/multimedia/camera/zcameraio.h @@ -27,4 +27,4 @@ class ZCameraIO bool isOpen() const { return _driver != -1; }; - bool snapshot( QImage* ); + static ZCameraIO* instance() { return _instance; }; @@ -32,2 +32,3 @@ class ZCameraIO int _driver; + static ZCameraIO* _instance; }; |