Diffstat (limited to 'noncore/multimedia/camera/zcameraio.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/camera/zcameraio.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/noncore/multimedia/camera/zcameraio.cpp b/noncore/multimedia/camera/zcameraio.cpp index 56b2e13..51771a5 100644 --- a/noncore/multimedia/camera/zcameraio.cpp +++ b/noncore/multimedia/camera/zcameraio.cpp @@ -99,24 +99,25 @@ inline bool ZCameraIO::isCapturing() const return _status[2] == 'C'; } inline 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; } return false; @@ -164,36 +165,49 @@ 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( IMAGE | XFLIP | YFLIP ); - char buf[76800]; + setReadMode( STATUS ); + + odebug << "finder reversed = " << isFinderReversed() << oendl; + odebug << "rotation = " << _rot << oendl; + + if ( _rot ) // Portrait + { + setReadMode( IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0 ); + } + else // Landscape + { + setReadMode( IMAGE | XFLIP | YFLIP ); //isFinderReversed() ? 0 : XFLIP ); + } + + char buf[_readlen]; char* bp = buf; unsigned char* p; read( bp, _readlen ); - image->create( 240, 160, 16 ); - for ( int i = 0; i < 160; ++i ) + image->create( _width, _height, 16 ); + for ( int i = 0; i < _height; ++i ) { p = image->scanLine( i ); - for ( int j = 0; j < 240; j++ ) + for ( int j = 0; j < _width; j++ ) { *p = *bp; p++; bp++; *p = *bp; p++; bp++; } } return true; } |