Diffstat (limited to 'noncore/multimedia/camera/lib') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/camera/lib/zcameraio.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/noncore/multimedia/camera/lib/zcameraio.cpp b/noncore/multimedia/camera/lib/zcameraio.cpp index c940b45..d59cbbb 100644 --- a/noncore/multimedia/camera/lib/zcameraio.cpp +++ b/noncore/multimedia/camera/lib/zcameraio.cpp | |||
@@ -118,48 +118,49 @@ bool ZCameraIO::isCapturing() const | |||
118 | return _status[2] == 'C'; | 118 | return _status[2] == 'C'; |
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
122 | bool ZCameraIO::isAvailable() const | 122 | bool ZCameraIO::isAvailable() const |
123 | { | 123 | { |
124 | return _status[3] == 'A'; | 124 | return _status[3] == 'A'; |
125 | } | 125 | } |
126 | 126 | ||
127 | 127 | ||
128 | bool ZCameraIO::setCaptureFrame( int width, int height, int zoom, bool rot ) | 128 | bool ZCameraIO::setCaptureFrame( int width, int height, int zoom, bool rot ) |
129 | { | 129 | { |
130 | odebug << "setCaptureFrame( " << width << ", " << height << ", " << zoom << ", " << rot << " )" << oendl; | 130 | odebug << "setCaptureFrame( " << width << ", " << height << ", " << zoom << ", " << rot << " )" << oendl; |
131 | char b[100]; | 131 | char b[100]; |
132 | sprintf( b, "%c=%d,%d,%d,%d", rot ? 'R':'S', width, height, zoom, width*2 ); | 132 | sprintf( b, "%c=%d,%d,%d,%d", rot ? 'R':'S', width, height, zoom, width*2 ); |
133 | if ( write( b ) ) | 133 | if ( write( b ) ) |
134 | { | 134 | { |
135 | _width = width; | 135 | _width = width; |
136 | _height = height; | 136 | _height = height; |
137 | _zoom = zoom; | 137 | _zoom = zoom; |
138 | _rot = rot; | 138 | _rot = rot; |
139 | _readlen = 2 * _width * _height; // camera is fixed @ 16 bits per pixel | 139 | _readlen = 2 * _width * _height; // camera is fixed @ 16 bits per pixel |
140 | return true; | 140 | return true; |
141 | } | 141 | } |
142 | owarn << "couldn't write to driver" << oendl; | ||
142 | return false; | 143 | return false; |
143 | } | 144 | } |
144 | 145 | ||
145 | 146 | ||
146 | bool ZCameraIO::setZoom( int zoom ) | 147 | bool ZCameraIO::setZoom( int zoom ) |
147 | { | 148 | { |
148 | return setCaptureFrame( _width, _height, zoom*256, _rot ); | 149 | return setCaptureFrame( _width, _height, zoom*256, _rot ); |
149 | } | 150 | } |
150 | 151 | ||
151 | 152 | ||
152 | void ZCameraIO::setReadMode( int mode ) | 153 | void ZCameraIO::setReadMode( int mode ) |
153 | { | 154 | { |
154 | char b[10]; | 155 | char b[10]; |
155 | sprintf( b, "M=%d", mode ); | 156 | sprintf( b, "M=%d", mode ); |
156 | write( b, mode <= 9 ? 3 : 4 ); | 157 | write( b, mode <= 9 ? 3 : 4 ); |
157 | if ( mode & STATUS ) // STATUS bit is set | 158 | if ( mode & STATUS ) // STATUS bit is set |
158 | { | 159 | { |
159 | read( _status, 4 ); | 160 | read( _status, 4 ); |
160 | if ( isShutterPressed() ) | 161 | if ( isShutterPressed() ) |
161 | { | 162 | { |
162 | emit shutterClicked(); | 163 | emit shutterClicked(); |
163 | } | 164 | } |
164 | } | 165 | } |
165 | } | 166 | } |
@@ -194,48 +195,50 @@ bool ZCameraIO::read( char* b, int len ) | |||
194 | else | 195 | else |
195 | odebug << "read nothing from driver." << oendl; | 196 | odebug << "read nothing from driver." << oendl; |
196 | return rlen == len; | 197 | return rlen == len; |
197 | } | 198 | } |
198 | 199 | ||
199 | 200 | ||
200 | bool ZCameraIO::write( char* buf, int len ) | 201 | bool ZCameraIO::write( char* buf, int len ) |
201 | { | 202 | { |
202 | if ( !len ) | 203 | if ( !len ) |
203 | len = strlen( buf ); | 204 | len = strlen( buf ); |
204 | 205 | ||
205 | odebug << "writing '" << buf << "' to driver." << oendl; | 206 | odebug << "writing '" << buf << "' to driver." << oendl; |
206 | 207 | ||
207 | return ::write( _driver, buf, len ) == len; | 208 | return ::write( _driver, buf, len ) == len; |
208 | } | 209 | } |
209 | 210 | ||
210 | 211 | ||
211 | bool ZCameraIO::snapshot( QImage* image ) | 212 | bool ZCameraIO::snapshot( QImage* image ) |
212 | { | 213 | { |
213 | setReadMode( STATUS ); | 214 | setReadMode( STATUS ); |
214 | 215 | ||
215 | odebug << "finder reversed = " << isFinderReversed() << oendl; | 216 | odebug << "finder reversed = " << isFinderReversed() << oendl; |
216 | odebug << "rotation = " << _rot << oendl; | 217 | odebug << "rotation = " << _rot << oendl; |
217 | 218 | ||
219 | odebug << "w=" << _width << " h= " << _height << " readlen= " << _readlen << oendl; | ||
220 | |||
218 | int readmode; | 221 | int readmode; |
219 | if ( _flip == -1 ) // AUTO | 222 | if ( _flip == -1 ) // AUTO |
220 | { | 223 | { |
221 | if ( _rot ) // Portrait | 224 | if ( _rot ) // Portrait |
222 | { | 225 | { |
223 | readmode = IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0; | 226 | readmode = IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0; |
224 | } | 227 | } |
225 | else // Landscape | 228 | else // Landscape |
226 | { | 229 | { |
227 | readmode = IMAGE | XFLIP | YFLIP; | 230 | readmode = IMAGE | XFLIP | YFLIP; |
228 | } | 231 | } |
229 | } | 232 | } |
230 | else // OVERRIDE | 233 | else // OVERRIDE |
231 | { | 234 | { |
232 | readmode = IMAGE | _flip; | 235 | readmode = IMAGE | _flip; |
233 | } | 236 | } |
234 | 237 | ||
235 | setReadMode( readmode ); | 238 | setReadMode( readmode ); |
236 | 239 | ||
237 | char buf[_readlen]; | 240 | char buf[_readlen]; |
238 | char* bp = buf; | 241 | char* bp = buf; |
239 | unsigned char* p; | 242 | unsigned char* p; |
240 | 243 | ||
241 | read( bp, _readlen ); | 244 | read( bp, _readlen ); |
@@ -270,42 +273,43 @@ bool ZCameraIO::snapshot( unsigned char* buf ) | |||
270 | if ( _flip == -1 ) // AUTO | 273 | if ( _flip == -1 ) // AUTO |
271 | { | 274 | { |
272 | if ( _rot ) // Portrait | 275 | if ( _rot ) // Portrait |
273 | { | 276 | { |
274 | readmode = IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0; | 277 | readmode = IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0; |
275 | } | 278 | } |
276 | else // Landscape | 279 | else // Landscape |
277 | { | 280 | { |
278 | readmode = IMAGE | XFLIP | YFLIP; | 281 | readmode = IMAGE | XFLIP | YFLIP; |
279 | } | 282 | } |
280 | } | 283 | } |
281 | else // OVERRIDE | 284 | else // OVERRIDE |
282 | { | 285 | { |
283 | readmode = IMAGE | _flip; | 286 | readmode = IMAGE | _flip; |
284 | } | 287 | } |
285 | 288 | ||
286 | setReadMode( readmode ); | 289 | setReadMode( readmode ); |
287 | read( (char*) buf, _readlen ); | 290 | read( (char*) buf, _readlen ); |
288 | 291 | ||
289 | } | 292 | } |
290 | 293 | ||
291 | 294 | ||
292 | void ZCameraIO::captureFrame( int w, int h, int zoom, QImage* image ) | 295 | void ZCameraIO::captureFrame( int w, int h, int zoom, QImage* image ) |
293 | { | 296 | { |
297 | int prot = _rot; | ||
294 | int pw = _width; | 298 | int pw = _width; |
295 | int ph = _height; | 299 | int ph = _height; |
296 | setCaptureFrame( w, h, zoom*256, _rot ); | 300 | setCaptureFrame( w, h, zoom*256, w<h ); |
297 | snapshot( image ); | 301 | snapshot( image ); |
298 | setCaptureFrame( pw, ph, _zoom, _rot ); | 302 | setCaptureFrame( pw, ph, _zoom, prot ); |
299 | } | 303 | } |
300 | 304 | ||
301 | 305 | ||
302 | void ZCameraIO::captureFrame( int w, int h, int zoom, unsigned char* buf ) | 306 | void ZCameraIO::captureFrame( int w, int h, int zoom, unsigned char* buf ) |
303 | { | 307 | { |
304 | //FIXME: this is too slow | 308 | //FIXME: this is too slow |
305 | int pw = _width; | 309 | int pw = _width; |
306 | int ph = _height; | 310 | int ph = _height; |
307 | setCaptureFrame( w, h, zoom*256, _rot ); | 311 | setCaptureFrame( w, h, zoom*256, _rot ); |
308 | snapshot( buf ); | 312 | snapshot( buf ); |
309 | setCaptureFrame( pw, ph, _zoom, _rot ); | 313 | setCaptureFrame( pw, ph, _zoom, _rot ); |
310 | } | 314 | } |
311 | 315 | ||