-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,4 +1,4 @@ | |||
1 | moc | ||
2 | obj | ||
1 | config.in | 3 | config.in |
2 | mainwindowbase.h | ||
3 | mainwindowbase.cpp | ||
4 | Makefile | 4 | Makefile |
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 | |||
@@ -18,3 +18,3 @@ DEPENDPATH += $(OPIEDIR)/include | |||
18 | LIBS += -lqpe -lopiecore2 | 18 | LIBS += -lqpe -lopiecore2 |
19 | INTERFACES = mainwindowbase.ui | 19 | INTERFACES = |
20 | TARGET = opiecam | 20 | TARGET = opiecam |
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 | |||
@@ -16,3 +16,3 @@ | |||
16 | #include "mainwindow.h" | 16 | #include "mainwindow.h" |
17 | #include "mainwindowbase.h" | 17 | #include "previewwidget.h" |
18 | #include "zcameraio.h" | 18 | #include "zcameraio.h" |
@@ -21,2 +21,3 @@ | |||
21 | #include <qcombobox.h> | 21 | #include <qcombobox.h> |
22 | #include <qdatastream.h> | ||
22 | #include <qpushbutton.h> | 23 | #include <qpushbutton.h> |
@@ -25,4 +26,7 @@ | |||
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> |
@@ -32,8 +36,14 @@ CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags | |||
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 | }; |
@@ -46,2 +56,21 @@ CameraMainWindow::~CameraMainWindow() | |||
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 ) |
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 | |||
@@ -27,2 +27,4 @@ class QLabel; | |||
27 | class MainWindowBase; | 27 | class MainWindowBase; |
28 | class QCopChannel; | ||
29 | class PreviewWidget; | ||
28 | 30 | ||
@@ -38,2 +40,3 @@ class CameraMainWindow: public QMainWindow | |||
38 | void changeZoom( int ); | 40 | void changeZoom( int ); |
41 | void systemMessage( const QCString&, const QByteArray& ); | ||
39 | 42 | ||
@@ -42,3 +45,5 @@ class CameraMainWindow: public QMainWindow | |||
42 | private: | 45 | private: |
43 | MainWindowBase* mw; | 46 | PreviewWidget* preview; |
47 | int _rotation; | ||
48 | QCopChannel* _sysChannel; | ||
44 | }; | 49 | }; |
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 | |||
@@ -18,2 +18,4 @@ | |||
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 ) |
@@ -21,6 +23,11 @@ PreviewWidget::PreviewWidget( QWidget * parent, const char * name, WFlags 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 | }; |
@@ -33,2 +40,14 @@ PreviewWidget::~PreviewWidget() | |||
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* ) |
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 | |||
@@ -22,2 +22,5 @@ | |||
22 | 22 | ||
23 | class QTimerEvent; | ||
24 | class QResizeEvent; | ||
25 | |||
23 | class PreviewWidget: public QLabel | 26 | class PreviewWidget: public QLabel |
@@ -32,2 +35,3 @@ class PreviewWidget: public QLabel | |||
32 | virtual void timerEvent( QTimerEvent* ); | 35 | virtual void timerEvent( QTimerEvent* ); |
36 | virtual void resizeEvent( QResizeEvent* ); | ||
33 | 37 | ||
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 | |||
@@ -110,2 +110,3 @@ 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]; |
@@ -175,4 +176,17 @@ 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; |
@@ -182,7 +196,7 @@ bool ZCameraIO::snapshot( QImage* image ) | |||
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 | { |