Diffstat (limited to 'noncore/multimedia/camera/zcameraio.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/camera/zcameraio.cpp | 100 |
1 files changed, 77 insertions, 23 deletions
diff --git a/noncore/multimedia/camera/zcameraio.cpp b/noncore/multimedia/camera/zcameraio.cpp index 9af0c25..1c449e7 100644 --- a/noncore/multimedia/camera/zcameraio.cpp +++ b/noncore/multimedia/camera/zcameraio.cpp | |||
@@ -46,3 +46,5 @@ ZCameraIO* ZCameraIO::instance() | |||
46 | ZCameraIO::ZCameraIO() | 46 | ZCameraIO::ZCameraIO() |
47 | :_height( 0 ), _width( 0 ), _zoom( 0 ), _rot( 0 ), _readlen( 0 ) | 47 | : _pressed( false ), _height( 0 ), _width( 0 ), _zoom( 0 ), |
48 | _flip( -1 ), _rot( 0 ), _readlen( 0 ) | ||
49 | |||
48 | { | 50 | { |
@@ -86,14 +88,20 @@ bool ZCameraIO::isShutterPressed() | |||
86 | { | 88 | { |
87 | if ( _timer->elapsed() < 1000 ) //TODO: make this customizable? | ||
88 | { | ||
89 | clearShutterLatch(); | ||
90 | return false; | ||
91 | } | ||
92 | if ( _status[0] == 'S' ) | 89 | if ( _status[0] == 'S' ) |
93 | { | 90 | { |
94 | _timer->restart(); | 91 | if ( !_pressed ) // wasn't pressed before, but is now! |
95 | clearShutterLatch(); | 92 | { |
96 | return true; | 93 | _pressed = true; |
94 | _timer->start(); | ||
95 | return true; | ||
96 | } | ||
97 | |||
98 | if ( _timer->elapsed() > 2000 ) // the press is pretty old now | ||
99 | { | ||
100 | clearShutterLatch(); | ||
101 | _status[0] = 's'; | ||
102 | _pressed = false; | ||
103 | } | ||
97 | } | 104 | } |
98 | else return false; | 105 | |
106 | return false; | ||
99 | } | 107 | } |
@@ -151,3 +159,6 @@ void ZCameraIO::setReadMode( int mode ) | |||
151 | read( _status, 4 ); | 159 | read( _status, 4 ); |
152 | if ( isShutterPressed() ) emit shutterClicked(); | 160 | if ( isShutterPressed() ) |
161 | { | ||
162 | emit shutterClicked(); | ||
163 | } | ||
153 | } | 164 | } |
@@ -156,2 +167,8 @@ void ZCameraIO::setReadMode( int mode ) | |||
156 | 167 | ||
168 | void ZCameraIO::setFlip( int flip ) | ||
169 | { | ||
170 | _flip = flip; | ||
171 | } | ||
172 | |||
173 | |||
157 | void ZCameraIO::clearShutterLatch() | 174 | void ZCameraIO::clearShutterLatch() |
@@ -200,11 +217,21 @@ bool ZCameraIO::snapshot( QImage* image ) | |||
200 | 217 | ||
201 | if ( _rot ) // Portrait | 218 | int readmode; |
219 | if ( _flip == -1 ) // AUTO | ||
202 | { | 220 | { |
203 | setReadMode( IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0 ); | 221 | if ( _rot ) // Portrait |
222 | { | ||
223 | readmode = IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0; | ||
224 | } | ||
225 | else // Landscape | ||
226 | { | ||
227 | readmode = IMAGE | XFLIP | YFLIP; | ||
228 | } | ||
204 | } | 229 | } |
205 | else // Landscape | 230 | else // OVERRIDE |
206 | { | 231 | { |
207 | setReadMode( IMAGE | XFLIP | YFLIP ); //isFinderReversed() ? 0 : XFLIP ); | 232 | readmode = IMAGE | _flip; |
208 | } | 233 | } |
209 | 234 | ||
235 | setReadMode( readmode ); | ||
236 | |||
210 | char buf[_readlen]; | 237 | char buf[_readlen]; |
@@ -236,14 +263,27 @@ bool ZCameraIO::snapshot( unsigned char* buf ) | |||
236 | { | 263 | { |
237 | setReadMode( IMAGE | XFLIP | YFLIP ); | 264 | setReadMode( STATUS ); |
238 | 265 | ||
239 | read( (char*) buf, _readlen ); | 266 | odebug << "finder reversed = " << isFinderReversed() << oendl; |
267 | odebug << "rotation = " << _rot << oendl; | ||
240 | 268 | ||
241 | /* //TESTCODE | 269 | int readmode; |
242 | int fd = open( "/tmp/cam", O_RDONLY ); | 270 | if ( _flip == -1 ) // AUTO |
243 | if ( ::read( fd, (char*) buf, 76800 ) != 76800 ) | 271 | { |
244 | owarn << "Couldn't read image from /dev/sharp_zdc" << oendl; | 272 | if ( _rot ) // Portrait |
245 | // TESTCODE */ | 273 | { |
274 | readmode = IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0; | ||
275 | } | ||
276 | else // Landscape | ||
277 | { | ||
278 | readmode = IMAGE | XFLIP | YFLIP; | ||
279 | } | ||
280 | } | ||
281 | else // OVERRIDE | ||
282 | { | ||
283 | readmode = IMAGE | _flip; | ||
284 | } | ||
246 | 285 | ||
286 | setReadMode( readmode ); | ||
287 | read( (char*) buf, _readlen ); | ||
247 | 288 | ||
248 | return true; | ||
249 | } | 289 | } |
@@ -264 +304,15 @@ void ZCameraIO::captureFrame( int w, int h, int zoom, QImage* image ) | |||
264 | 304 | ||
305 | void ZCameraIO::captureFrame( int w, int h, int zoom, unsigned char* buf ) | ||
306 | { | ||
307 | //FIXME: this is too slow | ||
308 | int pw = _width; | ||
309 | int ph = _height; | ||
310 | if ( _rot ) | ||
311 | setCaptureFrame( h, w, zoom*256, true ); | ||
312 | else | ||
313 | setCaptureFrame( w, h, zoom*256, false ); | ||
314 | |||
315 | snapshot( buf ); | ||
316 | setCaptureFrame( pw, ph, _zoom, _rot ); | ||
317 | } | ||
318 | |||