Diffstat (limited to 'noncore/multimedia/camera/zcameraio.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/camera/zcameraio.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
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 | } |