summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/camera/mainwindow.cpp11
-rw-r--r--noncore/multimedia/camera/mainwindow.h6
-rw-r--r--noncore/multimedia/camera/zcameraio.cpp35
-rw-r--r--noncore/multimedia/camera/zcameraio.h3
4 files changed, 49 insertions, 6 deletions
diff --git a/noncore/multimedia/camera/mainwindow.cpp b/noncore/multimedia/camera/mainwindow.cpp
index 6431dfa..2cca9f9 100644
--- a/noncore/multimedia/camera/mainwindow.cpp
+++ b/noncore/multimedia/camera/mainwindow.cpp
@@ -5,46 +5,53 @@
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "mainwindow.h" 16#include "mainwindow.h"
17#include "zcameraio.h"
17 18
18#include <qvbox.h> 19#include <qvbox.h>
19#include <qpushbutton.h> 20#include <qpushbutton.h>
20#include <qlabel.h> 21#include <qlabel.h>
21 22
22#include <qpe/resource.h> 23#include <qpe/resource.h>
23#include <opie/ofiledialog.h> 24#include <opie/ofiledialog.h>
24 25
25CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) 26CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f )
26 :QMainWindow( parent, name, f ) 27 :QMainWindow( parent, name, f )
27{ 28{
28 QVBox* v = new QVBox( this ); 29 QVBox* v = new QVBox( this );
29 QLabel* l = new QLabel( v ); 30 l = new QLabel( v );
30 l->setFixedSize( QSize( 240, 160 ) ); 31 l->setFixedSize( QSize( 240, 160 ) );
31 QPushButton* p = new QPushButton( "Snapshot", v ); 32 QPushButton* p = new QPushButton( "Snapshot", v );
32 connect( p, SIGNAL( clicked() ), this, SLOT( clickedSnapShot() ) ); 33 connect( p, SIGNAL( clicked() ), this, SLOT( clickedSnapShot() ) );
33 v->show(); 34 v->show();
34 l->show(); 35 l->show();
35 p->show(); 36 p->show();
36 setCentralWidget( v ); 37 setCentralWidget( v );
37 38
38}; 39};
39 40
40 41
41CameraMainWindow::~CameraMainWindow() 42CameraMainWindow::~CameraMainWindow()
42{ 43{
43} 44}
44 45
45 46
46void CameraMainWindow::clickedSnapShot() 47void CameraMainWindow::clickedSnapShot()
47{ 48{
48 qDebug( "Hello!" ); 49 QImage i;
50 QPixmap p;
51 if ( ZCameraIO::instance()->snapshot( &i ) )
52 {
53 p.convertFromImage( i );
54 l->setPixmap( p );
55 }
49} 56}
50 57
diff --git a/noncore/multimedia/camera/mainwindow.h b/noncore/multimedia/camera/mainwindow.h
index a349652..521107b 100644
--- a/noncore/multimedia/camera/mainwindow.h
+++ b/noncore/multimedia/camera/mainwindow.h
@@ -9,32 +9,34 @@
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef MAINWINDOW_H 16#ifndef MAINWINDOW_H
17#define MAINWINDOW_H 17#define MAINWINDOW_H
18 18
19#include <qmainwindow.h> 19#include <qmainwindow.h>
20 20
21class Wellenreiter;
22class WellenreiterConfigWindow;
23class QIconSet; 21class QIconSet;
24class QToolButton; 22class QToolButton;
23class QLabel;
25 24
26class CameraMainWindow: public QMainWindow 25class CameraMainWindow: public QMainWindow
27{ 26{
28 Q_OBJECT 27 Q_OBJECT
29 28
30 public: 29 public:
31 CameraMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 ); 30 CameraMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 );
32 virtual ~CameraMainWindow(); 31 virtual ~CameraMainWindow();
33 32
34 protected: 33 protected:
35 34
36 public slots: 35 public slots:
37 void clickedSnapShot(); 36 void clickedSnapShot();
37
38 private:
39 QLabel* l;
38}; 40};
39 41
40#endif 42#endif
diff --git a/noncore/multimedia/camera/zcameraio.cpp b/noncore/multimedia/camera/zcameraio.cpp
index aa6cbe3..e74136f 100644
--- a/noncore/multimedia/camera/zcameraio.cpp
+++ b/noncore/multimedia/camera/zcameraio.cpp
@@ -17,40 +17,73 @@
17 17
18#include <sys/types.h> 18#include <sys/types.h>
19#include <sys/stat.h> 19#include <sys/stat.h>
20#include <errno.h> 20#include <errno.h>
21#include <string.h> 21#include <string.h>
22#include <fcntl.h> 22#include <fcntl.h>
23#include <unistd.h> 23#include <unistd.h>
24 24
25#include <qimage.h> 25#include <qimage.h>
26 26
27#include <opie2/odebug.h> 27#include <opie2/odebug.h>
28 28
29ZCameraIO* ZCameraIO::_instance = 0;
30
29ZCameraIO::ZCameraIO() 31ZCameraIO::ZCameraIO()
30{ 32{
31 _driver = open( "/dev/sharp_zdc", O_RDWR ); 33 _driver = open( "/dev/sharp_zdc", O_RDWR );
32 if ( _driver == -1 ) 34 if ( _driver == -1 )
33 oerr << "Can't open camera driver: " << strerror(errno) << oendl; 35 oerr << "Can't open camera driver: " << strerror(errno) << oendl;
34 36
37 ZCameraIO::_instance = this;
35}; 38};
36 39
37 40
38ZCameraIO::~ZCameraIO() 41ZCameraIO::~ZCameraIO()
39{ 42{
40 if ( _driver != -1 ) 43 if ( _driver != -1 )
41 close( _driver ); 44 close( _driver );
42} 45}
43 46
44 47
45bool ZCameraIO::snapshot( QImage* img ) 48bool ZCameraIO::snapshot( QImage* image )
46{ 49{
50 /*
51
47 char buf[76800]; 52 char buf[76800];
48 53
49 write( _driver, "M=13", 4 ); 54 write( _driver, "M=13", 4 );
50 write( _driver, "R=240,160,256,480", 17 ); 55 write( _driver, "R=240,160,256,480", 17 );
51 write( _driver, "M=12", 4 ); 56 write( _driver, "M=12", 4 );
52 57
53 int result = read( _driver, &buf, sizeof buf ); 58 int result = read( _driver, &buf, sizeof buf );
54 59
55 return result == sizeof buf; 60 return result == sizeof buf;
61
62 */
63
64 uchar buf[76800];
65 uchar* bp = buf;
66 uchar* p;
67
68
69 int fd = open( "/tmp/cam", O_RDONLY );
70 if ( read( fd, buf, sizeof buf ) != sizeof buf )
71 qDebug( "WARNING: couldn't read image!" );
72
73 image->create( 240, 160, 16 );
74 for ( int i = 0; i < 160; ++i )
75 {
76 p = image->scanLine( i );
77 for ( int j = 0; j < 240; j++ )
78 {
79 *p = *bp;
80 p++;
81 bp++;
82 *p = *bp;
83 p++;
84 bp++;
85 }
86 }
87
88 return true;
56} 89}
diff --git a/noncore/multimedia/camera/zcameraio.h b/noncore/multimedia/camera/zcameraio.h
index 817d3b4..1690aa6 100644
--- a/noncore/multimedia/camera/zcameraio.h
+++ b/noncore/multimedia/camera/zcameraio.h
@@ -16,20 +16,21 @@
16#ifndef ZCAMERAIO_H 16#ifndef ZCAMERAIO_H
17#define ZCAMERAIO_H 17#define ZCAMERAIO_H
18 18
19class QImage; 19class QImage;
20 20
21class ZCameraIO 21class ZCameraIO
22{ 22{
23 public: 23 public:
24 ZCameraIO(); 24 ZCameraIO();
25 virtual ~ZCameraIO(); 25 virtual ~ZCameraIO();
26 26
27 bool isOpen() const { return _driver != -1; }; 27 bool isOpen() const { return _driver != -1; };
28
29 bool snapshot( QImage* ); 28 bool snapshot( QImage* );
29 static ZCameraIO* instance() { return _instance; };
30 30
31 private: 31 private:
32 int _driver; 32 int _driver;
33 static ZCameraIO* _instance;
33}; 34};
34 35
35#endif 36#endif