summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-04-01 23:19:16 (UTC)
committer mickeyl <mickeyl>2003-04-01 23:19:16 (UTC)
commit911a05806c4cce85750f3bd9bca84e18162cb739 (patch) (unidiff)
treed5bbed42b991968852aa30e702deda95fa7b1393
parent3497616220db68ea4105880c40c4c542d9b5228d (diff)
downloadopie-911a05806c4cce85750f3bd9bca84e18162cb739.zip
opie-911a05806c4cce85750f3bd9bca84e18162cb739.tar.gz
opie-911a05806c4cce85750f3bd9bca84e18162cb739.tar.bz2
figured out how to get binary RAW data into a QImage
actual capturing is now only a footstep away :-D
Diffstat (more/less context) (ignore 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
@@ -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
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
@@ -18,10 +18,9 @@
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{
@@ -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
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
@@ -42,8 +45,10 @@ ZCameraIO::~ZCameraIO()
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 );
@@ -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