summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-04-19 00:40:00 (UTC)
committer mickeyl <mickeyl>2003-04-19 00:40:00 (UTC)
commit724bb4ef15cd02a360e49de9c67847a19d5ca832 (patch) (unidiff)
tree0fc5f2aab63c005aa2cfd36f7517547c0aa62e1d
parent6e7112a3610c4e562f991ba6d6f33ca2fe0c605d (diff)
downloadopie-724bb4ef15cd02a360e49de9c67847a19d5ca832.zip
opie-724bb4ef15cd02a360e49de9c67847a19d5ca832.tar.gz
opie-724bb4ef15cd02a360e49de9c67847a19d5ca832.tar.bz2
- fix shutter handling
- include manually overriding xflip and yflip - prepare video capturing mode - use caption to indicate current settings
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/camera/camera.pro6
-rw-r--r--noncore/multimedia/camera/imageio.cpp55
-rw-r--r--noncore/multimedia/camera/imageio.h26
-rw-r--r--noncore/multimedia/camera/mainwindow.cpp198
-rw-r--r--noncore/multimedia/camera/mainwindow.h19
-rw-r--r--noncore/multimedia/camera/previewwidget.cpp14
-rw-r--r--noncore/multimedia/camera/previewwidget.h3
-rw-r--r--noncore/multimedia/camera/zcameraio.cpp100
-rw-r--r--noncore/multimedia/camera/zcameraio.h11
9 files changed, 396 insertions, 36 deletions
diff --git a/noncore/multimedia/camera/camera.pro b/noncore/multimedia/camera/camera.pro
index ffd5f37..8aedcea 100644
--- a/noncore/multimedia/camera/camera.pro
+++ b/noncore/multimedia/camera/camera.pro
@@ -6,3 +6,4 @@ CONFIG = qt warn_on debug
6 6
7HEADERS = zcameraio.h \ 7HEADERS = imageio.h \
8 zcameraio.h \
8 previewwidget.h \ 9 previewwidget.h \
@@ -10,3 +11,4 @@ HEADERS = zcameraio.h \
10 11
11SOURCES = zcameraio.cpp \ 12SOURCES = imageio.cpp \
13 zcameraio.cpp \
12 previewwidget.cpp \ 14 previewwidget.cpp \
diff --git a/noncore/multimedia/camera/imageio.cpp b/noncore/multimedia/camera/imageio.cpp
new file mode 100644
index 0000000..f8f5dd0
--- a/dev/null
+++ b/noncore/multimedia/camera/imageio.cpp
@@ -0,0 +1,55 @@
1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3**
4** This file is part of Opie Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14**********************************************************************/
15
16#include "imageio.h"
17
18#include <opie2/odebug.h>
19#include <qimage.h>
20
21
22void bufferToImage( int _width, int _height, unsigned char* bp, QImage* image )
23{
24 unsigned char* p;
25
26 image->create( _width, _height, 16 );
27 for ( int i = 0; i < _height; ++i )
28 {
29 p = image->scanLine( i );
30 for ( int j = 0; j < _width; j++ )
31 {
32 *p = *bp;
33 p++;
34 bp++;
35 *p = *bp;
36 p++;
37 bp++;
38 }
39 }
40}
41
42
43void imageToFile( QImage* i, const QString& name, const QString& format, int quality )
44{
45 QImage im = i->convertDepth( 32 );
46 bool result = im.save( name, format, quality );
47 if ( !result )
48 {
49 oerr << "imageio-Problem while writing." << oendl;
50 }
51 else
52 {
53 odebug << format << "-image has been successfully captured" << oendl;
54 }
55} \ No newline at end of file
diff --git a/noncore/multimedia/camera/imageio.h b/noncore/multimedia/camera/imageio.h
new file mode 100644
index 0000000..8dba2ed
--- a/dev/null
+++ b/noncore/multimedia/camera/imageio.h
@@ -0,0 +1,26 @@
1/**********************************************************************
2** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved.
3**
4** This file is part of Opie Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14**********************************************************************/
15
16#ifndef IMAGEIO_H
17#define IMAGEIO_H
18
19#include <qstring.h>
20
21class QImage;
22
23void bufferToImage( int _width, int height, unsigned char* bp, QImage* image );
24void imageToFile( QImage* i, const QString& name, const QString& format, int quality );
25
26#endif
diff --git a/noncore/multimedia/camera/mainwindow.cpp b/noncore/multimedia/camera/mainwindow.cpp
index 8e89039..6141fd1 100644
--- a/noncore/multimedia/camera/mainwindow.cpp
+++ b/noncore/multimedia/camera/mainwindow.cpp
@@ -18,2 +18,3 @@
18#include "zcameraio.h" 18#include "zcameraio.h"
19#include "imageio.h"
19 20
@@ -29,4 +30,6 @@
29#include <qpopupmenu.h> 30#include <qpopupmenu.h>
31#include <qprogressbar.h>
30#include <qpushbutton.h> 32#include <qpushbutton.h>
31#include <qmessagebox.h> 33#include <qmessagebox.h>
34#include <qlayout.h>
32#include <qdirectpainter_qws.h> 35#include <qdirectpainter_qws.h>
@@ -38,3 +41,2 @@
38using namespace Opie; 41using namespace Opie;
39
40#include <opie2/odebug.h> 42#include <opie2/odebug.h>
@@ -42,5 +44,13 @@ using namespace Opie;
42#include <assert.h> 44#include <assert.h>
45#include <sys/types.h>
46#include <sys/stat.h>
47#include <fcntl.h>
48#include <string.h>
49#include <errno.h>
50#include <unistd.h>
51
52#define CAPTUREFILE "/tmp/capture.dat"
43 53
44CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) 54CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f )
45 :QMainWindow( parent, name, f ), _pics( 0 ) 55 :QMainWindow( parent, name, f ), _capturing( false ), _pics( 0 )
46{ 56{
@@ -80,2 +90,5 @@ CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags
80 connect( ZCameraIO::instance(), SIGNAL( shutterClicked() ), this, SLOT( shutterClicked() ) ); 90 connect( ZCameraIO::instance(), SIGNAL( shutterClicked() ), this, SLOT( shutterClicked() ) );
91
92 updateCaption();
93
81}; 94};
@@ -91,2 +104,3 @@ void CameraMainWindow::init()
91 // TODO: Save this stuff in config 104 // TODO: Save this stuff in config
105 flip = 'A'; // auto
92 quality = 50; 106 quality = 50;
@@ -123,2 +137,10 @@ void CameraMainWindow::init()
123 137
138 flipg = new QActionGroup( 0, "flip", true );
139 flipg->setToggleAction( true );
140 ( new QAction( "Auto (recommended)", 0, 0, flipg, 0, true ) )->setOn( true );
141 new QAction( "0 (always off)", 0, 0, flipg, 0, true );
142 new QAction( "X (always horizontal)", 0, 0, flipg, 0, true );
143 new QAction( "Y (always vertical)", 0, 0, flipg, 0, true );
144 new QAction( "* (always both)", 0, 0, flipg, 0, true );
145
124 outputg = new QActionGroup( 0, "output", true ); 146 outputg = new QActionGroup( 0, "output", true );
@@ -128,2 +150,3 @@ void CameraMainWindow::init()
128 new QAction( "BMP", 0, 0, outputg, 0, true ); 150 new QAction( "BMP", 0, 0, outputg, 0, true );
151 new QAction( "AVI", 0, 0, outputg, 0, true );
129 152
@@ -132,3 +155,5 @@ void CameraMainWindow::init()
132 connect( zoomg, SIGNAL( selected(QAction*) ), this, SLOT( zoomMenuItemClicked(QAction*) ) ); 155 connect( zoomg, SIGNAL( selected(QAction*) ), this, SLOT( zoomMenuItemClicked(QAction*) ) );
156 connect( flipg, SIGNAL( selected(QAction*) ), this, SLOT( flipMenuItemClicked(QAction*) ) );
133 connect( outputg, SIGNAL( selected(QAction*) ), this, SLOT( outputMenuItemClicked(QAction*) ) ); 157 connect( outputg, SIGNAL( selected(QAction*) ), this, SLOT( outputMenuItemClicked(QAction*) ) );
158
134} 159}
@@ -171,2 +196,3 @@ void CameraMainWindow::changeZoom( int zoom )
171 196
197
172void CameraMainWindow::showContextMenu() 198void CameraMainWindow::showContextMenu()
@@ -181,2 +207,6 @@ void CameraMainWindow::showContextMenu()
181 207
208 QPopupMenu flip;
209 flip.setCheckable( true );
210 flipg->addTo( &flip );
211
182 QPopupMenu zoom; 212 QPopupMenu zoom;
@@ -192,2 +222,3 @@ void CameraMainWindow::showContextMenu()
192 m.insertItem( "&Zoom", &zoom ); 222 m.insertItem( "&Zoom", &zoom );
223 m.insertItem( "&Flip", &flip );
193 m.insertItem( "&Quality", &quality ); 224 m.insertItem( "&Quality", &quality );
@@ -203,2 +234,3 @@ void CameraMainWindow::resoMenuItemClicked( QAction* a )
203 odebug << "Capture Resolution now: " << captureX << ", " << captureY << oendl; 234 odebug << "Capture Resolution now: " << captureX << ", " << captureY << oendl;
235 updateCaption();
204} 236}
@@ -210,2 +242,3 @@ void CameraMainWindow::qualityMenuItemClicked( QAction* a )
210 odebug << "Quality now: " << quality << oendl; 242 odebug << "Quality now: " << quality << oendl;
243 updateCaption();
211} 244}
@@ -215,5 +248,25 @@ void CameraMainWindow::zoomMenuItemClicked( QAction* a )
215{ 248{
216 zoom = QString( a->text()[2] ).toInt(); 249 zoom = QString( a->text().at(2) ).toInt();
217 odebug << "Zoom now: " << zoom << oendl; 250 odebug << "Zoom now: " << zoom << oendl;
218 ZCameraIO::instance()->setZoom( zoom ); 251 ZCameraIO::instance()->setZoom( zoom );
252 updateCaption();
253}
254
255
256void CameraMainWindow::flipMenuItemClicked( QAction* a )
257{
258 flip = QString( a->text().at(0) );
259 odebug << "Flip now: " << flip << oendl;
260 if ( flip == "A" )
261 ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP );
262 else if ( flip == "0" )
263 ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP );
264 else if ( flip == "X" )
265 ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP );
266 else if ( flip == "Y" )
267 ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP );
268 else if ( flip == "*" )
269 ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP );
270
271 updateCaption();
219} 272}
@@ -225,2 +278,3 @@ void CameraMainWindow::outputMenuItemClicked( QAction* a )
225 odebug << "Output format now: " << captureFormat << oendl; 278 odebug << "Output format now: " << captureFormat << oendl;
279 updateCaption();
226} 280}
@@ -230,7 +284,21 @@ void CameraMainWindow::shutterClicked()
230{ 284{
231 Global::statusMessage( "CAPTURING..." ); 285 if ( captureFormat != "AVI" ) // capture one photo per shutterClick
232 qApp->processEvents(); 286 {
287 Global::statusMessage( "CAPTURING..." );
288 qApp->processEvents();
233 289
234 odebug << "Shutter has been pressed" << oendl; 290 odebug << "Shutter has been pressed" << oendl;
235 ODevice::inst()->touchSound(); 291 ODevice::inst()->touchSound();
292
293 performCapture( captureFormat );
294 }
295 else // capture video! start with one shutter click and stop with the next
296 {
297 !_capturing ? startVideoCapture() : stopVideoCapture();
298 }
299}
300
301
302void CameraMainWindow::performCapture( const QString& format )
303{
236 QString name; 304 QString name;
@@ -240,3 +308,3 @@ void CameraMainWindow::shutterClicked()
240 QImage im = i.convertDepth( 32 ); 308 QImage im = i.convertDepth( 32 );
241 bool result = im.save( name, captureFormat, quality ); 309 bool result = im.save( name, format, quality );
242 if ( !result ) 310 if ( !result )
@@ -253 +321,115 @@ void CameraMainWindow::shutterClicked()
253 321
322
323void CameraMainWindow::startVideoCapture()
324{
325 //ODevice::inst()->touchSound();
326 ODevice::inst()->setLedState( Led_Mail, Led_BlinkSlow );
327
328 _capturefd = ::open( CAPTUREFILE, O_WRONLY | O_CREAT );
329 if ( _capturefd == -1 )
330 {
331 owarn << "can't open capture file: " << strerror(errno) << oendl;
332 return;
333 }
334
335 _capturebuf = new unsigned char[captureX*captureY*2];
336 _capturing = true;
337 _videopics = 0;
338 updateCaption();
339 _time.start();
340 preview->setRefreshingRate( 1000 );
341 startTimer( 100 ); // too fast but that is ok
342}
343
344
345void CameraMainWindow::timerEvent( QTimerEvent* )
346{
347 if ( !_capturing )
348 {
349 owarn << "timer event in CameraMainWindow without capturing video ?" << oendl;
350 return;
351 }
352
353 ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, _capturebuf );
354 _videopics++;
355 ::write( _capturefd, _capturebuf, captureX*captureY*2 );
356 setCaption( QString().sprintf( "Capturing %dx%d @ %.2f fps %d",
357 captureX, captureY, 1000.0 / (_time.elapsed()/_videopics), _videopics ) );
358}
359
360
361void CameraMainWindow::stopVideoCapture()
362{
363 killTimers();
364 //ODevice::inst()->touchSound();
365 ODevice::inst()->setLedState( Led_Mail, Led_Off );
366 _capturing = false;
367 updateCaption();
368 ::close( _capturefd );
369
370 //postProcessVideo();
371
372 #ifndef QT_NO_DEBUG
373 preview->setRefreshingRate( 1500 );
374 #else
375 preview->setRefreshingRate( 200 );
376 #endif
377
378 //delete[] _capturebuf; //FIXME: close memory leak
379}
380
381void CameraMainWindow::postProcessVideo()
382{
383 preview->setRefreshingRate( 0 );
384
385 /*
386
387 QDialog* fr = new QDialog( this, "splash" ); //, false, QWidget::WStyle_NoBorder | QWidget::WStyle_Customize );
388 fr->setCaption( "Please wait..." );
389 QVBoxLayout* box = new QVBoxLayout( fr, 2, 2 );
390 QProgressBar* bar = new QProgressBar( fr );
391 bar->setCenterIndicator( true );
392 bar->setTotalSteps( _videopics-1 );
393 QLabel* label = new QLabel( "Post processing frame bla/bla", fr );
394 box->addWidget( bar );
395 box->addWidget( label );
396 fr->show();
397 qApp->processEvents();
398
399 for ( int i = 0; i < _videopics; ++i )
400 {
401 label->setText( QString().sprintf( "Post processing frame %d / %d", i+1, _videopics ) );
402 bar->setProgress( i );
403 qApp->processEvents();
404 }
405
406 */
407
408 int infd = ::open( CAPTUREFILE, O_RDONLY );
409 if ( infd == -1 )
410 {
411 owarn << "couldn't open capture file: " << strerror(errno) << oendl;
412 return;
413 }
414
415 int outfd = ::open( "/tmp/output.avi", O_WRONLY );
416 if ( outfd == -1 )
417 {
418 owarn << "couldn't open output file: " << strerror(errno) << oendl;
419 return;
420 }
421
422
423
424
425}
426
427void CameraMainWindow::updateCaption()
428{
429 if ( !_capturing )
430 setCaption( QString().sprintf( "Opie-Camera: %dx%d %s q%d z%d (%s)", captureX, captureY, (const char*) captureFormat.lower(), quality, zoom, (const char*) flip ) );
431 else
432 setCaption( "Opie-Camera: => CAPTURING <=" );
433}
434
435
diff --git a/noncore/multimedia/camera/mainwindow.h b/noncore/multimedia/camera/mainwindow.h
index 7a12452..ad8d1b1 100644
--- a/noncore/multimedia/camera/mainwindow.h
+++ b/noncore/multimedia/camera/mainwindow.h
@@ -22,2 +22,3 @@
22#include <qpixmap.h> 22#include <qpixmap.h>
23#include <qdatetime.h>
23 24
@@ -26,2 +27,3 @@ class QActionGroup;
26class QIconSet; 27class QIconSet;
28class QTimerEvent;
27class QToolButton; 29class QToolButton;
@@ -47,2 +49,3 @@ class CameraMainWindow: public QMainWindow
47 void zoomMenuItemClicked( QAction* ); 49 void zoomMenuItemClicked( QAction* );
50 void flipMenuItemClicked( QAction* );
48 void outputMenuItemClicked( QAction* ); 51 void outputMenuItemClicked( QAction* );
@@ -50,4 +53,12 @@ class CameraMainWindow: public QMainWindow
50 53
54 void updateCaption();
55
51 protected: 56 protected:
52 void init(); 57 void init();
58 void startVideoCapture();
59 void stopVideoCapture();
60 void postProcessVideo();
61 void performCapture( const QString& );
62
63 virtual void timerEvent( QTimerEvent* );
53 64
@@ -61,4 +72,6 @@ class CameraMainWindow: public QMainWindow
61 QActionGroup* zoomg; 72 QActionGroup* zoomg;
73 QActionGroup* flipg;
62 QActionGroup* outputg; 74 QActionGroup* outputg;
63 75
76 QString flip;
64 int quality; 77 int quality;
@@ -69,3 +82,9 @@ class CameraMainWindow: public QMainWindow
69 82
83 bool _capturing;
70 int _pics; 84 int _pics;
85
86 QTime _time;
87 int _videopics;
88 int _capturefd;
89 unsigned char* _capturebuf;
71}; 90};
diff --git a/noncore/multimedia/camera/previewwidget.cpp b/noncore/multimedia/camera/previewwidget.cpp
index f87dcc9..08330d0 100644
--- a/noncore/multimedia/camera/previewwidget.cpp
+++ b/noncore/multimedia/camera/previewwidget.cpp
@@ -74 +74,15 @@ void PreviewWidget::mousePressEvent( QMouseEvent* )
74 74
75
76void PreviewWidget::setRefreshingRate( int ms )
77{
78 killTimers();
79 if ( ms )
80 startTimer( ms );
81}
82
83
84void PreviewWidget::refresh()
85{
86 QTimerEvent t( 10 ); // event id is meaningless in this case
87 timerEvent( &t );
88}
diff --git a/noncore/multimedia/camera/previewwidget.h b/noncore/multimedia/camera/previewwidget.h
index dada301..d37f80f 100644
--- a/noncore/multimedia/camera/previewwidget.h
+++ b/noncore/multimedia/camera/previewwidget.h
@@ -33,2 +33,5 @@ class PreviewWidget: public QLabel
33 33
34 void setRefreshingRate( int ms );
35 void refresh();
36
34 protected: 37 protected:
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()
46ZCameraIO::ZCameraIO() 46ZCameraIO::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
168void ZCameraIO::setFlip( int flip )
169{
170 _flip = flip;
171}
172
173
157void ZCameraIO::clearShutterLatch() 174void 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
305void 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
diff --git a/noncore/multimedia/camera/zcameraio.h b/noncore/multimedia/camera/zcameraio.h
index edce143..3352a5e 100644
--- a/noncore/multimedia/camera/zcameraio.h
+++ b/noncore/multimedia/camera/zcameraio.h
@@ -35,3 +35,4 @@ class ZCameraIO : public QObject
35 XNOFLIP = 0, XFLIP = 4, 35 XNOFLIP = 0, XFLIP = 4,
36 YNOFLIP = 0, YFLIP = 8 36 YNOFLIP = 0, YFLIP = 8,
37 AUTOMATICFLIP = -1
37 }; 38 };
@@ -43,2 +44,3 @@ class ZCameraIO : public QObject
43 void setReadMode( int = IMAGE | XFLIP | YFLIP ); 44 void setReadMode( int = IMAGE | XFLIP | YFLIP );
45 void setFlip( int flip );
44 46
@@ -49,4 +51,4 @@ class ZCameraIO : public QObject
49 51
50 bool snapshot( unsigned char* ); 52 bool snapshot( QImage* image );
51 bool snapshot( QImage* ); 53 bool snapshot( unsigned char* buf );
52 54
@@ -56,2 +58,3 @@ class ZCameraIO : public QObject
56 void captureFrame( int w, int h, int zoom, QImage* image ); 58 void captureFrame( int w, int h, int zoom, QImage* image );
59 void captureFrame( int w, int h, int zoom, unsigned char* buf );
57 60
@@ -70,2 +73,3 @@ class ZCameraIO : public QObject
70 char _status[4]; 73 char _status[4];
74 bool _pressed;
71 static ZCameraIO* _instance; 75 static ZCameraIO* _instance;
@@ -74,2 +78,3 @@ class ZCameraIO : public QObject
74 int _zoom; 78 int _zoom;
79 int _flip;
75 bool _rot; 80 bool _rot;