Diffstat (limited to 'noncore/multimedia/camera/zcameraio.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/camera/zcameraio.cpp | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/noncore/multimedia/camera/zcameraio.cpp b/noncore/multimedia/camera/zcameraio.cpp index b37ae8c..9af0c25 100644 --- a/noncore/multimedia/camera/zcameraio.cpp +++ b/noncore/multimedia/camera/zcameraio.cpp @@ -57,12 +57,13 @@ ZCameraIO::ZCameraIO() void ZCameraIO::init() { if ( ZCameraIO::_instance ) ofatal << "Don't create more than one ZCameraIO instances." << oendl; else { + _timer = new QTime(); setReadMode( STATUS ); } } ZCameraIO::~ZCameraIO() @@ -80,14 +81,24 @@ bool ZCameraIO::isOpen() const return _driver != -1; } bool ZCameraIO::isShutterPressed() { - return _status[0] == 'S'; - clearShutterLatch(); + if ( _timer->elapsed() < 1000 ) //TODO: make this customizable? + { + clearShutterLatch(); + return false; + } + if ( _status[0] == 'S' ) + { + _timer->restart(); + clearShutterLatch(); + return true; + } + else return false; } bool ZCameraIO::isFinderReversed() const { return _status[1] == 'M'; @@ -121,26 +132,34 @@ bool ZCameraIO::setCaptureFrame( int width, int height, int zoom, bool rot ) return true; } return false; } +bool ZCameraIO::setZoom( int zoom ) +{ + return setCaptureFrame( _width, _height, zoom*256, _rot ); +} + + void ZCameraIO::setReadMode( int mode ) { char b[10]; sprintf( b, "M=%d", mode ); write( b, mode <= 9 ? 3 : 4 ); - if ( mode & 1 ) // STATUS bit is set + if ( mode & STATUS ) // STATUS bit is set + { read( _status, 4 ); + if ( isShutterPressed() ) emit shutterClicked(); + } } void ZCameraIO::clearShutterLatch() { - char b = 'B'; - write( &b, 1 ); + write( "B", 1 ); } bool ZCameraIO::read( char* b, int len ) { #ifndef NO_TIMING @@ -209,12 +228,13 @@ bool ZCameraIO::snapshot( QImage* image ) } } return true; } + bool ZCameraIO::snapshot( unsigned char* buf ) { setReadMode( IMAGE | XFLIP | YFLIP ); read( (char*) buf, _readlen ); @@ -225,6 +245,20 @@ bool ZCameraIO::snapshot( unsigned char* buf ) // TESTCODE */ return true; } + +void ZCameraIO::captureFrame( int w, int h, int zoom, QImage* image ) +{ + int pw = _width; + int ph = _height; + if ( _rot ) + setCaptureFrame( h, w, zoom*256, true ); + else + setCaptureFrame( w, h, zoom*256, false ); + snapshot( image ); + setCaptureFrame( pw, ph, _zoom, _rot ); +} + + |