-rw-r--r-- | noncore/multimedia/camera/.cvsignore | 4 | ||||
-rw-r--r-- | noncore/multimedia/camera/camera.pro | 2 | ||||
-rw-r--r-- | noncore/multimedia/camera/mainwindow.cpp | 41 | ||||
-rw-r--r-- | noncore/multimedia/camera/mainwindow.h | 7 | ||||
-rw-r--r-- | noncore/multimedia/camera/mainwindowbase.ui | 246 | ||||
-rw-r--r-- | noncore/multimedia/camera/previewwidget.cpp | 21 | ||||
-rw-r--r-- | noncore/multimedia/camera/previewwidget.h | 4 | ||||
-rw-r--r-- | noncore/multimedia/camera/zcameraio.cpp | 24 |
8 files changed, 87 insertions, 262 deletions
diff --git a/noncore/multimedia/camera/.cvsignore b/noncore/multimedia/camera/.cvsignore index d89e3af..737c5b2 100644 --- a/noncore/multimedia/camera/.cvsignore +++ b/noncore/multimedia/camera/.cvsignore | |||
@@ -1,5 +1,5 @@ | |||
1 | moc | ||
2 | obj | ||
1 | config.in | 3 | config.in |
2 | mainwindowbase.h | ||
3 | mainwindowbase.cpp | ||
4 | Makefile | 4 | Makefile |
5 | 5 | ||
diff --git a/noncore/multimedia/camera/camera.pro b/noncore/multimedia/camera/camera.pro index 2d1faa3..16da0c9 100644 --- a/noncore/multimedia/camera/camera.pro +++ b/noncore/multimedia/camera/camera.pro | |||
@@ -1,23 +1,23 @@ | |||
1 | MOC_DIR = ./moc | 1 | MOC_DIR = ./moc |
2 | OBJECTS_DIR = ./obj | 2 | OBJECTS_DIR = ./obj |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | TEMPLATE = app | 4 | TEMPLATE = app |
5 | CONFIG = qt warn_on debug | 5 | CONFIG = qt warn_on debug |
6 | 6 | ||
7 | HEADERS = zcameraio.h \ | 7 | HEADERS = zcameraio.h \ |
8 | previewwidget.h \ | 8 | previewwidget.h \ |
9 | mainwindow.h | 9 | mainwindow.h |
10 | 10 | ||
11 | SOURCES = zcameraio.cpp \ | 11 | SOURCES = zcameraio.cpp \ |
12 | previewwidget.cpp \ | 12 | previewwidget.cpp \ |
13 | mainwindow.cpp \ | 13 | mainwindow.cpp \ |
14 | main.cpp | 14 | main.cpp |
15 | 15 | ||
16 | INCLUDEPATH += $(OPIEDIR)/include | 16 | INCLUDEPATH += $(OPIEDIR)/include |
17 | DEPENDPATH += $(OPIEDIR)/include | 17 | DEPENDPATH += $(OPIEDIR)/include |
18 | LIBS += -lqpe -lopiecore2 | 18 | LIBS += -lqpe -lopiecore2 |
19 | INTERFACES = mainwindowbase.ui | 19 | INTERFACES = |
20 | TARGET = opiecam | 20 | TARGET = opiecam |
21 | 21 | ||
22 | include ( $(OPIEDIR)/include.pro ) | 22 | include ( $(OPIEDIR)/include.pro ) |
23 | 23 | ||
diff --git a/noncore/multimedia/camera/mainwindow.cpp b/noncore/multimedia/camera/mainwindow.cpp index 8578bce..7080e63 100644 --- a/noncore/multimedia/camera/mainwindow.cpp +++ b/noncore/multimedia/camera/mainwindow.cpp | |||
@@ -1,60 +1,89 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #include "mainwindow.h" | 16 | #include "mainwindow.h" |
17 | #include "mainwindowbase.h" | 17 | #include "previewwidget.h" |
18 | #include "zcameraio.h" | 18 | #include "zcameraio.h" |
19 | 19 | ||
20 | #include <qvbox.h> | 20 | #include <qvbox.h> |
21 | #include <qcombobox.h> | 21 | #include <qcombobox.h> |
22 | #include <qdatastream.h> | ||
22 | #include <qpushbutton.h> | 23 | #include <qpushbutton.h> |
23 | #include <qlabel.h> | 24 | #include <qlabel.h> |
24 | #include <qdirectpainter_qws.h> | 25 | #include <qdirectpainter_qws.h> |
25 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qcopenvelope_qws.h> | ||
26 | #include <opie/ofiledialog.h> | 28 | #include <opie/ofiledialog.h> |
27 | 29 | ||
30 | #include <opie2/odebug.h> | ||
31 | |||
28 | #include <assert.h> | 32 | #include <assert.h> |
29 | 33 | ||
30 | CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) | 34 | CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) |
31 | :QMainWindow( parent, name, f ) | 35 | :QMainWindow( parent, name, f ) |
32 | { | 36 | { |
33 | mw = new MainWindowBase( this, "main widget" ); | 37 | _rotation = 270; //TODO: grab these from the actual settings |
34 | ZCameraIO::instance()->setCaptureFrame( 240, 160, 256 ); | 38 | |
35 | setCentralWidget( mw ); | 39 | preview = new PreviewWidget( this, "camera preview widget" ); |
36 | mw->show(); | 40 | //setCentralWidget( preview ); <--- don't do this! |
41 | preview->resize( QSize( 240, 288 ) ); | ||
42 | preview->show(); | ||
43 | |||
44 | // construct a System Channel to receive setRotation messages | ||
45 | _sysChannel = new QCopChannel( "QPE/System", this ); | ||
46 | connect( _sysChannel, SIGNAL( received( const QCString&, const QByteArray& ) ), | ||
47 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); | ||
37 | 48 | ||
38 | connect( mw->zoom, SIGNAL( activated( int ) ), this, SLOT( changeZoom(int) ) ); | ||
39 | }; | 49 | }; |
40 | 50 | ||
41 | 51 | ||
42 | CameraMainWindow::~CameraMainWindow() | 52 | CameraMainWindow::~CameraMainWindow() |
43 | { | 53 | { |
44 | } | 54 | } |
45 | 55 | ||
46 | 56 | ||
57 | void CameraMainWindow::systemMessage( const QCString& msg, const QByteArray& data ) | ||
58 | { | ||
59 | QDataStream stream( data, IO_ReadOnly ); | ||
60 | odebug << "received system message: " << msg << oendl; | ||
61 | if ( msg == "setCurrentRotation(int)" ) | ||
62 | { | ||
63 | stream >> _rotation; | ||
64 | odebug << "received setCurrentRotation(" << _rotation << ")" << oendl; | ||
65 | |||
66 | switch ( _rotation ) | ||
67 | { | ||
68 | case 270: preview->resize( QSize( 240, 288 ) ); break; | ||
69 | case 180: preview->resize( QSize( 320, 208 ) ); break; | ||
70 | default: assert( 0 ); // not yet handled | ||
71 | } | ||
72 | } | ||
73 | } | ||
74 | |||
75 | |||
47 | void CameraMainWindow::changeZoom( int zoom ) | 76 | void CameraMainWindow::changeZoom( int zoom ) |
48 | { | 77 | { |
49 | int z; | 78 | int z; |
50 | switch ( zoom ) | 79 | switch ( zoom ) |
51 | { | 80 | { |
52 | case 0: z = 128; break; | 81 | case 0: z = 128; break; |
53 | case 1: z = 256; break; | 82 | case 1: z = 256; break; |
54 | case 2: z = 512; break; | 83 | case 2: z = 512; break; |
55 | default: assert( 0 ); break; | 84 | default: assert( 0 ); break; |
56 | } | 85 | } |
57 | 86 | ||
58 | ZCameraIO::instance()->setCaptureFrame( 240, 160, z ); | 87 | ZCameraIO::instance()->setCaptureFrame( 240, 160, z ); |
59 | } | 88 | } |
60 | 89 | ||
diff --git a/noncore/multimedia/camera/mainwindow.h b/noncore/multimedia/camera/mainwindow.h index 7ccdcf8..cc12840 100644 --- a/noncore/multimedia/camera/mainwindow.h +++ b/noncore/multimedia/camera/mainwindow.h | |||
@@ -1,46 +1,51 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #ifndef MAINWINDOW_H | 16 | #ifndef MAINWINDOW_H |
17 | #define MAINWINDOW_H | 17 | #define MAINWINDOW_H |
18 | 18 | ||
19 | #include <qmainwindow.h> | 19 | #include <qmainwindow.h> |
20 | #include <qdatetime.h> | 20 | #include <qdatetime.h> |
21 | #include <qimage.h> | 21 | #include <qimage.h> |
22 | #include <qpixmap.h> | 22 | #include <qpixmap.h> |
23 | 23 | ||
24 | class QIconSet; | 24 | class QIconSet; |
25 | class QToolButton; | 25 | class QToolButton; |
26 | class QLabel; | 26 | class QLabel; |
27 | class MainWindowBase; | 27 | class MainWindowBase; |
28 | class QCopChannel; | ||
29 | class PreviewWidget; | ||
28 | 30 | ||
29 | class CameraMainWindow: public QMainWindow | 31 | class CameraMainWindow: public QMainWindow |
30 | { | 32 | { |
31 | Q_OBJECT | 33 | Q_OBJECT |
32 | 34 | ||
33 | public: | 35 | public: |
34 | CameraMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 ); | 36 | CameraMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 ); |
35 | virtual ~CameraMainWindow(); | 37 | virtual ~CameraMainWindow(); |
36 | 38 | ||
37 | public slots: | 39 | public slots: |
38 | void changeZoom( int ); | 40 | void changeZoom( int ); |
41 | void systemMessage( const QCString&, const QByteArray& ); | ||
39 | 42 | ||
40 | protected: | 43 | protected: |
41 | 44 | ||
42 | private: | 45 | private: |
43 | MainWindowBase* mw; | 46 | PreviewWidget* preview; |
47 | int _rotation; | ||
48 | QCopChannel* _sysChannel; | ||
44 | }; | 49 | }; |
45 | 50 | ||
46 | #endif | 51 | #endif |
diff --git a/noncore/multimedia/camera/mainwindowbase.ui b/noncore/multimedia/camera/mainwindowbase.ui deleted file mode 100644 index 8da884a..0000000 --- a/noncore/multimedia/camera/mainwindowbase.ui +++ b/dev/null | |||
@@ -1,246 +0,0 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>MainWindowBase</class> | ||
3 | <widget> | ||
4 | <class>QWidget</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>MainWindowBase</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>242</width> | ||
15 | <height>329</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Form1</string> | ||
21 | </property> | ||
22 | <property> | ||
23 | <name>layoutMargin</name> | ||
24 | </property> | ||
25 | <property> | ||
26 | <name>layoutSpacing</name> | ||
27 | </property> | ||
28 | <grid> | ||
29 | <property stdset="1"> | ||
30 | <name>margin</name> | ||
31 | <number>0</number> | ||
32 | </property> | ||
33 | <property stdset="1"> | ||
34 | <name>spacing</name> | ||
35 | <number>2</number> | ||
36 | </property> | ||
37 | <widget row="1" column="0" > | ||
38 | <class>QLayoutWidget</class> | ||
39 | <property stdset="1"> | ||
40 | <name>name</name> | ||
41 | <cstring>Layout1</cstring> | ||
42 | </property> | ||
43 | <hbox> | ||
44 | <property stdset="1"> | ||
45 | <name>margin</name> | ||
46 | <number>0</number> | ||
47 | </property> | ||
48 | <property stdset="1"> | ||
49 | <name>spacing</name> | ||
50 | <number>6</number> | ||
51 | </property> | ||
52 | <widget> | ||
53 | <class>QLabel</class> | ||
54 | <property stdset="1"> | ||
55 | <name>name</name> | ||
56 | <cstring>TextLabel1</cstring> | ||
57 | </property> | ||
58 | <property stdset="1"> | ||
59 | <name>text</name> | ||
60 | <string>Reso:</string> | ||
61 | </property> | ||
62 | </widget> | ||
63 | <widget> | ||
64 | <class>QComboBox</class> | ||
65 | <item> | ||
66 | <property> | ||
67 | <name>text</name> | ||
68 | <string>240x160</string> | ||
69 | </property> | ||
70 | </item> | ||
71 | <item> | ||
72 | <property> | ||
73 | <name>text</name> | ||
74 | <string>480x320</string> | ||
75 | </property> | ||
76 | </item> | ||
77 | <property stdset="1"> | ||
78 | <name>name</name> | ||
79 | <cstring>resolution</cstring> | ||
80 | </property> | ||
81 | </widget> | ||
82 | <widget> | ||
83 | <class>QLabel</class> | ||
84 | <property stdset="1"> | ||
85 | <name>name</name> | ||
86 | <cstring>TextLabel2</cstring> | ||
87 | </property> | ||
88 | <property stdset="1"> | ||
89 | <name>text</name> | ||
90 | <string>Zoom:</string> | ||
91 | </property> | ||
92 | </widget> | ||
93 | <widget> | ||
94 | <class>QComboBox</class> | ||
95 | <item> | ||
96 | <property> | ||
97 | <name>text</name> | ||
98 | <string>Half</string> | ||
99 | </property> | ||
100 | </item> | ||
101 | <item> | ||
102 | <property> | ||
103 | <name>text</name> | ||
104 | <string>Full</string> | ||
105 | </property> | ||
106 | </item> | ||
107 | <item> | ||
108 | <property> | ||
109 | <name>text</name> | ||
110 | <string>Double</string> | ||
111 | </property> | ||
112 | </item> | ||
113 | <property stdset="1"> | ||
114 | <name>name</name> | ||
115 | <cstring>zoom</cstring> | ||
116 | </property> | ||
117 | </widget> | ||
118 | </hbox> | ||
119 | </widget> | ||
120 | <widget row="2" column="0" > | ||
121 | <class>QLayoutWidget</class> | ||
122 | <property stdset="1"> | ||
123 | <name>name</name> | ||
124 | <cstring>Layout2</cstring> | ||
125 | </property> | ||
126 | <hbox> | ||
127 | <property stdset="1"> | ||
128 | <name>margin</name> | ||
129 | <number>0</number> | ||
130 | </property> | ||
131 | <property stdset="1"> | ||
132 | <name>spacing</name> | ||
133 | <number>6</number> | ||
134 | </property> | ||
135 | <spacer> | ||
136 | <property> | ||
137 | <name>name</name> | ||
138 | <cstring>Spacer1</cstring> | ||
139 | </property> | ||
140 | <property stdset="1"> | ||
141 | <name>orientation</name> | ||
142 | <enum>Horizontal</enum> | ||
143 | </property> | ||
144 | <property stdset="1"> | ||
145 | <name>sizeType</name> | ||
146 | <enum>Expanding</enum> | ||
147 | </property> | ||
148 | <property> | ||
149 | <name>sizeHint</name> | ||
150 | <size> | ||
151 | <width>20</width> | ||
152 | <height>20</height> | ||
153 | </size> | ||
154 | </property> | ||
155 | </spacer> | ||
156 | <widget> | ||
157 | <class>QPushButton</class> | ||
158 | <property stdset="1"> | ||
159 | <name>name</name> | ||
160 | <cstring>PushButton1</cstring> | ||
161 | </property> | ||
162 | <property stdset="1"> | ||
163 | <name>text</name> | ||
164 | <string>Take Photo</string> | ||
165 | </property> | ||
166 | <property stdset="1"> | ||
167 | <name>default</name> | ||
168 | <bool>true</bool> | ||
169 | </property> | ||
170 | </widget> | ||
171 | <spacer> | ||
172 | <property> | ||
173 | <name>name</name> | ||
174 | <cstring>Spacer2</cstring> | ||
175 | </property> | ||
176 | <property stdset="1"> | ||
177 | <name>orientation</name> | ||
178 | <enum>Horizontal</enum> | ||
179 | </property> | ||
180 | <property stdset="1"> | ||
181 | <name>sizeType</name> | ||
182 | <enum>Expanding</enum> | ||
183 | </property> | ||
184 | <property> | ||
185 | <name>sizeHint</name> | ||
186 | <size> | ||
187 | <width>20</width> | ||
188 | <height>20</height> | ||
189 | </size> | ||
190 | </property> | ||
191 | </spacer> | ||
192 | </hbox> | ||
193 | </widget> | ||
194 | <spacer row="3" column="0" > | ||
195 | <property> | ||
196 | <name>name</name> | ||
197 | <cstring>Spacer3</cstring> | ||
198 | </property> | ||
199 | <property stdset="1"> | ||
200 | <name>orientation</name> | ||
201 | <enum>Vertical</enum> | ||
202 | </property> | ||
203 | <property stdset="1"> | ||
204 | <name>sizeType</name> | ||
205 | <enum>Expanding</enum> | ||
206 | </property> | ||
207 | <property> | ||
208 | <name>sizeHint</name> | ||
209 | <size> | ||
210 | <width>20</width> | ||
211 | <height>20</height> | ||
212 | </size> | ||
213 | </property> | ||
214 | </spacer> | ||
215 | <widget row="0" column="0" > | ||
216 | <class>PreviewWidget</class> | ||
217 | <property stdset="1"> | ||
218 | <name>name</name> | ||
219 | <cstring>preview</cstring> | ||
220 | </property> | ||
221 | </widget> | ||
222 | </grid> | ||
223 | </widget> | ||
224 | <customwidgets> | ||
225 | <customwidget> | ||
226 | <class>PreviewWidget</class> | ||
227 | <header location="local">previewwidget.h</header> | ||
228 | <sizehint> | ||
229 | <width>240</width> | ||
230 | <height>160</height> | ||
231 | </sizehint> | ||
232 | <container>0</container> | ||
233 | <sizepolicy> | ||
234 | <hordata>0</hordata> | ||
235 | <verdata>0</verdata> | ||
236 | </sizepolicy> | ||
237 | <pixmap>image0</pixmap> | ||
238 | </customwidget> | ||
239 | </customwidgets> | ||
240 | <images> | ||
241 | <image> | ||
242 | <name>image0</name> | ||
243 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> | ||
244 | </image> | ||
245 | </images> | ||
246 | </UI> | ||
diff --git a/noncore/multimedia/camera/previewwidget.cpp b/noncore/multimedia/camera/previewwidget.cpp index bb84c00..cdeacf6 100644 --- a/noncore/multimedia/camera/previewwidget.cpp +++ b/noncore/multimedia/camera/previewwidget.cpp | |||
@@ -1,45 +1,64 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #include "previewwidget.h" | 16 | #include "previewwidget.h" |
17 | #include "zcameraio.h" | 17 | #include "zcameraio.h" |
18 | 18 | ||
19 | #include <opie2/odebug.h> | ||
20 | |||
19 | PreviewWidget::PreviewWidget( QWidget * parent, const char * name, WFlags f ) | 21 | PreviewWidget::PreviewWidget( QWidget * parent, const char * name, WFlags f ) |
20 | :QLabel( parent, name, f ) | 22 | :QLabel( parent, name, f ) |
21 | { | 23 | { |
22 | setFixedSize( QSize( 240, 160 ) ); | 24 | #ifndef QT_NO_DEBUG |
25 | setBackgroundColor( QColor( 255, 0, 0 ) ); | ||
26 | #else | ||
23 | setBackgroundMode( NoBackground ); | 27 | setBackgroundMode( NoBackground ); |
28 | #endif | ||
29 | |||
24 | 30 | ||
25 | startTimer( 150 ); | 31 | startTimer( 150 ); |
32 | //startTimer( 2000 ); | ||
26 | }; | 33 | }; |
27 | 34 | ||
28 | 35 | ||
29 | PreviewWidget::~PreviewWidget() | 36 | PreviewWidget::~PreviewWidget() |
30 | { | 37 | { |
31 | } | 38 | } |
32 | 39 | ||
33 | 40 | ||
41 | void PreviewWidget::resizeEvent( QResizeEvent* e ) | ||
42 | { | ||
43 | QLabel::resizeEvent( e ); | ||
44 | int w = e->size().width(); | ||
45 | int h = e->size().height(); | ||
46 | ZCameraIO::instance()->setCaptureFrame( e->size().width(), | ||
47 | e->size().height(), | ||
48 | 256, | ||
49 | w < h ); | ||
50 | } | ||
51 | |||
52 | |||
34 | void PreviewWidget::timerEvent( QTimerEvent* ) | 53 | void PreviewWidget::timerEvent( QTimerEvent* ) |
35 | { | 54 | { |
36 | //QDirectPainter fb( this ); | 55 | //QDirectPainter fb( this ); |
37 | //ZCameraIO::instance()->snapshot( fb.frameBuffer() ); | 56 | //ZCameraIO::instance()->snapshot( fb.frameBuffer() ); |
38 | 57 | ||
39 | if ( ZCameraIO::instance()->snapshot( &i ) ) | 58 | if ( ZCameraIO::instance()->snapshot( &i ) ) |
40 | { | 59 | { |
41 | p.convertFromImage( i ); | 60 | p.convertFromImage( i ); |
42 | setPixmap( p ); | 61 | setPixmap( p ); |
43 | } | 62 | } |
44 | } | 63 | } |
45 | 64 | ||
diff --git a/noncore/multimedia/camera/previewwidget.h b/noncore/multimedia/camera/previewwidget.h index c031d95..6b64768 100644 --- a/noncore/multimedia/camera/previewwidget.h +++ b/noncore/multimedia/camera/previewwidget.h | |||
@@ -1,39 +1,43 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #ifndef PREVIEWWIDGET_H | 16 | #ifndef PREVIEWWIDGET_H |
17 | #define PREVIEWWIDGET_H | 17 | #define PREVIEWWIDGET_H |
18 | 18 | ||
19 | #include <qlabel.h> | 19 | #include <qlabel.h> |
20 | #include <qimage.h> | 20 | #include <qimage.h> |
21 | #include <qpixmap.h> | 21 | #include <qpixmap.h> |
22 | 22 | ||
23 | class QTimerEvent; | ||
24 | class QResizeEvent; | ||
25 | |||
23 | class PreviewWidget: public QLabel | 26 | class PreviewWidget: public QLabel |
24 | { | 27 | { |
25 | Q_OBJECT | 28 | Q_OBJECT |
26 | 29 | ||
27 | public: | 30 | public: |
28 | PreviewWidget( QWidget * parent = 0, const char * name = 0, WFlags f = 0 ); | 31 | PreviewWidget( QWidget * parent = 0, const char * name = 0, WFlags f = 0 ); |
29 | virtual ~PreviewWidget(); | 32 | virtual ~PreviewWidget(); |
30 | 33 | ||
31 | protected: | 34 | protected: |
32 | virtual void timerEvent( QTimerEvent* ); | 35 | virtual void timerEvent( QTimerEvent* ); |
36 | virtual void resizeEvent( QResizeEvent* ); | ||
33 | 37 | ||
34 | private: | 38 | private: |
35 | QPixmap p; | 39 | QPixmap p; |
36 | QImage i; | 40 | QImage i; |
37 | }; | 41 | }; |
38 | 42 | ||
39 | #endif | 43 | #endif |
diff --git a/noncore/multimedia/camera/zcameraio.cpp b/noncore/multimedia/camera/zcameraio.cpp index 56b2e13..51771a5 100644 --- a/noncore/multimedia/camera/zcameraio.cpp +++ b/noncore/multimedia/camera/zcameraio.cpp | |||
@@ -47,170 +47,184 @@ ZCameraIO::ZCameraIO() | |||
47 | :_height( 0 ), _width( 0 ), _zoom( 0 ), _rot( 0 ), _readlen( 0 ) | 47 | :_height( 0 ), _width( 0 ), _zoom( 0 ), _rot( 0 ), _readlen( 0 ) |
48 | { | 48 | { |
49 | _driver = ::open( SHARPZDC, O_RDWR ); | 49 | _driver = ::open( SHARPZDC, O_RDWR ); |
50 | if ( _driver == -1 ) | 50 | if ( _driver == -1 ) |
51 | oerr << "Can't open camera driver: " << strerror(errno) << oendl; | 51 | oerr << "Can't open camera driver: " << strerror(errno) << oendl; |
52 | else | 52 | else |
53 | init(); | 53 | init(); |
54 | } | 54 | } |
55 | 55 | ||
56 | 56 | ||
57 | void ZCameraIO::init() | 57 | void ZCameraIO::init() |
58 | { | 58 | { |
59 | if ( ZCameraIO::_instance ) | 59 | if ( ZCameraIO::_instance ) |
60 | ofatal << "Don't create more than one ZCameraIO instances." << oendl; | 60 | ofatal << "Don't create more than one ZCameraIO instances." << oendl; |
61 | else | 61 | else |
62 | { | 62 | { |
63 | setReadMode( STATUS ); | 63 | setReadMode( STATUS ); |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | ZCameraIO::~ZCameraIO() | 68 | ZCameraIO::~ZCameraIO() |
69 | { | 69 | { |
70 | if ( _driver != -1 ) | 70 | if ( _driver != -1 ) |
71 | { | 71 | { |
72 | setReadMode( 0 ); | 72 | setReadMode( 0 ); |
73 | ::close( _driver ); | 73 | ::close( _driver ); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | 77 | ||
78 | inline bool ZCameraIO::isOpen() const | 78 | inline bool ZCameraIO::isOpen() const |
79 | { | 79 | { |
80 | return _driver != -1; | 80 | return _driver != -1; |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | inline bool ZCameraIO::isShutterPressed() | 84 | inline bool ZCameraIO::isShutterPressed() |
85 | { | 85 | { |
86 | return _status[0] == 'S'; | 86 | return _status[0] == 'S'; |
87 | clearShutterLatch(); | 87 | clearShutterLatch(); |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | inline bool ZCameraIO::isFinderReversed() const | 91 | inline bool ZCameraIO::isFinderReversed() const |
92 | { | 92 | { |
93 | return _status[1] == 'M'; | 93 | return _status[1] == 'M'; |
94 | } | 94 | } |
95 | 95 | ||
96 | 96 | ||
97 | inline bool ZCameraIO::isCapturing() const | 97 | inline bool ZCameraIO::isCapturing() const |
98 | { | 98 | { |
99 | return _status[2] == 'C'; | 99 | return _status[2] == 'C'; |
100 | } | 100 | } |
101 | 101 | ||
102 | 102 | ||
103 | inline bool ZCameraIO::isAvailable() const | 103 | inline bool ZCameraIO::isAvailable() const |
104 | { | 104 | { |
105 | return _status[3] == 'A'; | 105 | return _status[3] == 'A'; |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | bool ZCameraIO::setCaptureFrame( int width, int height, int zoom, bool rot ) | 109 | bool ZCameraIO::setCaptureFrame( int width, int height, int zoom, bool rot ) |
110 | { | 110 | { |
111 | odebug << "setCaptureFrame( " << width << ", " << height << ", " << zoom << ", " << rot << " )" << oendl; | ||
111 | char b[100]; | 112 | char b[100]; |
112 | sprintf( b, "%c=%d,%d,%d,%d", rot ? 'R':'S', width, height, zoom, width*2 ); | 113 | sprintf( b, "%c=%d,%d,%d,%d", rot ? 'R':'S', width, height, zoom, width*2 ); |
113 | if ( write( b ) ) | 114 | if ( write( b ) ) |
114 | { | 115 | { |
115 | _width = width; | 116 | _width = width; |
116 | _height = height; | 117 | _height = height; |
117 | _zoom = zoom; | 118 | _zoom = zoom; |
118 | _rot = rot; | 119 | _rot = rot; |
119 | _readlen = 2 * _width * _height; // camera is fixed @ 16 bits per pixel | 120 | _readlen = 2 * _width * _height; // camera is fixed @ 16 bits per pixel |
120 | return true; | 121 | return true; |
121 | } | 122 | } |
122 | return false; | 123 | return false; |
123 | } | 124 | } |
124 | 125 | ||
125 | 126 | ||
126 | void ZCameraIO::setReadMode( int mode ) | 127 | void ZCameraIO::setReadMode( int mode ) |
127 | { | 128 | { |
128 | char b[10]; | 129 | char b[10]; |
129 | sprintf( b, "M=%d", mode ); | 130 | sprintf( b, "M=%d", mode ); |
130 | write( b, mode <= 9 ? 3 : 4 ); | 131 | write( b, mode <= 9 ? 3 : 4 ); |
131 | if ( mode & 1 ) // STATUS bit is set | 132 | if ( mode & 1 ) // STATUS bit is set |
132 | read( _status, 4 ); | 133 | read( _status, 4 ); |
133 | } | 134 | } |
134 | 135 | ||
135 | 136 | ||
136 | void ZCameraIO::clearShutterLatch() | 137 | void ZCameraIO::clearShutterLatch() |
137 | { | 138 | { |
138 | char b = 'B'; | 139 | char b = 'B'; |
139 | write( &b, 1 ); | 140 | write( &b, 1 ); |
140 | } | 141 | } |
141 | 142 | ||
142 | 143 | ||
143 | bool ZCameraIO::read( char* b, int len ) | 144 | bool ZCameraIO::read( char* b, int len ) |
144 | { | 145 | { |
145 | #ifndef NO_TIMING | 146 | #ifndef NO_TIMING |
146 | QTime t; | 147 | QTime t; |
147 | t.start(); | 148 | t.start(); |
148 | #endif | 149 | #endif |
149 | int rlen = ::read( _driver, b, len ); | 150 | int rlen = ::read( _driver, b, len ); |
150 | #ifndef NO_TIMING | 151 | #ifndef NO_TIMING |
151 | int time = t.elapsed(); | 152 | int time = t.elapsed(); |
152 | #else | 153 | #else |
153 | int time = -1; | 154 | int time = -1; |
154 | #endif | 155 | #endif |
155 | if ( rlen ) | 156 | if ( rlen ) |
156 | odebug << "read " << rlen << " ('" << b[0] << b[1] << b[2] << b[3] << "') [" << time << " ms] from driver." << oendl; | 157 | odebug << "read " << rlen << " ('" << b[0] << b[1] << b[2] << b[3] << "') [" << time << " ms] from driver." << oendl; |
157 | else | 158 | else |
158 | odebug << "read nothing from driver." << oendl; | 159 | odebug << "read nothing from driver." << oendl; |
159 | return rlen == len; | 160 | return rlen == len; |
160 | } | 161 | } |
161 | 162 | ||
162 | 163 | ||
163 | bool ZCameraIO::write( char* buf, int len ) | 164 | bool ZCameraIO::write( char* buf, int len ) |
164 | { | 165 | { |
165 | if ( !len ) | 166 | if ( !len ) |
166 | len = strlen( buf ); | 167 | len = strlen( buf ); |
167 | 168 | ||
168 | odebug << "writing '" << buf << "' to driver." << oendl; | 169 | odebug << "writing '" << buf << "' to driver." << oendl; |
169 | 170 | ||
170 | return ::write( _driver, buf, len ) == len; | 171 | return ::write( _driver, buf, len ) == len; |
171 | } | 172 | } |
172 | 173 | ||
173 | 174 | ||
174 | bool ZCameraIO::snapshot( QImage* image ) | 175 | bool ZCameraIO::snapshot( QImage* image ) |
175 | { | 176 | { |
176 | setReadMode( IMAGE | XFLIP | YFLIP ); | 177 | setReadMode( STATUS ); |
177 | char buf[76800]; | 178 | |
179 | odebug << "finder reversed = " << isFinderReversed() << oendl; | ||
180 | odebug << "rotation = " << _rot << oendl; | ||
181 | |||
182 | if ( _rot ) // Portrait | ||
183 | { | ||
184 | setReadMode( IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0 ); | ||
185 | } | ||
186 | else // Landscape | ||
187 | { | ||
188 | setReadMode( IMAGE | XFLIP | YFLIP ); //isFinderReversed() ? 0 : XFLIP ); | ||
189 | } | ||
190 | |||
191 | char buf[_readlen]; | ||
178 | char* bp = buf; | 192 | char* bp = buf; |
179 | unsigned char* p; | 193 | unsigned char* p; |
180 | 194 | ||
181 | read( bp, _readlen ); | 195 | read( bp, _readlen ); |
182 | 196 | ||
183 | image->create( 240, 160, 16 ); | 197 | image->create( _width, _height, 16 ); |
184 | for ( int i = 0; i < 160; ++i ) | 198 | for ( int i = 0; i < _height; ++i ) |
185 | { | 199 | { |
186 | p = image->scanLine( i ); | 200 | p = image->scanLine( i ); |
187 | for ( int j = 0; j < 240; j++ ) | 201 | for ( int j = 0; j < _width; j++ ) |
188 | { | 202 | { |
189 | *p = *bp; | 203 | *p = *bp; |
190 | p++; | 204 | p++; |
191 | bp++; | 205 | bp++; |
192 | *p = *bp; | 206 | *p = *bp; |
193 | p++; | 207 | p++; |
194 | bp++; | 208 | bp++; |
195 | } | 209 | } |
196 | } | 210 | } |
197 | 211 | ||
198 | return true; | 212 | return true; |
199 | } | 213 | } |
200 | 214 | ||
201 | bool ZCameraIO::snapshot( unsigned char* buf ) | 215 | bool ZCameraIO::snapshot( unsigned char* buf ) |
202 | { | 216 | { |
203 | setReadMode( IMAGE | XFLIP | YFLIP ); | 217 | setReadMode( IMAGE | XFLIP | YFLIP ); |
204 | 218 | ||
205 | read( (char*) buf, _readlen ); | 219 | read( (char*) buf, _readlen ); |
206 | 220 | ||
207 | /* //TESTCODE | 221 | /* //TESTCODE |
208 | int fd = open( "/tmp/cam", O_RDONLY ); | 222 | int fd = open( "/tmp/cam", O_RDONLY ); |
209 | if ( ::read( fd, (char*) buf, 76800 ) != 76800 ) | 223 | if ( ::read( fd, (char*) buf, 76800 ) != 76800 ) |
210 | owarn << "Couldn't read image from /dev/sharp_zdc" << oendl; | 224 | owarn << "Couldn't read image from /dev/sharp_zdc" << oendl; |
211 | // TESTCODE */ | 225 | // TESTCODE */ |
212 | 226 | ||
213 | 227 | ||
214 | return true; | 228 | return true; |
215 | } | 229 | } |
216 | 230 | ||