Diffstat (limited to 'noncore/multimedia/camera/lib/zcameraio.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/camera/lib/zcameraio.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/noncore/multimedia/camera/lib/zcameraio.cpp b/noncore/multimedia/camera/lib/zcameraio.cpp index c940b45..d59cbbb 100644 --- a/noncore/multimedia/camera/lib/zcameraio.cpp +++ b/noncore/multimedia/camera/lib/zcameraio.cpp @@ -110,64 +110,65 @@ bool ZCameraIO::isShutterPressed() bool ZCameraIO::isFinderReversed() const { return _status[1] == 'M'; } bool ZCameraIO::isCapturing() const { return _status[2] == 'C'; } bool ZCameraIO::isAvailable() const { return _status[3] == 'A'; } bool ZCameraIO::setCaptureFrame( int width, int height, int zoom, bool rot ) { odebug << "setCaptureFrame( " << width << ", " << height << ", " << zoom << ", " << rot << " )" << oendl; char b[100]; sprintf( b, "%c=%d,%d,%d,%d", rot ? 'R':'S', width, height, zoom, width*2 ); if ( write( b ) ) { _width = width; _height = height; _zoom = zoom; _rot = rot; _readlen = 2 * _width * _height; // camera is fixed @ 16 bits per pixel return true; } + owarn << "couldn't write to driver" << oendl; 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 & STATUS ) // STATUS bit is set { read( _status, 4 ); if ( isShutterPressed() ) { emit shutterClicked(); } } } void ZCameraIO::setFlip( int flip ) { _flip = flip; } @@ -186,64 +187,66 @@ bool ZCameraIO::read( char* b, int len ) int rlen = ::read( _driver, b, len ); #ifndef NO_TIMING int time = t.elapsed(); #else int time = -1; #endif if ( rlen ) odebug << "read " << rlen << " ('" << b[0] << b[1] << b[2] << b[3] << "') [" << time << " ms] from driver." << oendl; else odebug << "read nothing from driver." << oendl; return rlen == len; } bool ZCameraIO::write( char* buf, int len ) { if ( !len ) len = strlen( buf ); odebug << "writing '" << buf << "' to driver." << oendl; return ::write( _driver, buf, len ) == len; } bool ZCameraIO::snapshot( QImage* image ) { setReadMode( STATUS ); odebug << "finder reversed = " << isFinderReversed() << oendl; odebug << "rotation = " << _rot << oendl; + odebug << "w=" << _width << " h= " << _height << " readlen= " << _readlen << oendl; + int readmode; if ( _flip == -1 ) // AUTO { if ( _rot ) // Portrait { readmode = IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0; } else // Landscape { readmode = IMAGE | XFLIP | YFLIP; } } else // OVERRIDE { readmode = IMAGE | _flip; } setReadMode( readmode ); char buf[_readlen]; char* bp = buf; unsigned char* p; read( bp, _readlen ); image->create( _width, _height, 16 ); for ( int i = 0; i < _height; ++i ) { p = image->scanLine( i ); for ( int j = 0; j < _width; j++ ) { *p = *bp; @@ -262,50 +265,51 @@ bool ZCameraIO::snapshot( QImage* image ) bool ZCameraIO::snapshot( unsigned char* buf ) { setReadMode( STATUS ); odebug << "finder reversed = " << isFinderReversed() << oendl; odebug << "rotation = " << _rot << oendl; int readmode; if ( _flip == -1 ) // AUTO { if ( _rot ) // Portrait { readmode = IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0; } else // Landscape { readmode = IMAGE | XFLIP | YFLIP; } } else // OVERRIDE { readmode = IMAGE | _flip; } setReadMode( readmode ); read( (char*) buf, _readlen ); } void ZCameraIO::captureFrame( int w, int h, int zoom, QImage* image ) { + int prot = _rot; int pw = _width; int ph = _height; - setCaptureFrame( w, h, zoom*256, _rot ); + setCaptureFrame( w, h, zoom*256, w<h ); snapshot( image ); - setCaptureFrame( pw, ph, _zoom, _rot ); + setCaptureFrame( pw, ph, _zoom, prot ); } void ZCameraIO::captureFrame( int w, int h, int zoom, unsigned char* buf ) { //FIXME: this is too slow int pw = _width; int ph = _height; setCaptureFrame( w, h, zoom*256, _rot ); snapshot( buf ); setCaptureFrame( pw, ph, _zoom, _rot ); } |