Diffstat (limited to 'noncore/multimedia/camera/zcameraio.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/camera/zcameraio.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/noncore/multimedia/camera/zcameraio.cpp b/noncore/multimedia/camera/zcameraio.cpp new file mode 100644 index 0000000..aa6cbe3 --- a/dev/null +++ b/noncore/multimedia/camera/zcameraio.cpp | |||
@@ -0,0 +1,56 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #include "zcameraio.h" | ||
17 | |||
18 | #include <sys/types.h> | ||
19 | #include <sys/stat.h> | ||
20 | #include <errno.h> | ||
21 | #include <string.h> | ||
22 | #include <fcntl.h> | ||
23 | #include <unistd.h> | ||
24 | |||
25 | #include <qimage.h> | ||
26 | |||
27 | #include <opie2/odebug.h> | ||
28 | |||
29 | ZCameraIO::ZCameraIO() | ||
30 | { | ||
31 | _driver = open( "/dev/sharp_zdc", O_RDWR ); | ||
32 | if ( _driver == -1 ) | ||
33 | oerr << "Can't open camera driver: " << strerror(errno) << oendl; | ||
34 | |||
35 | }; | ||
36 | |||
37 | |||
38 | ZCameraIO::~ZCameraIO() | ||
39 | { | ||
40 | if ( _driver != -1 ) | ||
41 | close( _driver ); | ||
42 | } | ||
43 | |||
44 | |||
45 | bool ZCameraIO::snapshot( QImage* img ) | ||
46 | { | ||
47 | char buf[76800]; | ||
48 | |||
49 | write( _driver, "M=13", 4 ); | ||
50 | write( _driver, "R=240,160,256,480", 17 ); | ||
51 | write( _driver, "M=12", 4 ); | ||
52 | |||
53 | int result = read( _driver, &buf, sizeof buf ); | ||
54 | |||
55 | return result == sizeof buf; | ||
56 | } | ||