author | mickeyl <mickeyl> | 2003-05-11 22:40:20 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-11 22:40:20 (UTC) |
commit | c0b6d29485dad8f39873def7cd890613f60a631b (patch) (unidiff) | |
tree | 5a8f0190ce739f3ba9af597537058818c643b434 /noncore | |
parent | 10de2c93dffa16f6d2f1cf72fa20008757c5ef3a (diff) | |
download | opie-c0b6d29485dad8f39873def7cd890613f60a631b.zip opie-c0b6d29485dad8f39873def7cd890613f60a631b.tar.gz opie-c0b6d29485dad8f39873def7cd890613f60a631b.tar.bz2 |
command line capturer now seems to work
you can now write yourself a nice webcam application :)
-rw-r--r-- | noncore/multimedia/camera/cmd/capture.cpp | 162 | ||||
-rw-r--r-- | noncore/multimedia/camera/cmd/capture.h | 45 | ||||
-rw-r--r-- | noncore/multimedia/camera/cmd/cmd.pro | 4 | ||||
-rw-r--r-- | noncore/multimedia/camera/lib/zcameraio.cpp | 8 |
4 files changed, 156 insertions, 63 deletions
diff --git a/noncore/multimedia/camera/cmd/capture.cpp b/noncore/multimedia/camera/cmd/capture.cpp index 7960bbb..64c223c 100644 --- a/noncore/multimedia/camera/cmd/capture.cpp +++ b/noncore/multimedia/camera/cmd/capture.cpp | |||
@@ -1,146 +1,190 @@ | |||
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 | #include "capture.h" | ||
17 | |||
16 | #include "zcameraio.h" | 18 | #include "zcameraio.h" |
17 | #include "imageio.h" | 19 | #include "imageio.h" |
18 | #include "avi.h" | 20 | #include "avi.h" |
19 | 21 | ||
20 | #include <qfile.h> | ||
21 | #include <qimage.h> | ||
22 | #include <opie2/oapplication.h> | 22 | #include <opie2/oapplication.h> |
23 | #include <opie2/odebug.h> | ||
24 | |||
25 | #include <qimage.h> | ||
23 | 26 | ||
24 | #include <assert.h> | 27 | Capturer::Capturer() |
25 | #include <sys/types.h> | 28 | :QFrame( 0 ), height( 320 ), width( 240 ), zoom( 1 ), quality( 90 ), |
26 | #include <sys/stat.h> | 29 | flip( "A" ), format( "JPEG" ), name( "Untitled" ) |
27 | #include <fcntl.h> | 30 | { |
28 | #include <string.h> | 31 | } |
29 | #include <errno.h> | ||
30 | #include <unistd.h> | ||
31 | #include <stdio.h> | ||
32 | 32 | ||
33 | #define CAPTUREFILE "/tmp/capture.dat" | ||
34 | #define OUTPUTFILE "/tmp/output.avi" | ||
35 | 33 | ||
36 | int captureX = 240; | 34 | Capturer::~Capturer() |
37 | int captureY = 320; | 35 | { |
38 | int quality = 75; | 36 | } |
39 | QString flip = "A"; | 37 | |
40 | int zoom = 1; | 38 | |
41 | QString format = "JPG"; | 39 | void Capturer::checkSettings() |
42 | QString name; | 40 | { |
41 | if ( width > height ) | ||
42 | { | ||
43 | if ( 0 != width % 16 || width < 16 || width > 640 ) | ||
44 | { | ||
45 | printf( "Warning: Corrected X resolution to 320 px\n" ); | ||
46 | width = 320; | ||
47 | } | ||
48 | if ( 0 != height % 16 || height < 16 || height > 480 ) | ||
49 | { | ||
50 | printf( "Warning: Corrected Y resolution to 240 px\n" ); | ||
51 | height = 240; | ||
52 | } | ||
53 | } | ||
54 | else | ||
55 | { | ||
56 | if ( 0 != width % 16 || width < 16 || width > 480 ) | ||
57 | { | ||
58 | printf( "Warning: Corrected X resolution to 240 px\n" ); | ||
59 | width = 240; | ||
60 | } | ||
61 | if ( 0 != height % 16 || height < 16 || height > 640 ) | ||
62 | { | ||
63 | printf( "Warning: Corrected Y resolution to 320 px\n" ); | ||
64 | height = 320; | ||
65 | } | ||
66 | } | ||
67 | |||
68 | if ( quality > 100 || quality < 10 ) | ||
69 | { | ||
70 | printf( "Warning: Corrected quality to 75%%\n" ); | ||
71 | quality = 75; | ||
72 | } | ||
73 | |||
74 | if ( zoom > 2 || zoom < 1 ) | ||
75 | { | ||
76 | printf( "Warning: Corrected zoom to x1\n" ); | ||
77 | zoom = 1; | ||
78 | } | ||
79 | |||
80 | if ( format != "JPEG" && format != "PNG" && format != "BMP" ) | ||
81 | { | ||
82 | printf( "Warning: Corrected format to 'JPEG'\n" ); | ||
83 | format = "JPEG"; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | |||
88 | void Capturer::capture() | ||
89 | { | ||
90 | if ( flip == "A" ) | ||
91 | ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP ); | ||
92 | else if ( flip == "0" ) | ||
93 | ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP ); | ||
94 | else if ( flip == "X" ) | ||
95 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP ); | ||
96 | else if ( flip == "Y" ) | ||
97 | ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP ); | ||
98 | else if ( flip == "*" ) | ||
99 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP ); | ||
100 | |||
101 | ZCameraIO::instance()->captureFrame( width, height, zoom, &image ); | ||
102 | QImage im = image.convertDepth( 32 ); | ||
103 | bool result = im.save( name, format, quality ); | ||
104 | if ( !result ) | ||
105 | { | ||
106 | printf( "QImageio-Problem while writing.\n" ); | ||
107 | } | ||
108 | else | ||
109 | { | ||
110 | printf( "Ok.\n" ); | ||
111 | } | ||
112 | } | ||
43 | 113 | ||
44 | int performCapture(); | ||
45 | 114 | ||
46 | void usage() | 115 | void usage() |
47 | { | 116 | { |
48 | printf( "Usage: ./capture [options] filename\n\n" ); | 117 | printf( "Usage: ./capture [options] filename\n\n" ); |
49 | printf( " -x xresolution (dividable by 16) [default=240]\n" ); | 118 | printf( " -x xresolution (dividable by 16) [default=240]\n" ); |
50 | printf( " -y xresolution (dividable by 16) [default=320]\n" ); | 119 | printf( " -y xresolution (dividable by 16) [default=320]\n" ); |
51 | printf( " -q quality (10-100) [default=75]\n" ); | 120 | printf( " -q quality (10-100) [default=75]\n" ); |
52 | printf( " -f flip (A=auto, X, Y, *=both) [default=Auto]\n" ); | 121 | printf( " -f flip (A=auto, 0, X, Y, *=both) [default=Auto]\n" ); |
53 | printf( " -o output format (JPG,BMP,PNG) [default=JPG]\n" ); | 122 | printf( " -o output format (JPEG,BMP,PNG) [default=JPEG]\n" ); |
54 | printf( " -z zoom (1-2) [default=1]\n" ); | 123 | printf( " -z zoom (1-2) [default=1]\n" ); |
55 | } | 124 | } |
56 | 125 | ||
57 | int main( int argc, char** argv ) | 126 | int main( int argc, char** argv ) |
58 | { | 127 | { |
59 | OApplication* a = new OApplication( argc, argv, "opie-camera" ); | 128 | OApplication* a = new OApplication( argc, argv, "Capture" ); |
129 | Capturer* c = new Capturer(); | ||
60 | 130 | ||
61 | if ( argc < 2 ) | 131 | if ( argc < 2 ) |
62 | { | 132 | { |
63 | usage(); | 133 | usage(); |
64 | return -1; | 134 | return -1; |
65 | } | 135 | } |
66 | 136 | ||
67 | int captureX = 240; | ||
68 | int captureY = 320; | ||
69 | QString flip = "A"; | ||
70 | |||
71 | #define I_HATE_WRITING_HARDCODED_PARSES | 137 | #define I_HATE_WRITING_HARDCODED_PARSES |
72 | 138 | ||
73 | int i = 1; | 139 | int i = 1; |
74 | while ( i < argc ) | 140 | while ( i < argc ) |
75 | { | 141 | { |
76 | // check for filename | 142 | // check for filename |
77 | if ( argv[i][0] != '-' ) | 143 | if ( argv[i][0] != '-' ) |
78 | { | 144 | { |
79 | if ( argc != i+1 ) | 145 | if ( argc != i+1 ) |
80 | { | 146 | { |
81 | usage(); | 147 | usage(); |
82 | return -1; | 148 | return -1; |
83 | } | 149 | } |
84 | else | 150 | else |
85 | { | 151 | { |
86 | name = argv[i]; | 152 | c->name = argv[i]; |
87 | break; | 153 | break; |
88 | } | 154 | } |
89 | } | 155 | } |
90 | else | 156 | else |
91 | { | 157 | { |
92 | i++; | 158 | i++; |
93 | if ( argc == i ) | 159 | if ( argc == i ) |
94 | { | 160 | { |
95 | usage(); | 161 | usage(); |
96 | return -1; | 162 | return -1; |
97 | } | 163 | } |
98 | switch ( argv[i-1][1] ) | 164 | switch ( argv[i-1][1] ) |
99 | { | 165 | { |
100 | case 'x': captureX = QString( argv[i] ).toInt(); break; | 166 | case 'x': c->width = QString( argv[i] ).toInt(); break; |
101 | case 'y': captureY = QString( argv[i] ).toInt(); break; | 167 | case 'y': c->height = QString( argv[i] ).toInt(); break; |
102 | case 'z': zoom = QString( argv[i] ).toInt(); break; | 168 | case 'z': c->zoom = QString( argv[i] ).toInt(); break; |
103 | case 'o': format = QString( argv[i] ); break; | 169 | case 'o': c->format = QString( argv[i] ); break; |
104 | case 'q': quality = QString( argv[i] ).toInt(); break; | 170 | case 'q': c->quality = QString( argv[i] ).toInt(); break; |
105 | case 'f': flip = QString( argv[i] )[0]; break; | 171 | case 'f': c->flip = QString( argv[i] )[0]; break; |
106 | default: usage(); return -1; | 172 | default: usage(); return -1; |
107 | } | 173 | } |
108 | i++; | 174 | i++; |
109 | } | 175 | } |
110 | 176 | ||
111 | #undef I_HATE_WRITING_HARDCODED_PARSES | 177 | #undef I_HATE_WRITING_HARDCODED_PARSES |
112 | } | 178 | } |
113 | 179 | ||
114 | if ( !ZCameraIO::instance()->isOpen() ) | 180 | if ( !ZCameraIO::instance()->isOpen() ) |
115 | { | 181 | { |
116 | printf( "Error: Can't detect your camera. Exiting.\n" ); | 182 | printf( "Error: Can't detect your camera. Exiting.\n" ); |
117 | return -1; | 183 | return -1; |
118 | } | 184 | } |
119 | return performCapture(); | ||
120 | } | ||
121 | |||
122 | 185 | ||
123 | int performCapture() | 186 | c->checkSettings(); |
124 | { | 187 | c->capture(); |
125 | printf( "Capturing %dx%d Image [%s] q%d z%d --> %s\n", captureX, | 188 | return 0; |
126 | captureY, | ||
127 | (const char*) format, | ||
128 | quality, | ||
129 | zoom, | ||
130 | (const char*) name ); | ||
131 | |||
132 | QImage i; | ||
133 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i ); | ||
134 | QImage im = i.convertDepth( 32 ); | ||
135 | bool result = im.save( name, format, quality ); | ||
136 | if ( !result ) | ||
137 | { | ||
138 | printf( "QImageio-Problem while writing.\n" ); | ||
139 | return -1; | ||
140 | } | ||
141 | else | ||
142 | { | ||
143 | printf( "Ok.\n" ); | ||
144 | } | ||
145 | } | 189 | } |
146 | 190 | ||
diff --git a/noncore/multimedia/camera/cmd/capture.h b/noncore/multimedia/camera/cmd/capture.h new file mode 100644 index 0000000..f23aca0 --- a/dev/null +++ b/noncore/multimedia/camera/cmd/capture.h | |||
@@ -0,0 +1,45 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2003 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 | #include "imageio.h" | ||
18 | #include "avi.h" | ||
19 | |||
20 | #include <qfile.h> | ||
21 | #include <qframe.h> | ||
22 | #include <qimage.h> | ||
23 | |||
24 | class Capturer: public QFrame | ||
25 | { | ||
26 | Q_OBJECT | ||
27 | |||
28 | public: | ||
29 | Capturer(); | ||
30 | virtual ~Capturer(); | ||
31 | |||
32 | int height; | ||
33 | int width; | ||
34 | int zoom; | ||
35 | int quality; | ||
36 | QString flip; | ||
37 | QString format; | ||
38 | QString name; | ||
39 | QImage image; | ||
40 | |||
41 | public slots: | ||
42 | void capture(); | ||
43 | void checkSettings(); | ||
44 | }; | ||
45 | |||
diff --git a/noncore/multimedia/camera/cmd/cmd.pro b/noncore/multimedia/camera/cmd/cmd.pro index 3b1aaa6..a5791f4 100644 --- a/noncore/multimedia/camera/cmd/cmd.pro +++ b/noncore/multimedia/camera/cmd/cmd.pro | |||
@@ -1,18 +1,18 @@ | |||
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 = | 7 | HEADERS = capture.h |
8 | 8 | ||
9 | SOURCES = capture.cpp | 9 | SOURCES = capture.cpp |
10 | 10 | ||
11 | INCLUDEPATH += $(OPIEDIR)/include ../lib | 11 | INCLUDEPATH += $(OPIEDIR)/include ../lib |
12 | DEPENDPATH += $(OPIEDIR)/include ../lib | 12 | DEPENDPATH += $(OPIEDIR)/include ../lib |
13 | LIBS += -lqpe -lopiecore2 -lopiecam | 13 | LIBS += -lopiecore2 -lopiecam |
14 | INTERFACES = | 14 | INTERFACES = |
15 | TARGET = capture | 15 | TARGET = capture |
16 | 16 | ||
17 | include ( $(OPIEDIR)/include.pro ) | 17 | include ( $(OPIEDIR)/include.pro ) |
18 | 18 | ||
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 | ||