-rw-r--r-- | noncore/multimedia/camera/mainwindow.cpp | 11 | ||||
-rw-r--r-- | noncore/multimedia/camera/mainwindow.h | 6 | ||||
-rw-r--r-- | noncore/multimedia/camera/zcameraio.cpp | 35 | ||||
-rw-r--r-- | noncore/multimedia/camera/zcameraio.h | 3 |
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 | |||
@@ -14,6 +14,7 @@ | |||
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> |
@@ -26,7 +27,7 @@ CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags | |||
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() ) ); |
@@ -45,6 +46,12 @@ CameraMainWindow::~CameraMainWindow() | |||
45 | 46 | ||
46 | void CameraMainWindow::clickedSnapShot() | 47 | void 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 | |||
@@ -18,10 +18,9 @@ | |||
18 | 18 | ||
19 | #include <qmainwindow.h> | 19 | #include <qmainwindow.h> |
20 | 20 | ||
21 | class Wellenreiter; | ||
22 | class WellenreiterConfigWindow; | ||
23 | class QIconSet; | 21 | class QIconSet; |
24 | class QToolButton; | 22 | class QToolButton; |
23 | class QLabel; | ||
25 | 24 | ||
26 | class CameraMainWindow: public QMainWindow | 25 | class CameraMainWindow: public QMainWindow |
27 | { | 26 | { |
@@ -35,6 +34,9 @@ class CameraMainWindow: public QMainWindow | |||
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 | |||
@@ -26,12 +26,15 @@ | |||
26 | 26 | ||
27 | #include <opie2/odebug.h> | 27 | #include <opie2/odebug.h> |
28 | 28 | ||
29 | ZCameraIO* ZCameraIO::_instance = 0; | ||
30 | |||
29 | ZCameraIO::ZCameraIO() | 31 | ZCameraIO::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 | ||
@@ -42,8 +45,10 @@ ZCameraIO::~ZCameraIO() | |||
42 | } | 45 | } |
43 | 46 | ||
44 | 47 | ||
45 | bool ZCameraIO::snapshot( QImage* img ) | 48 | bool 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 ); |
@@ -53,4 +58,32 @@ bool ZCameraIO::snapshot( QImage* img ) | |||
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 | |||
@@ -25,11 +25,12 @@ class 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 |