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
@@ -16,2 +16,3 @@
16#include "mainwindow.h" 16#include "mainwindow.h"
17#include "zcameraio.h"
17 18
@@ -28,3 +29,3 @@ CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags
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 ) );
@@ -47,3 +48,9 @@ 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}
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
@@ -20,6 +20,5 @@
20 20
21class Wellenreiter;
22class WellenreiterConfigWindow;
23class QIconSet; 21class QIconSet;
24class QToolButton; 22class QToolButton;
23class QLabel;
25 24
@@ -37,2 +36,5 @@ class CameraMainWindow: public QMainWindow
37 void clickedSnapShot(); 36 void clickedSnapShot();
37
38 private:
39 QLabel* l;
38}; 40};
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
@@ -28,2 +28,4 @@
28 28
29ZCameraIO* ZCameraIO::_instance = 0;
30
29ZCameraIO::ZCameraIO() 31ZCameraIO::ZCameraIO()
@@ -34,2 +36,3 @@ ZCameraIO::ZCameraIO()
34 36
37 ZCameraIO::_instance = this;
35}; 38};
@@ -44,4 +47,6 @@ ZCameraIO::~ZCameraIO()
44 47
45bool ZCameraIO::snapshot( QImage* img ) 48bool ZCameraIO::snapshot( QImage* image )
46{ 49{
50 /*
51
47 char buf[76800]; 52 char buf[76800];
@@ -55,2 +60,30 @@ bool ZCameraIO::snapshot( QImage* img )
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
@@ -27,4 +27,4 @@ class ZCameraIO
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
@@ -32,2 +32,3 @@ class ZCameraIO
32 int _driver; 32 int _driver;
33 static ZCameraIO* _instance;
33}; 34};