Diffstat (limited to 'noncore/multimedia/camera/zcameraio.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/camera/zcameraio.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
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 @@ -26,12 +26,15 @@ #include <opie2/odebug.h> +ZCameraIO* ZCameraIO::_instance = 0; + ZCameraIO::ZCameraIO() { _driver = open( "/dev/sharp_zdc", O_RDWR ); if ( _driver == -1 ) oerr << "Can't open camera driver: " << strerror(errno) << oendl; + ZCameraIO::_instance = this; }; @@ -42,8 +45,10 @@ ZCameraIO::~ZCameraIO() } -bool ZCameraIO::snapshot( QImage* img ) +bool ZCameraIO::snapshot( QImage* image ) { + /* + char buf[76800]; write( _driver, "M=13", 4 ); @@ -53,4 +58,32 @@ bool ZCameraIO::snapshot( QImage* img ) int result = read( _driver, &buf, sizeof buf ); 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; } |