-rw-r--r-- | noncore/multimedia/camera/cmd/capture.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/camera/gui/mainwindow.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/camera/lib/avi.c | 1 |
3 files changed, 5 insertions, 1 deletions
diff --git a/noncore/multimedia/camera/cmd/capture.cpp b/noncore/multimedia/camera/cmd/capture.cpp index 688622b..6b8c63c 100644 --- a/noncore/multimedia/camera/cmd/capture.cpp +++ b/noncore/multimedia/camera/cmd/capture.cpp | |||
@@ -1,192 +1,195 @@ | |||
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" | 16 | #include "capture.h" |
17 | 17 | ||
18 | #include "zcameraio.h" | 18 | #include "zcameraio.h" |
19 | #include "imageio.h" | 19 | #include "imageio.h" |
20 | #include "avi.h" | 20 | #include "avi.h" |
21 | 21 | ||
22 | #include <opie2/oapplication.h> | 22 | #include <opie2/oapplication.h> |
23 | #include <opie2/odebug.h> | 23 | #include <opie2/odebug.h> |
24 | 24 | ||
25 | #include <qimage.h> | 25 | #include <qimage.h> |
26 | 26 | ||
27 | using namespace Opie::Core; | 27 | using namespace Opie::Core; |
28 | using namespace Opie::Core; | 28 | using namespace Opie::Core; |
29 | Capturer::Capturer() | 29 | Capturer::Capturer() |
30 | :QFrame( 0 ), height( 320 ), width( 240 ), zoom( 1 ), quality( 90 ), | 30 | :QFrame( 0 ), height( 320 ), width( 240 ), zoom( 1 ), quality( 90 ), |
31 | flip( "A" ), format( "JPEG" ), name( "Untitled" ) | 31 | flip( "A" ), format( "JPEG" ), name( "Untitled" ) |
32 | { | 32 | { |
33 | } | 33 | } |
34 | 34 | ||
35 | 35 | ||
36 | Capturer::~Capturer() | 36 | Capturer::~Capturer() |
37 | { | 37 | { |
38 | } | 38 | } |
39 | 39 | ||
40 | 40 | ||
41 | void Capturer::checkSettings() | 41 | void Capturer::checkSettings() |
42 | { | 42 | { |
43 | if ( width > height ) | 43 | if ( width > height ) |
44 | { | 44 | { |
45 | if ( 0 != width % 16 || width < 16 || width > 640 ) | 45 | if ( 0 != width % 16 || width < 16 || width > 640 ) |
46 | { | 46 | { |
47 | printf( "Warning: Corrected X resolution to 320 px\n" ); | 47 | printf( "Warning: Corrected X resolution to 320 px\n" ); |
48 | width = 320; | 48 | width = 320; |
49 | } | 49 | } |
50 | if ( 0 != height % 16 || height < 16 || height > 480 ) | 50 | if ( 0 != height % 16 || height < 16 || height > 480 ) |
51 | { | 51 | { |
52 | printf( "Warning: Corrected Y resolution to 240 px\n" ); | 52 | printf( "Warning: Corrected Y resolution to 240 px\n" ); |
53 | height = 240; | 53 | height = 240; |
54 | } | 54 | } |
55 | } | 55 | } |
56 | else | 56 | else |
57 | { | 57 | { |
58 | if ( 0 != width % 16 || width < 16 || width > 480 ) | 58 | if ( 0 != width % 16 || width < 16 || width > 480 ) |
59 | { | 59 | { |
60 | printf( "Warning: Corrected X resolution to 240 px\n" ); | 60 | printf( "Warning: Corrected X resolution to 240 px\n" ); |
61 | width = 240; | 61 | width = 240; |
62 | } | 62 | } |
63 | if ( 0 != height % 16 || height < 16 || height > 640 ) | 63 | if ( 0 != height % 16 || height < 16 || height > 640 ) |
64 | { | 64 | { |
65 | printf( "Warning: Corrected Y resolution to 320 px\n" ); | 65 | printf( "Warning: Corrected Y resolution to 320 px\n" ); |
66 | height = 320; | 66 | height = 320; |
67 | } | 67 | } |
68 | } | 68 | } |
69 | 69 | ||
70 | if ( quality > 100 || quality < 10 ) | 70 | if ( quality > 100 || quality < 10 ) |
71 | { | 71 | { |
72 | printf( "Warning: Corrected quality to 75%%\n" ); | 72 | printf( "Warning: Corrected quality to 75%%\n" ); |
73 | quality = 75; | 73 | quality = 75; |
74 | } | 74 | } |
75 | 75 | ||
76 | if ( zoom > 2 || zoom < 1 ) | 76 | if ( zoom > 2 || zoom < 1 ) |
77 | { | 77 | { |
78 | printf( "Warning: Corrected zoom to x1\n" ); | 78 | printf( "Warning: Corrected zoom to x1\n" ); |
79 | zoom = 1; | 79 | zoom = 1; |
80 | } | 80 | } |
81 | 81 | ||
82 | if ( format != "JPEG" && format != "PNG" && format != "BMP" ) | 82 | if ( format != "JPEG" && format != "PNG" && format != "BMP" ) |
83 | { | 83 | { |
84 | printf( "Warning: Corrected format to 'JPEG'\n" ); | 84 | printf( "Warning: Corrected format to 'JPEG'\n" ); |
85 | format = "JPEG"; | 85 | format = "JPEG"; |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | 89 | ||
90 | void Capturer::capture() | 90 | void Capturer::capture() |
91 | { | 91 | { |
92 | if ( flip == "A" ) | 92 | if ( flip == "A" ) |
93 | ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP ); | 93 | ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP ); |
94 | else if ( flip == "0" ) | 94 | else if ( flip == "0" ) |
95 | ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP ); | 95 | ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP ); |
96 | else if ( flip == "X" ) | 96 | else if ( flip == "X" ) |
97 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP ); | 97 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP ); |
98 | else if ( flip == "Y" ) | 98 | else if ( flip == "Y" ) |
99 | ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP ); | 99 | ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP ); |
100 | else if ( flip == "*" ) | 100 | else if ( flip == "*" ) |
101 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP ); | 101 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP ); |
102 | 102 | ||
103 | ZCameraIO::instance()->captureFrame( width, height, zoom, &image ); | 103 | ZCameraIO::instance()->captureFrame( width, height, zoom, &image ); |
104 | QImage im = image.convertDepth( 32 ); | 104 | QImage im = image.convertDepth( 32 ); |
105 | bool result = im.save( name, format, quality ); | 105 | bool result = im.save( name, format, quality ); |
106 | if ( !result ) | 106 | if ( !result ) |
107 | { | 107 | { |
108 | printf( "QImageio-Problem while writing.\n" ); | 108 | printf( "QImageio-Problem while writing.\n" ); |
109 | } | 109 | } |
110 | else | 110 | else |
111 | { | 111 | { |
112 | printf( "Ok.\n" ); | 112 | printf( "Ok.\n" ); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | void usage() | 117 | void usage() |
118 | { | 118 | { |
119 | printf( "Usage: ./capture [options] filename\n\n" ); | 119 | printf( "Usage: ./capture [options] filename\n\n" ); |
120 | printf( " -x xresolution (dividable by 16) [default=240]\n" ); | 120 | printf( " -x xresolution (dividable by 16) [default=240]\n" ); |
121 | printf( " -y xresolution (dividable by 16) [default=320]\n" ); | 121 | printf( " -y xresolution (dividable by 16) [default=320]\n" ); |
122 | printf( " -q quality (10-100) [default=75]\n" ); | 122 | printf( " -q quality (10-100) [default=75]\n" ); |
123 | printf( " -f flip (A=auto, 0, X, Y, *=both) [default=Auto]\n" ); | 123 | printf( " -f flip (A=auto, 0, X, Y, *=both) [default=Auto]\n" ); |
124 | printf( " -o output format (JPEG,BMP,PNG) [default=JPEG]\n" ); | 124 | printf( " -o output format (JPEG,BMP,PNG) [default=JPEG]\n" ); |
125 | printf( " -z zoom (1-2) [default=1]\n" ); | 125 | printf( " -z zoom (1-2) [default=1]\n" ); |
126 | } | 126 | } |
127 | 127 | ||
128 | int main( int argc, char** argv ) | 128 | int main( int argc, char** argv ) |
129 | { | 129 | { |
130 | OApplication* a = new OApplication( argc, argv, "Capture" ); | 130 | OApplication* a = new OApplication( argc, argv, "Capture" ); |
131 | Capturer* c = new Capturer(); | 131 | Capturer* c = new Capturer(); |
132 | 132 | ||
133 | if ( argc < 2 ) | 133 | if ( argc < 2 ) |
134 | { | 134 | { |
135 | usage(); | 135 | usage(); |
136 | return -1; | 136 | return -1; |
137 | } | 137 | } |
138 | 138 | ||
139 | #define I_HATE_WRITING_HARDCODED_PARSES | 139 | #define I_HATE_WRITING_HARDCODED_PARSES |
140 | 140 | ||
141 | int i = 1; | 141 | int i = 1; |
142 | while ( i < argc ) | 142 | while ( i < argc ) |
143 | { | 143 | { |
144 | // check for filename | 144 | // check for filename |
145 | if ( argv[i][0] != '-' ) | 145 | if ( argv[i][0] != '-' ) |
146 | { | 146 | { |
147 | if ( argc != i+1 ) | 147 | if ( argc != i+1 ) |
148 | { | 148 | { |
149 | usage(); | 149 | usage(); |
150 | return -1; | 150 | return -1; |
151 | } | 151 | } |
152 | else | 152 | else |
153 | { | 153 | { |
154 | c->name = argv[i]; | 154 | c->name = argv[i]; |
155 | break; | 155 | break; |
156 | } | 156 | } |
157 | } | 157 | } |
158 | else | 158 | else |
159 | { | 159 | { |
160 | i++; | 160 | i++; |
161 | if ( argc == i ) | 161 | if ( argc == i ) |
162 | { | 162 | { |
163 | usage(); | 163 | usage(); |
164 | return -1; | 164 | return -1; |
165 | } | 165 | } |
166 | switch ( argv[i-1][1] ) | 166 | switch ( argv[i-1][1] ) |
167 | { | 167 | { |
168 | case 'x': c->width = QString( argv[i] ).toInt(); break; | 168 | case 'x': c->width = QString( argv[i] ).toInt(); break; |
169 | case 'y': c->height = QString( argv[i] ).toInt(); break; | 169 | case 'y': c->height = QString( argv[i] ).toInt(); break; |
170 | case 'z': c->zoom = QString( argv[i] ).toInt(); break; | 170 | case 'z': c->zoom = QString( argv[i] ).toInt(); break; |
171 | case 'o': c->format = QString( argv[i] ); break; | 171 | case 'o': c->format = QString( argv[i] ); break; |
172 | case 'q': c->quality = QString( argv[i] ).toInt(); break; | 172 | case 'q': c->quality = QString( argv[i] ).toInt(); break; |
173 | case 'f': c->flip = QString( argv[i] )[0]; break; | 173 | case 'f': c->flip = QString( argv[i] )[0]; break; |
174 | default: usage(); return -1; | 174 | default: usage(); return -1; |
175 | } | 175 | } |
176 | i++; | 176 | i++; |
177 | } | 177 | } |
178 | 178 | ||
179 | #undef I_HATE_WRITING_HARDCODED_PARSES | 179 | #undef I_HATE_WRITING_HARDCODED_PARSES |
180 | } | 180 | } |
181 | 181 | ||
182 | if ( !ZCameraIO::instance()->isOpen() ) | 182 | if ( !ZCameraIO::instance()->isOpen() ) |
183 | { | 183 | { |
184 | printf( "Error: Can't detect your camera. Exiting.\n" ); | 184 | printf( "Error: Can't detect your camera. Exiting.\n" ); |
185 | return -1; | 185 | return -1; |
186 | } | 186 | } |
187 | 187 | ||
188 | c->checkSettings(); | 188 | c->checkSettings(); |
189 | c->capture(); | 189 | c->capture(); |
190 | |||
191 | delete c; | ||
192 | delete a; | ||
190 | return 0; | 193 | return 0; |
191 | } | 194 | } |
192 | 195 | ||
diff --git a/noncore/multimedia/camera/gui/mainwindow.cpp b/noncore/multimedia/camera/gui/mainwindow.cpp index 7f2a9bd..bde448d 100644 --- a/noncore/multimedia/camera/gui/mainwindow.cpp +++ b/noncore/multimedia/camera/gui/mainwindow.cpp | |||
@@ -1,731 +1,731 @@ | |||
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 "previewwidget.h" | 17 | #include "previewwidget.h" |
18 | #include "zcameraio.h" | 18 | #include "zcameraio.h" |
19 | #include "imageio.h" | 19 | #include "imageio.h" |
20 | #include "avi.h" | 20 | #include "avi.h" |
21 | 21 | ||
22 | /* OPIE */ | 22 | /* OPIE */ |
23 | #include <opie2/ofiledialog.h> | 23 | #include <opie2/ofiledialog.h> |
24 | #include <opie2/odevice.h> | 24 | #include <opie2/odevice.h> |
25 | #include <opie2/oapplication.h> | 25 | #include <opie2/oapplication.h> |
26 | #include <opie2/oconfig.h> | 26 | #include <opie2/oconfig.h> |
27 | #include <opie2/odebug.h> | 27 | #include <opie2/odebug.h> |
28 | #include <qpe/global.h> | 28 | #include <qpe/global.h> |
29 | #include <qpe/resource.h> | 29 | #include <qpe/resource.h> |
30 | #include <qpe/qcopenvelope_qws.h> | 30 | #include <qpe/qcopenvelope_qws.h> |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qaction.h> | 34 | #include <qaction.h> |
35 | #include <qvbox.h> | 35 | #include <qvbox.h> |
36 | #include <qcombobox.h> | 36 | #include <qcombobox.h> |
37 | #include <qcursor.h> | 37 | #include <qcursor.h> |
38 | #include <qdatastream.h> | 38 | #include <qdatastream.h> |
39 | #include <qdir.h> | 39 | #include <qdir.h> |
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qimage.h> | 41 | #include <qimage.h> |
42 | #include <qlabel.h> | 42 | #include <qlabel.h> |
43 | #include <qlineedit.h> | 43 | #include <qlineedit.h> |
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qprogressbar.h> | 45 | #include <qprogressbar.h> |
46 | #include <qpushbutton.h> | 46 | #include <qpushbutton.h> |
47 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qdirectpainter_qws.h> | 49 | #include <qdirectpainter_qws.h> |
50 | 50 | ||
51 | /* STD */ | 51 | /* STD */ |
52 | #include <assert.h> | 52 | #include <assert.h> |
53 | #include <sys/types.h> | 53 | #include <sys/types.h> |
54 | #include <sys/stat.h> | 54 | #include <sys/stat.h> |
55 | #include <fcntl.h> | 55 | #include <fcntl.h> |
56 | #include <string.h> | 56 | #include <string.h> |
57 | #include <errno.h> | 57 | #include <errno.h> |
58 | #include <unistd.h> | 58 | #include <unistd.h> |
59 | 59 | ||
60 | #define CAPTUREFILE "/tmp/capture.dat" | 60 | #define CAPTUREFILE "/tmp/capture.dat" |
61 | #define OUTPUTFILE "/tmp/output.avi" | 61 | #define OUTPUTFILE "/tmp/output.avi" |
62 | 62 | ||
63 | #define OUTPUT_TO_CUSTOM 250 | 63 | #define OUTPUT_TO_CUSTOM 250 |
64 | #define OUTPUT_TO_DOCFOLDER 251 | 64 | #define OUTPUT_TO_DOCFOLDER 251 |
65 | 65 | ||
66 | 66 | ||
67 | using namespace Opie::Ui; | 67 | using namespace Opie::Ui; |
68 | using namespace Opie::Core; | 68 | using namespace Opie::Core; |
69 | 69 | ||
70 | CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) | 70 | CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) |
71 | :QMainWindow( parent, name, f ), | 71 | :QMainWindow( parent, name, f ), |
72 | _rotation( 270 ), // FIXME: get this from current settings (ODevice?) | 72 | _rotation( 270 ), // FIXME: get this from current settings (ODevice?) |
73 | _capturing( false ), | 73 | _capturing( false ), |
74 | _pics( 1 ), _videos( 1 ) | 74 | _pics( 1 ), _videos( 1 ) |
75 | { | 75 | { |
76 | #ifdef QT_NO_DEBUG | 76 | #ifdef QT_NO_DEBUG |
77 | if ( !ZCameraIO::instance()->isOpen() ) | 77 | if ( !ZCameraIO::instance()->isOpen() ) |
78 | { | 78 | { |
79 | QVBox* v = new QVBox( this ); | 79 | QVBox* v = new QVBox( this ); |
80 | v->setMargin( 10 ); | 80 | v->setMargin( 10 ); |
81 | QLabel* l1 = new QLabel( v ); | 81 | QLabel* l1 = new QLabel( v ); |
82 | l1->setPixmap( Resource::loadPixmap( "camera/error" ) ); | 82 | l1->setPixmap( Resource::loadPixmap( "camera/error" ) ); |
83 | QLabel* l2 = new QLabel( v ); | 83 | QLabel* l2 = new QLabel( v ); |
84 | l2->setText( "<b>Sorry. could not detect your camera :-(</b><p>" | 84 | l2->setText( "<b>Sorry. could not detect your camera :-(</b><p>" |
85 | "* Is the sharpzdc_cs module loaded ?<br>" | 85 | "* Is the sharpzdc_cs module loaded ?<br>" |
86 | "* Is /dev/sharpzdc read/writable ?<p>" ); | 86 | "* Is /dev/sharpzdc read/writable ?<p>" ); |
87 | connect( new QPushButton( "Exit", v ), SIGNAL( clicked() ), this, SLOT( close() ) ); | 87 | connect( new QPushButton( "Exit", v ), SIGNAL( clicked() ), this, SLOT( close() ) ); |
88 | setCentralWidget( v ); | 88 | setCentralWidget( v ); |
89 | return; | 89 | return; |
90 | } | 90 | } |
91 | #endif | 91 | #endif |
92 | 92 | ||
93 | init(); | 93 | init(); |
94 | 94 | ||
95 | _rotation = 270; //TODO: grab these from the actual settings | 95 | _rotation = 270; //TODO: grab these from the actual settings |
96 | 96 | ||
97 | preview = new PreviewWidget( this, "camera preview widget" ); | 97 | preview = new PreviewWidget( this, "camera preview widget" ); |
98 | //setCentralWidget( preview ); <--- don't do this! | 98 | //setCentralWidget( preview ); <--- don't do this! |
99 | preview->resize( QSize( 240, 288 ) ); | 99 | preview->resize( QSize( 240, 288 ) ); |
100 | preview->show(); | 100 | preview->show(); |
101 | 101 | ||
102 | // construct a System Channel to receive setRotation messages | 102 | // construct a System Channel to receive setRotation messages |
103 | _sysChannel = new QCopChannel( "QPE/System", this ); | 103 | _sysChannel = new QCopChannel( "QPE/System", this ); |
104 | connect( _sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 104 | connect( _sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
105 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); | 105 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
106 | 106 | ||
107 | connect( preview, SIGNAL( contextMenuRequested() ), this, SLOT( showContextMenu() ) ); | 107 | connect( preview, SIGNAL( contextMenuRequested() ), this, SLOT( showContextMenu() ) ); |
108 | 108 | ||
109 | connect( ZCameraIO::instance(), SIGNAL( shutterClicked() ), this, SLOT( shutterClicked() ) ); | 109 | connect( ZCameraIO::instance(), SIGNAL( shutterClicked() ), this, SLOT( shutterClicked() ) ); |
110 | 110 | ||
111 | updateCaption(); | 111 | updateCaption(); |
112 | 112 | ||
113 | }; | 113 | }; |
114 | 114 | ||
115 | 115 | ||
116 | CameraMainWindow::~CameraMainWindow() | 116 | CameraMainWindow::~CameraMainWindow() |
117 | { | 117 | { |
118 | // write back configuration | 118 | // write back configuration |
119 | OConfigGroupSaver cgs( oApp->config(), "General" ); | 119 | OConfigGroupSaver cgs( oApp->config(), "General" ); |
120 | cgs.config()->writeEntry( "flip", flip ); | 120 | cgs.config()->writeEntry( "flip", flip ); |
121 | cgs.config()->writeEntry( "quality", quality ); | 121 | cgs.config()->writeEntry( "quality", quality ); |
122 | cgs.config()->writeEntry( "zoom", zoom ); | 122 | cgs.config()->writeEntry( "zoom", zoom ); |
123 | cgs.config()->writeEntry( "captureX", captureX ); | 123 | cgs.config()->writeEntry( "captureX", captureX ); |
124 | cgs.config()->writeEntry( "captureY", captureY ); | 124 | cgs.config()->writeEntry( "captureY", captureY ); |
125 | cgs.config()->writeEntry( "captureFormat", captureFormat ); | 125 | cgs.config()->writeEntry( "captureFormat", captureFormat ); |
126 | cgs.config()->writeEntry( "outputTo", outputTo ); | 126 | cgs.config()->writeEntry( "outputTo", outputTo ); |
127 | cgs.config()->writeEntry( "prefix", prefix ); | 127 | cgs.config()->writeEntry( "prefix", prefix ); |
128 | cgs.config()->writeEntry( "appendSettings", appendSettings ); | 128 | cgs.config()->writeEntry( "appendSettings", appendSettings ); |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
132 | void CameraMainWindow::init() | 132 | void CameraMainWindow::init() |
133 | { | 133 | { |
134 | // get values from configuration | 134 | // get values from configuration |
135 | OConfigGroupSaver cgs( oApp->config(), "General" ); | 135 | OConfigGroupSaver cgs( oApp->config(), "General" ); |
136 | flip = cgs.config()->readEntry( "flip", "A" ); | 136 | flip = cgs.config()->readEntry( "flip", "A" ); |
137 | quality = cgs.config()->readNumEntry( "quality", 50 ); | 137 | quality = cgs.config()->readNumEntry( "quality", 50 ); |
138 | zoom = cgs.config()->readNumEntry( "zoom", 1 ); | 138 | zoom = cgs.config()->readNumEntry( "zoom", 1 ); |
139 | captureX = cgs.config()->readNumEntry( "captureX", 480 ); | 139 | captureX = cgs.config()->readNumEntry( "captureX", 480 ); |
140 | captureY = cgs.config()->readNumEntry( "captureY", 640 ); | 140 | captureY = cgs.config()->readNumEntry( "captureY", 640 ); |
141 | captureFormat = cgs.config()->readEntry( "captureFormat", "JPEG" ); | 141 | captureFormat = cgs.config()->readEntry( "captureFormat", "JPEG" ); |
142 | outputTo = cgs.config()->readEntry( "outputTo", "Documents Folder" ); | 142 | outputTo = cgs.config()->readEntry( "outputTo", "Documents Folder" ); |
143 | prefix = cgs.config()->readEntry( "prefix", "Untitled" ); | 143 | prefix = cgs.config()->readEntry( "prefix", "Untitled" ); |
144 | appendSettings = cgs.config()->readBoolEntry( "appendSettings", true ); | 144 | appendSettings = cgs.config()->readBoolEntry( "appendSettings", true ); |
145 | 145 | ||
146 | // create action groups | 146 | // create action groups |
147 | QAction* a; | 147 | QAction* a; |
148 | resog = new QActionGroup( 0, "reso", true ); | 148 | resog = new QActionGroup( 0, "reso", true ); |
149 | resog->setToggleAction( true ); | 149 | resog->setToggleAction( true ); |
150 | new QAction( " 64 x 48", 0, 0, resog, "64x48", true ); | 150 | new QAction( " 64 x 48", 0, 0, resog, "64x48", true ); |
151 | new QAction( "128 x 96", 0, 0, resog, "128x96", true ); | 151 | new QAction( "128 x 96", 0, 0, resog, "128x96", true ); |
152 | new QAction( "192 x 144", 0, 0, resog, "192x144", true ); | 152 | new QAction( "192 x 144", 0, 0, resog, "192x144", true ); |
153 | new QAction( "256 x 192", 0, 0, resog, "256x192", true ); | 153 | new QAction( "256 x 192", 0, 0, resog, "256x192", true ); |
154 | new QAction( "320 x 240", 0, 0, resog, "320x240", true ); | 154 | new QAction( "320 x 240", 0, 0, resog, "320x240", true ); |
155 | new QAction( "384 x 288", 0, 0, resog, "384x288", true ); | 155 | new QAction( "384 x 288", 0, 0, resog, "384x288", true ); |
156 | new QAction( "448 x 336", 0, 0, resog, "448x336", true ); | 156 | new QAction( "448 x 336", 0, 0, resog, "448x336", true ); |
157 | new QAction( "512 x 384", 0, 0, resog, "512x384", true ); | 157 | new QAction( "512 x 384", 0, 0, resog, "512x384", true ); |
158 | new QAction( "576 x 432", 0, 0, resog, "576x432", true ); | 158 | new QAction( "576 x 432", 0, 0, resog, "576x432", true ); |
159 | new QAction( "640 x 480", 0, 0, resog, "640x480", true ); | 159 | new QAction( "640 x 480", 0, 0, resog, "640x480", true ); |
160 | a = (QAction*) resog->child( QString().sprintf( "%dx%d", captureX>captureY ? captureX:captureY, captureX>captureY ? captureY:captureX ) ); | 160 | a = (QAction*) resog->child( QString().sprintf( "%dx%d", captureX>captureY ? captureX:captureY, captureX>captureY ? captureY:captureX ) ); |
161 | if ( a ) a->setOn( true ); | 161 | if ( a ) a->setOn( true ); |
162 | else owarn << "can't set resolution" << oendl; | 162 | else owarn << "can't set resolution" << oendl; |
163 | 163 | ||
164 | qualityg = new QActionGroup( 0, "quality", true ); | 164 | qualityg = new QActionGroup( 0, "quality", true ); |
165 | qualityg->setToggleAction( true ); | 165 | qualityg->setToggleAction( true ); |
166 | new QAction( " 0 (&minimal)", 0, 0, qualityg, "0", true ); | 166 | new QAction( " 0 (&minimal)", 0, 0, qualityg, "0", true ); |
167 | new QAction( " 25 (&low)", 0, 0, qualityg, "25", true ); | 167 | new QAction( " 25 (&low)", 0, 0, qualityg, "25", true ); |
168 | new QAction( " 50 (&good)", 0, 0, qualityg, "50", true ); | 168 | new QAction( " 50 (&good)", 0, 0, qualityg, "50", true ); |
169 | new QAction( " 75 (&better)", 0, 0, qualityg, "75", true ); | 169 | new QAction( " 75 (&better)", 0, 0, qualityg, "75", true ); |
170 | new QAction( "100 (bes&t)", 0, 0, qualityg, "100", true ); | 170 | new QAction( "100 (bes&t)", 0, 0, qualityg, "100", true ); |
171 | a = (QAction*) qualityg->child( QString().sprintf( "%d", quality ) ); | 171 | a = (QAction*) qualityg->child( QString().sprintf( "%d", quality ) ); |
172 | if ( a ) a->setOn( true ); | 172 | if ( a ) a->setOn( true ); |
173 | else owarn << "can't set quality" << oendl; | 173 | else owarn << "can't set quality" << oendl; |
174 | 174 | ||
175 | zoomg = new QActionGroup( 0, "zoom", true ); | 175 | zoomg = new QActionGroup( 0, "zoom", true ); |
176 | zoomg->setToggleAction( true ); | 176 | zoomg->setToggleAction( true ); |
177 | new QAction( "x 1", 0, 0, zoomg, "1", true ); | 177 | new QAction( "x 1", 0, 0, zoomg, "1", true ); |
178 | new QAction( "x 2", 0, 0, zoomg, "2", true ); | 178 | new QAction( "x 2", 0, 0, zoomg, "2", true ); |
179 | a = (QAction*) zoomg->child( QString().sprintf( "%d", zoom ) ); | 179 | a = (QAction*) zoomg->child( QString().sprintf( "%d", zoom ) ); |
180 | if ( a ) a->setOn( true ); | 180 | if ( a ) a->setOn( true ); |
181 | else owarn << "can't set zoom" << oendl; | 181 | else owarn << "can't set zoom" << oendl; |
182 | 182 | ||
183 | flipg = new QActionGroup( 0, "flip", true ); | 183 | flipg = new QActionGroup( 0, "flip", true ); |
184 | flipg->setToggleAction( true ); | 184 | flipg->setToggleAction( true ); |
185 | new QAction( "Auto (recommended)", 0, 0, flipg, "A", true ); | 185 | new QAction( "Auto (recommended)", 0, 0, flipg, "A", true ); |
186 | new QAction( "0 (always off)", 0, 0, flipg, "0", true ); | 186 | new QAction( "0 (always off)", 0, 0, flipg, "0", true ); |
187 | new QAction( "X (always horizontal)", 0, 0, flipg, "X", true ); | 187 | new QAction( "X (always horizontal)", 0, 0, flipg, "X", true ); |
188 | new QAction( "Y (always vertical)", 0, 0, flipg, "Y", true ); | 188 | new QAction( "Y (always vertical)", 0, 0, flipg, "Y", true ); |
189 | new QAction( "* (always both)", 0, 0, flipg, "*", true ); | 189 | new QAction( "* (always both)", 0, 0, flipg, "*", true ); |
190 | a = (QAction*) flipg->child( QString().sprintf( "%s", (const char*) flip ) ); | 190 | a = (QAction*) flipg->child( QString().sprintf( "%s", (const char*) flip ) ); |
191 | if ( a ) a->setOn( true ); | 191 | if ( a ) a->setOn( true ); |
192 | else owarn << "can't set flip" << oendl; | 192 | else owarn << "can't set flip" << oendl; |
193 | 193 | ||
194 | outputTog = new QActionGroup( 0, "output", true ); | 194 | outputTog = new QActionGroup( 0, "output", true ); |
195 | outputTog->setToggleAction( true ); | 195 | outputTog->setToggleAction( true ); |
196 | new QAction( "/tmp/", 0, 0, outputTog, "/tmp/", true ); | 196 | new QAction( "/tmp/", 0, 0, outputTog, "/tmp/", true ); |
197 | new QAction( "/mnt/card/", 0, 0, outputTog, "/mnt/card/", true ); | 197 | new QAction( "/mnt/card/", 0, 0, outputTog, "/mnt/card/", true ); |
198 | new QAction( "/mnt/cf/", 0, 0, outputTog, "/mnt/cf/", true ); | 198 | new QAction( "/mnt/cf/", 0, 0, outputTog, "/mnt/cf/", true ); |
199 | docfolder = new QAction( "Documents Folder", 0, 0, outputTog, "Documents Folder", true ); | 199 | docfolder = new QAction( "Documents Folder", 0, 0, outputTog, "Documents Folder", true ); |
200 | custom = new QAction( "&Custom...", 0, 0, outputTog, "custom", true ); //TODO: How to save custom!? | 200 | custom = new QAction( "&Custom...", 0, 0, outputTog, "custom", true ); //TODO: How to save custom!? |
201 | a = (QAction*) outputTog->child( QString().sprintf( "%s", (const char*) outputTo ) ); | 201 | a = (QAction*) outputTog->child( QString().sprintf( "%s", (const char*) outputTo ) ); |
202 | if ( a ) a->setOn( true ); | 202 | if ( a ) a->setOn( true ); |
203 | else owarn << "can't set outputTo" << oendl; | 203 | else owarn << "can't set outputTo" << oendl; |
204 | 204 | ||
205 | outputg = new QActionGroup( 0, "output", true ); | 205 | outputg = new QActionGroup( 0, "output", true ); |
206 | outputg->setToggleAction( true ); | 206 | outputg->setToggleAction( true ); |
207 | new QAction( "JPEG", 0, 0, outputg, "JPEG", true ); | 207 | new QAction( "JPEG", 0, 0, outputg, "JPEG", true ); |
208 | new QAction( "PNG", 0, 0, outputg, "PNG", true ); | 208 | new QAction( "PNG", 0, 0, outputg, "PNG", true ); |
209 | new QAction( "BMP", 0, 0, outputg, "BMP", true ); | 209 | new QAction( "BMP", 0, 0, outputg, "BMP", true ); |
210 | new QAction( "AVI", 0, 0, outputg, "AVI", true ); | 210 | new QAction( "AVI", 0, 0, outputg, "AVI", true ); |
211 | a = (QAction*) outputg->child( QString().sprintf( "%s", (const char*) captureFormat ) ); | 211 | a = (QAction*) outputg->child( QString().sprintf( "%s", (const char*) captureFormat ) ); |
212 | if ( a ) a->setOn( true ); | 212 | if ( a ) a->setOn( true ); |
213 | else owarn << "can't set output format" << oendl; | 213 | else owarn << "can't set output format" << oendl; |
214 | 214 | ||
215 | connect( resog, SIGNAL( selected(QAction*) ), this, SLOT( resoMenuItemClicked(QAction*) ) ); | 215 | connect( resog, SIGNAL( selected(QAction*) ), this, SLOT( resoMenuItemClicked(QAction*) ) ); |
216 | connect( qualityg, SIGNAL( selected(QAction*) ), this, SLOT( qualityMenuItemClicked(QAction*) ) ); | 216 | connect( qualityg, SIGNAL( selected(QAction*) ), this, SLOT( qualityMenuItemClicked(QAction*) ) ); |
217 | connect( zoomg, SIGNAL( selected(QAction*) ), this, SLOT( zoomMenuItemClicked(QAction*) ) ); | 217 | connect( zoomg, SIGNAL( selected(QAction*) ), this, SLOT( zoomMenuItemClicked(QAction*) ) ); |
218 | connect( flipg, SIGNAL( selected(QAction*) ), this, SLOT( flipMenuItemClicked(QAction*) ) ); | 218 | connect( flipg, SIGNAL( selected(QAction*) ), this, SLOT( flipMenuItemClicked(QAction*) ) ); |
219 | connect( outputTog, SIGNAL( selected(QAction*) ), this, SLOT( outputToMenuItemClicked(QAction*) ) ); | 219 | connect( outputTog, SIGNAL( selected(QAction*) ), this, SLOT( outputToMenuItemClicked(QAction*) ) ); |
220 | connect( outputg, SIGNAL( selected(QAction*) ), this, SLOT( outputMenuItemClicked(QAction*) ) ); | 220 | connect( outputg, SIGNAL( selected(QAction*) ), this, SLOT( outputMenuItemClicked(QAction*) ) ); |
221 | } | 221 | } |
222 | 222 | ||
223 | 223 | ||
224 | void CameraMainWindow::systemMessage( const QCString& msg, const QByteArray& data ) | 224 | void CameraMainWindow::systemMessage( const QCString& msg, const QByteArray& data ) |
225 | { | 225 | { |
226 | int _newrotation; | 226 | int _newrotation; |
227 | 227 | ||
228 | QDataStream stream( data, IO_ReadOnly ); | 228 | QDataStream stream( data, IO_ReadOnly ); |
229 | odebug << "received system message: " << msg << oendl; | 229 | odebug << "received system message: " << msg << oendl; |
230 | if ( msg == "setCurrentRotation(int)" ) | 230 | if ( msg == "setCurrentRotation(int)" ) |
231 | { | 231 | { |
232 | stream >> _newrotation; | 232 | stream >> _newrotation; |
233 | odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl; | 233 | odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl; |
234 | 234 | ||
235 | switch ( _newrotation ) | 235 | switch ( _newrotation ) |
236 | { | 236 | { |
237 | case 270: preview->resize( QSize( 240, 288 ) ); break; | 237 | case 270: preview->resize( QSize( 240, 288 ) ); break; |
238 | case 180: preview->resize( QSize( 320, 208 ) ); break; | 238 | case 180: preview->resize( QSize( 320, 208 ) ); break; |
239 | default: QMessageBox::warning( this, "opie-camera", | 239 | default: QMessageBox::warning( this, "opie-camera", |
240 | "This rotation is not supported.\n" | 240 | "This rotation is not supported.\n" |
241 | "Supported are 180° and 270°" ); | 241 | "Supported are 180° and 270°" ); |
242 | } | 242 | } |
243 | 243 | ||
244 | if ( _newrotation != _rotation ) | 244 | if ( _newrotation != _rotation ) |
245 | { | 245 | { |
246 | int tmp = captureX; | 246 | int tmp = captureX; |
247 | captureX = captureY; | 247 | captureX = captureY; |
248 | captureY = tmp; | 248 | captureY = tmp; |
249 | _rotation = _newrotation; | 249 | _rotation = _newrotation; |
250 | } | 250 | } |
251 | 251 | ||
252 | updateCaption(); | 252 | updateCaption(); |
253 | 253 | ||
254 | } | 254 | } |
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | void CameraMainWindow::changeZoom( int zoom ) | 258 | void CameraMainWindow::changeZoom( int zoom ) |
259 | { | 259 | { |
260 | int z; | 260 | int z; |
261 | switch ( zoom ) | 261 | switch ( zoom ) |
262 | { | 262 | { |
263 | case 0: z = 128; break; | 263 | case 0: z = 128; break; |
264 | case 1: z = 256; break; | 264 | case 1: z = 256; break; |
265 | case 2: z = 512; break; | 265 | case 2: z = 512; break; |
266 | default: assert( 0 ); break; | 266 | default: assert( 0 ); break; |
267 | } | 267 | } |
268 | 268 | ||
269 | ZCameraIO::instance()->setCaptureFrame( 240, 160, z ); | 269 | ZCameraIO::instance()->setCaptureFrame( 240, 160, z ); |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
273 | void CameraMainWindow::showContextMenu() | 273 | void CameraMainWindow::showContextMenu() |
274 | { | 274 | { |
275 | QPopupMenu reso; | 275 | QPopupMenu reso; |
276 | reso.setCheckable( true ); | 276 | reso.setCheckable( true ); |
277 | resog->addTo( &reso ); | 277 | resog->addTo( &reso ); |
278 | 278 | ||
279 | QPopupMenu quality; | 279 | QPopupMenu quality; |
280 | quality.setCheckable( true ); | 280 | quality.setCheckable( true ); |
281 | qualityg->addTo( &quality ); | 281 | qualityg->addTo( &quality ); |
282 | 282 | ||
283 | QPopupMenu flip; | 283 | QPopupMenu flip; |
284 | flip.setCheckable( true ); | 284 | flip.setCheckable( true ); |
285 | flipg->addTo( &flip ); | 285 | flipg->addTo( &flip ); |
286 | 286 | ||
287 | QPopupMenu zoom; | 287 | QPopupMenu zoom; |
288 | zoom.setCheckable( true ); | 288 | zoom.setCheckable( true ); |
289 | zoomg->addTo( &zoom ); | 289 | zoomg->addTo( &zoom ); |
290 | 290 | ||
291 | QPopupMenu prefix; | 291 | QPopupMenu prefix; |
292 | prefix.insertItem( "&Choose...", this, SLOT( prefixItemChoosen() ) ); | 292 | prefix.insertItem( "&Choose...", this, SLOT( prefixItemChoosen() ) ); |
293 | int id = prefix.insertItem( "&Append Settings", this, SLOT( appendSettingsChoosen() ) ); | 293 | int id = prefix.insertItem( "&Append Settings", this, SLOT( appendSettingsChoosen() ) ); |
294 | prefix.setItemChecked( id, appendSettings ); | 294 | prefix.setItemChecked( id, appendSettings ); |
295 | 295 | ||
296 | QPopupMenu outputTo; | 296 | QPopupMenu outputTo; |
297 | outputTo.setCheckable( true ); | 297 | outputTo.setCheckable( true ); |
298 | outputTog->addTo( &outputTo ); | 298 | outputTog->addTo( &outputTo ); |
299 | 299 | ||
300 | QPopupMenu output; | 300 | QPopupMenu output; |
301 | output.setCheckable( true ); | 301 | output.setCheckable( true ); |
302 | outputg->addTo( &output ); | 302 | outputg->addTo( &output ); |
303 | 303 | ||
304 | QPopupMenu m( this ); | 304 | QPopupMenu m( this ); |
305 | m.insertItem( "&Resolution", &reso ); | 305 | m.insertItem( "&Resolution", &reso ); |
306 | m.insertItem( "&Zoom", &zoom ); | 306 | m.insertItem( "&Zoom", &zoom ); |
307 | m.insertItem( "&Flip", &flip ); | 307 | m.insertItem( "&Flip", &flip ); |
308 | m.insertItem( "&Quality", &quality ); | 308 | m.insertItem( "&Quality", &quality ); |
309 | m.insertSeparator(); | 309 | m.insertSeparator(); |
310 | m.insertItem( "&Prefix", &prefix ); | 310 | m.insertItem( "&Prefix", &prefix ); |
311 | m.insertItem( "Output &To", &outputTo ); | 311 | m.insertItem( "Output &To", &outputTo ); |
312 | m.insertItem( "&Output As", &output ); | 312 | m.insertItem( "&Output As", &output ); |
313 | 313 | ||
314 | #ifndef QT_NO_DEBUG | 314 | #ifndef QT_NO_DEBUG |
315 | m.insertItem( "&Debug!", this, SLOT( doSomething() ) ); | 315 | m.insertItem( "&Debug!", this, SLOT( doSomething() ) ); |
316 | #endif | 316 | #endif |
317 | 317 | ||
318 | m.exec( QCursor::pos() ); | 318 | m.exec( QCursor::pos() ); |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | void CameraMainWindow::resoMenuItemClicked( QAction* a ) | 322 | void CameraMainWindow::resoMenuItemClicked( QAction* a ) |
323 | { | 323 | { |
324 | switch ( _rotation ) | 324 | switch ( _rotation ) |
325 | { | 325 | { |
326 | case 270: | 326 | case 270: |
327 | captureY = a->text().left(3).toInt(); | 327 | captureY = a->text().left(3).toInt(); |
328 | captureX = a->text().right(3).toInt(); | 328 | captureX = a->text().right(3).toInt(); |
329 | break; | 329 | break; |
330 | case 180: | 330 | case 180: |
331 | captureX = a->text().left(3).toInt(); | 331 | captureX = a->text().left(3).toInt(); |
332 | captureY = a->text().right(3).toInt(); | 332 | captureY = a->text().right(3).toInt(); |
333 | break; | 333 | break; |
334 | default: QMessageBox::warning( this, "opie-camera", | 334 | default: QMessageBox::warning( this, "opie-camera", |
335 | "This rotation is not supported.\n" | 335 | "This rotation is not supported.\n" |
336 | "Supported are 180° and 270°" ); | 336 | "Supported are 180° and 270°" ); |
337 | } | 337 | } |
338 | odebug << "Capture Resolution now: " << captureX << ", " << captureY << oendl; | 338 | odebug << "Capture Resolution now: " << captureX << ", " << captureY << oendl; |
339 | updateCaption(); | 339 | updateCaption(); |
340 | } | 340 | } |
341 | 341 | ||
342 | 342 | ||
343 | void CameraMainWindow::qualityMenuItemClicked( QAction* a ) | 343 | void CameraMainWindow::qualityMenuItemClicked( QAction* a ) |
344 | { | 344 | { |
345 | quality = a->text().left(3).toInt(); | 345 | quality = a->text().left(3).toInt(); |
346 | odebug << "Quality now: " << quality << oendl; | 346 | odebug << "Quality now: " << quality << oendl; |
347 | updateCaption(); | 347 | updateCaption(); |
348 | } | 348 | } |
349 | 349 | ||
350 | 350 | ||
351 | void CameraMainWindow::zoomMenuItemClicked( QAction* a ) | 351 | void CameraMainWindow::zoomMenuItemClicked( QAction* a ) |
352 | { | 352 | { |
353 | zoom = QString( a->text().at(2) ).toInt(); | 353 | zoom = QString( a->text().at(2) ).toInt(); |
354 | odebug << "Zoom now: " << zoom << oendl; | 354 | odebug << "Zoom now: " << zoom << oendl; |
355 | ZCameraIO::instance()->setZoom( zoom ); | 355 | ZCameraIO::instance()->setZoom( zoom ); |
356 | updateCaption(); | 356 | updateCaption(); |
357 | } | 357 | } |
358 | 358 | ||
359 | 359 | ||
360 | void CameraMainWindow::flipMenuItemClicked( QAction* a ) | 360 | void CameraMainWindow::flipMenuItemClicked( QAction* a ) |
361 | { | 361 | { |
362 | flip = QString( a->text().at(0) ); | 362 | flip = QString( a->text().at(0) ); |
363 | odebug << "Flip now: " << flip << oendl; | 363 | odebug << "Flip now: " << flip << oendl; |
364 | if ( flip == "A" ) | 364 | if ( flip == "A" ) |
365 | ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP ); | 365 | ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP ); |
366 | else if ( flip == "0" ) | 366 | else if ( flip == "0" ) |
367 | ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP ); | 367 | ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP ); |
368 | else if ( flip == "X" ) | 368 | else if ( flip == "X" ) |
369 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP ); | 369 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP ); |
370 | else if ( flip == "Y" ) | 370 | else if ( flip == "Y" ) |
371 | ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP ); | 371 | ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP ); |
372 | else if ( flip == "*" ) | 372 | else if ( flip == "*" ) |
373 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP ); | 373 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP ); |
374 | 374 | ||
375 | updateCaption(); | 375 | updateCaption(); |
376 | } | 376 | } |
377 | 377 | ||
378 | 378 | ||
379 | void CameraMainWindow::outputToMenuItemClicked( QAction* a ) | 379 | void CameraMainWindow::outputToMenuItemClicked( QAction* a ) |
380 | { | 380 | { |
381 | if ( a->text() == "&Custom..." ) | 381 | if ( a->text() == "&Custom..." ) |
382 | { | 382 | { |
383 | QMap<QString, QStringList> map; | 383 | QMap<QString, QStringList> map; |
384 | map.insert( tr("All"), QStringList() ); | 384 | map.insert( tr("All"), QStringList() ); |
385 | QStringList text; | 385 | QStringList text; |
386 | text << "text/*"; | 386 | text << "text/*"; |
387 | map.insert(tr("Text"), text ); | 387 | map.insert(tr("Text"), text ); |
388 | text << "*"; | 388 | text << "*"; |
389 | map.insert(tr("All"), text ); | 389 | map.insert(tr("All"), text ); |
390 | 390 | ||
391 | QString str; | 391 | QString str; |
392 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); | 392 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); |
393 | if ( str.isEmpty() || !QFileInfo(str).isDir() ) | 393 | if ( str.isEmpty() || !QFileInfo(str).isDir() ) |
394 | { | 394 | { |
395 | docfolder->setOn( true ); | 395 | docfolder->setOn( true ); |
396 | outputTo = "Documents Folder"; | 396 | outputTo = "Documents Folder"; |
397 | } | 397 | } |
398 | else | 398 | else |
399 | { | 399 | { |
400 | outputTo = str; | 400 | outputTo = str; |
401 | } | 401 | } |
402 | } | 402 | } |
403 | else | 403 | else |
404 | { | 404 | { |
405 | outputTo = a->text(); | 405 | outputTo = a->text(); |
406 | } | 406 | } |
407 | odebug << "Output to now: " << outputTo << oendl; | 407 | odebug << "Output to now: " << outputTo << oendl; |
408 | } | 408 | } |
409 | 409 | ||
410 | 410 | ||
411 | void CameraMainWindow::outputMenuItemClicked( QAction* a ) | 411 | void CameraMainWindow::outputMenuItemClicked( QAction* a ) |
412 | { | 412 | { |
413 | captureFormat = a->text(); | 413 | captureFormat = a->text(); |
414 | odebug << "Output format now: " << captureFormat << oendl; | 414 | odebug << "Output format now: " << captureFormat << oendl; |
415 | updateCaption(); | 415 | updateCaption(); |
416 | } | 416 | } |
417 | 417 | ||
418 | 418 | ||
419 | void CameraMainWindow::prefixItemChoosen() | 419 | void CameraMainWindow::prefixItemChoosen() |
420 | { | 420 | { |
421 | QDialog* d = new QDialog( this, "dialog", true ); | 421 | QDialog* d = new QDialog( this, "dialog", true ); |
422 | d->setCaption( "Enter Prefix..." ); | 422 | d->setCaption( "Enter Prefix..." ); |
423 | QVBoxLayout* v = new QVBoxLayout( d ); | 423 | QVBoxLayout* v = new QVBoxLayout( d ); |
424 | QLineEdit* le = new QLineEdit( prefix, d ); | 424 | QLineEdit* le = new QLineEdit( prefix, d ); |
425 | v->addWidget( le ); | 425 | v->addWidget( le ); |
426 | le->setFixedWidth( 150 ); //FIXME: 'tis a bit dirty | 426 | le->setFixedWidth( 150 ); //FIXME: 'tis a bit dirty |
427 | if ( d->exec() == QDialog::Accepted ) | 427 | if ( d->exec() == QDialog::Accepted ) |
428 | prefix = le->text(); | 428 | prefix = le->text(); |
429 | odebug << "Prefix now: " << prefix << oendl; | 429 | odebug << "Prefix now: " << prefix << oendl; |
430 | } | 430 | } |
431 | 431 | ||
432 | 432 | ||
433 | void CameraMainWindow::appendSettingsChoosen() | 433 | void CameraMainWindow::appendSettingsChoosen() |
434 | { | 434 | { |
435 | appendSettings = !appendSettings; | 435 | appendSettings = !appendSettings; |
436 | odebug << "appendSettings now: " << appendSettings << oendl; | 436 | odebug << "appendSettings now: " << appendSettings << oendl; |
437 | } | 437 | } |
438 | 438 | ||
439 | 439 | ||
440 | void CameraMainWindow::shutterClicked() | 440 | void CameraMainWindow::shutterClicked() |
441 | { | 441 | { |
442 | if ( captureFormat != "AVI" ) // capture one photo per shutterClick | 442 | if ( captureFormat != "AVI" ) // capture one photo per shutterClick |
443 | { | 443 | { |
444 | Global::statusMessage( "CAPTURING..." ); | 444 | Global::statusMessage( "CAPTURING..." ); |
445 | qApp->processEvents(); | 445 | qApp->processEvents(); |
446 | 446 | ||
447 | odebug << "Shutter has been pressed" << oendl; | 447 | odebug << "Shutter has been pressed" << oendl; |
448 | ODevice::inst()->playTouchSound(); | 448 | ODevice::inst()->playTouchSound(); |
449 | 449 | ||
450 | performCapture( captureFormat ); | 450 | performCapture( captureFormat ); |
451 | } | 451 | } |
452 | else // capture video! start with one shutter click and stop with the next | 452 | else // capture video! start with one shutter click and stop with the next |
453 | { | 453 | { |
454 | !_capturing ? startVideoCapture() : stopVideoCapture(); | 454 | !_capturing ? startVideoCapture() : stopVideoCapture(); |
455 | } | 455 | } |
456 | } | 456 | } |
457 | 457 | ||
458 | 458 | ||
459 | void CameraMainWindow::performCapture( const QString& format ) | 459 | void CameraMainWindow::performCapture( const QString& format ) |
460 | { | 460 | { |
461 | QString name; | 461 | QString name; |
462 | 462 | ||
463 | if ( outputTo == "Documents Folder" ) | 463 | if ( outputTo == "Documents Folder" ) |
464 | { | 464 | { |
465 | name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); | 465 | name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); |
466 | if ( !QDir( name ).exists() ) | 466 | if ( !QDir( name ).exists() ) |
467 | { | 467 | { |
468 | odebug << "creating directory " << name << oendl; | 468 | odebug << "creating directory " << name << oendl; |
469 | QString msg = "mkdir -p " + name; | 469 | QString msg = "mkdir -p " + name; |
470 | system( msg.latin1() ); | 470 | system( msg.latin1() ); |
471 | } | 471 | } |
472 | } | 472 | } |
473 | else | 473 | else |
474 | name = outputTo; | 474 | name = outputTo; |
475 | 475 | ||
476 | name.append( prefix ); | 476 | name.append( prefix ); |
477 | if ( appendSettings ) | 477 | if ( appendSettings ) |
478 | { | 478 | { |
479 | name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) ); | 479 | name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) ); |
480 | } | 480 | } |
481 | name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) ); | 481 | name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) ); |
482 | 482 | ||
483 | QImage i; | 483 | QImage i; |
484 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i ); | 484 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i ); |
485 | QImage im = i.convertDepth( 32 ); | 485 | QImage im = i.convertDepth( 32 ); |
486 | bool result = im.save( name, format, quality ); | 486 | bool result = im.save( name, format, quality ); |
487 | if ( !result ) | 487 | if ( !result ) |
488 | { | 488 | { |
489 | oerr << "imageio-Problem while writing." << oendl; | 489 | oerr << "imageio-Problem while writing." << oendl; |
490 | Global::statusMessage( "Error!" ); | 490 | Global::statusMessage( "Error!" ); |
491 | } | 491 | } |
492 | else | 492 | else |
493 | { | 493 | { |
494 | odebug << captureFormat << "-image has been successfully captured" << oendl; | 494 | odebug << captureFormat << "-image has been successfully captured" << oendl; |
495 | Global::statusMessage( "Ok." ); | 495 | Global::statusMessage( "Ok." ); |
496 | } | 496 | } |
497 | } | 497 | } |
498 | 498 | ||
499 | 499 | ||
500 | void CameraMainWindow::startVideoCapture() | 500 | void CameraMainWindow::startVideoCapture() |
501 | { | 501 | { |
502 | ODevice::inst()->playTouchSound(); | 502 | ODevice::inst()->playTouchSound(); |
503 | ODevice::inst()->setLedState( Led_Mail, Led_BlinkSlow ); | 503 | ODevice::inst()->setLedState( Led_Mail, Led_BlinkSlow ); |
504 | 504 | ||
505 | _capturefd = ::open( CAPTUREFILE, O_WRONLY | O_CREAT | O_TRUNC ); | 505 | _capturefd = ::open( CAPTUREFILE, O_WRONLY | O_CREAT | O_TRUNC ); |
506 | if ( _capturefd == -1 ) | 506 | if ( _capturefd == -1 ) |
507 | { | 507 | { |
508 | owarn << "can't open capture file: " << strerror(errno) << oendl; | 508 | owarn << "can't open capture file: " << strerror(errno) << oendl; |
509 | return; | 509 | return; |
510 | } | 510 | } |
511 | 511 | ||
512 | _capturebuf = new unsigned char[captureX*captureY*2]; | 512 | _capturebuf = new unsigned char[captureX*captureY*2]; |
513 | _capturing = true; | 513 | _capturing = true; |
514 | _videopics = 0; | 514 | _videopics = 0; |
515 | _framerate = 0; | 515 | _framerate = 0; |
516 | updateCaption(); | 516 | updateCaption(); |
517 | _time.start(); | 517 | _time.start(); |
518 | preview->setRefreshingRate( 1000 ); | 518 | preview->setRefreshingRate( 1000 ); |
519 | startTimer( 100 ); // too fast but that is ok | 519 | startTimer( 100 ); // too fast but that is ok |
520 | } | 520 | } |
521 | 521 | ||
522 | 522 | ||
523 | void CameraMainWindow::timerEvent( QTimerEvent* ) | 523 | void CameraMainWindow::timerEvent( QTimerEvent* ) |
524 | { | 524 | { |
525 | if ( !_capturing ) | 525 | if ( !_capturing ) |
526 | { | 526 | { |
527 | odebug << "timer event in CameraMainWindow without capturing video ?" << oendl; | 527 | odebug << "timer event in CameraMainWindow without capturing video ?" << oendl; |
528 | return; | 528 | return; |
529 | } | 529 | } |
530 | 530 | ||
531 | odebug << "timer event during video - now capturing frame #" << _videopics+1 << oendl; | 531 | odebug << "timer event during video - now capturing frame #" << _videopics+1 << oendl; |
532 | 532 | ||
533 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, _capturebuf ); | 533 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, _capturebuf ); |
534 | _videopics++; | 534 | _videopics++; |
535 | ::write( _capturefd, _capturebuf, captureX*captureY*2 ); | 535 | ::write( _capturefd, _capturebuf, captureX*captureY*2 ); |
536 | setCaption( QString().sprintf( "Capturing %dx%d @ %.2f fps %d", | 536 | setCaption( QString().sprintf( "Capturing %dx%d @ %.2f fps %d", |
537 | captureX, captureY, 1000.0 / (_time.elapsed()/_videopics), _videopics ) ); | 537 | captureX, captureY, 1000.0 / (_time.elapsed()/_videopics), _videopics ) ); |
538 | } | 538 | } |
539 | 539 | ||
540 | 540 | ||
541 | void CameraMainWindow::stopVideoCapture() | 541 | void CameraMainWindow::stopVideoCapture() |
542 | { | 542 | { |
543 | killTimers(); | 543 | killTimers(); |
544 | ODevice::inst()->playTouchSound(); | 544 | ODevice::inst()->playTouchSound(); |
545 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); | 545 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); |
546 | _capturing = false; | 546 | _capturing = false; |
547 | updateCaption(); | 547 | updateCaption(); |
548 | ::close( _capturefd ); | 548 | ::close( _capturefd ); |
549 | _framerate = 1000.0 / (_time.elapsed()/_videopics); | 549 | _framerate = static_cast<int>( 1000.0 / (_time.elapsed()/_videopics) ); |
550 | 550 | ||
551 | QString name; | 551 | QString name; |
552 | if ( outputTo == "Documents Folder" ) | 552 | if ( outputTo == "Documents Folder" ) |
553 | { | 553 | { |
554 | name.sprintf( "%s/Documents/video/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); | 554 | name.sprintf( "%s/Documents/video/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); |
555 | if ( !QDir( name ).exists() ) | 555 | if ( !QDir( name ).exists() ) |
556 | { | 556 | { |
557 | odebug << "creating directory " << name << oendl; | 557 | odebug << "creating directory " << name << oendl; |
558 | QString msg = "mkdir -p " + name; | 558 | QString msg = "mkdir -p " + name; |
559 | system( msg.latin1() ); | 559 | system( msg.latin1() ); |
560 | } | 560 | } |
561 | } | 561 | } |
562 | else | 562 | else |
563 | name = outputTo; | 563 | name = outputTo; |
564 | 564 | ||
565 | name.append( "/" ); // sure is sure and safe is safe ;-) | 565 | name.append( "/" ); // sure is sure and safe is safe ;-) |
566 | name.append( prefix ); | 566 | name.append( prefix ); |
567 | if ( appendSettings ) | 567 | if ( appendSettings ) |
568 | name.append( QString().sprintf( "_%d_%d_q%d_%dfps", captureX, captureY, quality, _framerate ) ); | 568 | name.append( QString().sprintf( "_%d_%d_q%d_%dfps", captureX, captureY, quality, _framerate ) ); |
569 | name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) ); | 569 | name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) ); |
570 | postProcessVideo( CAPTUREFILE, name ); | 570 | postProcessVideo( CAPTUREFILE, name ); |
571 | 571 | ||
572 | #ifndef QT_NO_DEBUG | 572 | #ifndef QT_NO_DEBUG |
573 | preview->setRefreshingRate( 1500 ); | 573 | preview->setRefreshingRate( 1500 ); |
574 | #else | 574 | #else |
575 | preview->setRefreshingRate( 200 ); | 575 | preview->setRefreshingRate( 200 ); |
576 | #endif | 576 | #endif |
577 | 577 | ||
578 | //delete[] _capturebuf; //FIXME: close memory leak | 578 | //delete[] _capturebuf; //FIXME: close memory leak |
579 | } | 579 | } |
580 | 580 | ||
581 | void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile ) | 581 | void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile ) |
582 | { | 582 | { |
583 | odebug << "post processing " << infile << " --> " << outfile << oendl; | 583 | odebug << "post processing " << infile << " --> " << outfile << oendl; |
584 | 584 | ||
585 | preview->setRefreshingRate( 0 ); | 585 | preview->setRefreshingRate( 0 ); |
586 | 586 | ||
587 | /* | 587 | /* |
588 | unsigned char buf[153600]; | 588 | unsigned char buf[153600]; |
589 | 589 | ||
590 | int fd = ::open( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", O_RDONLY ); | 590 | int fd = ::open( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", O_RDONLY ); |
591 | ::read( fd, &buf, 153600 ); | 591 | ::read( fd, &buf, 153600 ); |
592 | QImage i; | 592 | QImage i; |
593 | bufferToImage( 240, 320, (unsigned char*) &buf, &i ); | 593 | bufferToImage( 240, 320, (unsigned char*) &buf, &i ); |
594 | QPixmap p; | 594 | QPixmap p; |
595 | p.convertFromImage( i ); | 595 | p.convertFromImage( i ); |
596 | preview->setPixmap( p ); | 596 | preview->setPixmap( p ); |
597 | imageToFile( &i, "/tmp/tmpfile", "JPEG", 100 ); | 597 | imageToFile( &i, "/tmp/tmpfile", "JPEG", 100 ); |
598 | return; | 598 | return; |
599 | */ | 599 | */ |
600 | 600 | ||
601 | QDialog* fr = new QDialog( this, "splash", false, QWidget::WStyle_StaysOnTop ); //, false, QWidget::WStyle_NoBorder | QWidget::WStyle_Customize ); | 601 | QDialog* fr = new QDialog( this, "splash", false, QWidget::WStyle_StaysOnTop ); //, false, QWidget::WStyle_NoBorder | QWidget::WStyle_Customize ); |
602 | fr->setCaption( "Please wait..." ); | 602 | fr->setCaption( "Please wait..." ); |
603 | QVBoxLayout* box = new QVBoxLayout( fr, 2, 2 ); | 603 | QVBoxLayout* box = new QVBoxLayout( fr, 2, 2 ); |
604 | QProgressBar* bar = new QProgressBar( fr ); | 604 | QProgressBar* bar = new QProgressBar( fr ); |
605 | bar->setCenterIndicator( true ); | 605 | bar->setCenterIndicator( true ); |
606 | bar->setTotalSteps( _videopics-1 ); | 606 | bar->setTotalSteps( _videopics-1 ); |
607 | QLabel* label = new QLabel( "Post processing frame bla/bla", fr ); | 607 | QLabel* label = new QLabel( "Post processing frame bla/bla", fr ); |
608 | box->addWidget( bar ); | 608 | box->addWidget( bar ); |
609 | box->addWidget( label ); | 609 | box->addWidget( label ); |
610 | fr->show(); | 610 | fr->show(); |
611 | label->show(); | 611 | label->show(); |
612 | bar->show(); | 612 | bar->show(); |
613 | fr->repaint(); | 613 | fr->repaint(); |
614 | qApp->processEvents(); | 614 | qApp->processEvents(); |
615 | 615 | ||
616 | // open files | 616 | // open files |
617 | 617 | ||
618 | int infd = ::open( (const char*) infile, O_RDONLY ); | 618 | int infd = ::open( (const char*) infile, O_RDONLY ); |
619 | if ( infd == -1 ) | 619 | if ( infd == -1 ) |
620 | { | 620 | { |
621 | owarn << "couldn't open capture file: " << strerror(errno) << oendl; | 621 | owarn << "couldn't open capture file: " << strerror(errno) << oendl; |
622 | return; | 622 | return; |
623 | } | 623 | } |
624 | 624 | ||
625 | int outfd = ::open( (const char*) outfile, O_CREAT | O_WRONLY | O_TRUNC, 0644 ); | 625 | int outfd = ::open( (const char*) outfile, O_CREAT | O_WRONLY | O_TRUNC, 0644 ); |
626 | if ( outfd == -1 ) | 626 | if ( outfd == -1 ) |
627 | { | 627 | { |
628 | owarn << "couldn't open output file: " << strerror(errno) << oendl; | 628 | owarn << "couldn't open output file: " << strerror(errno) << oendl; |
629 | return; | 629 | return; |
630 | } | 630 | } |
631 | 631 | ||
632 | int framesize = captureX*captureY*2; | 632 | int framesize = captureX*captureY*2; |
633 | 633 | ||
634 | unsigned char* inbuffer = new unsigned char[ framesize ]; | 634 | unsigned char* inbuffer = new unsigned char[ framesize ]; |
635 | QImage image; | 635 | QImage image; |
636 | 636 | ||
637 | avi_start( outfd, _videopics ); // write preambel | 637 | avi_start( outfd, _videopics ); // write preambel |
638 | 638 | ||
639 | // post process | 639 | // post process |
640 | 640 | ||
641 | for ( int i = 0; i < _videopics; ++i ) | 641 | for ( int i = 0; i < _videopics; ++i ) |
642 | { | 642 | { |
643 | odebug << "processing frame " << i << oendl; | 643 | odebug << "processing frame " << i << oendl; |
644 | 644 | ||
645 | // <gui> | 645 | // <gui> |
646 | label->setText( QString().sprintf( "Post processing frame %d / %d", i+1, _videopics ) ); | 646 | label->setText( QString().sprintf( "Post processing frame %d / %d", i+1, _videopics ) ); |
647 | bar->setProgress( i ); | 647 | bar->setProgress( i ); |
648 | bar->repaint(); | 648 | bar->repaint(); |
649 | qApp->processEvents(); | 649 | qApp->processEvents(); |
650 | // </gui> | 650 | // </gui> |
651 | 651 | ||
652 | int read = ::read( infd, inbuffer, framesize ); | 652 | int read = ::read( infd, inbuffer, framesize ); |
653 | odebug << "read " << read << " bytes" << oendl; | 653 | odebug << "read " << read << " bytes" << oendl; |
654 | bufferToImage( captureX, captureY, inbuffer, &image ); | 654 | bufferToImage( captureX, captureY, inbuffer, &image ); |
655 | 655 | ||
656 | QPixmap p; | 656 | QPixmap p; |
657 | p.convertFromImage( image ); | 657 | p.convertFromImage( image ); |
658 | preview->setPixmap( p ); | 658 | preview->setPixmap( p ); |
659 | preview->repaint(); | 659 | preview->repaint(); |
660 | qApp->processEvents(); | 660 | qApp->processEvents(); |
661 | 661 | ||
662 | #ifdef CAMERA_EXTRA_DEBUG | 662 | #ifdef CAMERA_EXTRA_DEBUG |
663 | QString tmpfilename; | 663 | QString tmpfilename; |
664 | tmpfilename.sprintf( "/tmp/test/%04d.jpg", i ); | 664 | tmpfilename.sprintf( "/tmp/test/%04d.jpg", i ); |
665 | #else | 665 | #else |
666 | QString tmpfilename( "/tmp/tempfile" ); | 666 | QString tmpfilename( "/tmp/tempfile" ); |
667 | #endif | 667 | #endif |
668 | 668 | ||
669 | imageToFile( &image, tmpfilename, "JPEG", quality ); | 669 | imageToFile( &image, tmpfilename, "JPEG", quality ); |
670 | 670 | ||
671 | QFile framefile( tmpfilename ); | 671 | QFile framefile( tmpfilename ); |
672 | if ( !framefile.open( IO_ReadOnly ) ) | 672 | if ( !framefile.open( IO_ReadOnly ) ) |
673 | { | 673 | { |
674 | oerr << "can't process file: %s" << strerror(errno) << oendl; | 674 | oerr << "can't process file: %s" << strerror(errno) << oendl; |
675 | return; // TODO: clean up temp ressources | 675 | return; // TODO: clean up temp ressources |
676 | } | 676 | } |
677 | 677 | ||
678 | int filesize = framefile.size(); | 678 | int filesize = framefile.size(); |
679 | odebug << "filesize for frame " << i << " = " << filesize << oendl; | 679 | odebug << "filesize for frame " << i << " = " << filesize << oendl; |
680 | 680 | ||
681 | unsigned char* tempbuffer = new unsigned char[ filesize ]; | 681 | unsigned char* tempbuffer = new unsigned char[ filesize ]; |
682 | framefile.readBlock( (char*) tempbuffer, filesize ); | 682 | framefile.readBlock( (char*) tempbuffer, filesize ); |
683 | avi_add( outfd, tempbuffer, filesize ); | 683 | avi_add( outfd, tempbuffer, filesize ); |
684 | delete tempbuffer; | 684 | delete tempbuffer; |
685 | framefile.close(); | 685 | framefile.close(); |
686 | 686 | ||
687 | } | 687 | } |
688 | 688 | ||
689 | avi_end( outfd, captureX, captureY, _framerate ); | 689 | avi_end( outfd, captureX, captureY, _framerate ); |
690 | ::close( outfd ); | 690 | ::close( outfd ); |
691 | ::close( infd ); | 691 | ::close( infd ); |
692 | 692 | ||
693 | label->setText( "deleting temp files..." ); | 693 | label->setText( "deleting temp files..." ); |
694 | qApp->processEvents(); | 694 | qApp->processEvents(); |
695 | odebug << "deleting temporary capturefile " << infile << oendl; | 695 | odebug << "deleting temporary capturefile " << infile << oendl; |
696 | QFile::remove( infile ); | 696 | QFile::remove( infile ); |
697 | 697 | ||
698 | fr->hide(); | 698 | fr->hide(); |
699 | delete fr; | 699 | delete fr; |
700 | 700 | ||
701 | updateCaption(); | 701 | updateCaption(); |
702 | 702 | ||
703 | } | 703 | } |
704 | 704 | ||
705 | 705 | ||
706 | void CameraMainWindow::updateCaption() | 706 | void CameraMainWindow::updateCaption() |
707 | { | 707 | { |
708 | if ( !_capturing ) | 708 | if ( !_capturing ) |
709 | setCaption( QString().sprintf( "Opie-Camera: %dx%d %s q%d z%d (%s)", captureX, captureY, (const char*) captureFormat.lower(), quality, zoom, (const char*) flip ) ); | 709 | setCaption( QString().sprintf( "Opie-Camera: %dx%d %s q%d z%d (%s)", captureX, captureY, (const char*) captureFormat.lower(), quality, zoom, (const char*) flip ) ); |
710 | else | 710 | else |
711 | setCaption( "Opie-Camera: => CAPTURING <=" ); | 711 | setCaption( "Opie-Camera: => CAPTURING <=" ); |
712 | qApp->processEvents(); | 712 | qApp->processEvents(); |
713 | } | 713 | } |
714 | 714 | ||
715 | 715 | ||
716 | #ifndef QT_NO_DEBUG | 716 | #ifndef QT_NO_DEBUG |
717 | void CameraMainWindow::doSomething() | 717 | void CameraMainWindow::doSomething() |
718 | { | 718 | { |
719 | captureX = 240; | 719 | captureX = 240; |
720 | captureY = 320; | 720 | captureY = 320; |
721 | _videopics = 50; | 721 | _videopics = 50; |
722 | _framerate = 5; | 722 | _framerate = 5; |
723 | postProcessVideo( "/var/compile/opie/noncore/multimedia/camera/capture.dat", | 723 | postProcessVideo( "/var/compile/opie/noncore/multimedia/camera/capture.dat", |
724 | "/tmp/output.avi" ); | 724 | "/tmp/output.avi" ); |
725 | } | 725 | } |
726 | #else | 726 | #else |
727 | void CameraMainWindow::doSomething() | 727 | void CameraMainWindow::doSomething() |
728 | { | 728 | { |
729 | } | 729 | } |
730 | #endif | 730 | #endif |
731 | 731 | ||
diff --git a/noncore/multimedia/camera/lib/avi.c b/noncore/multimedia/camera/lib/avi.c index 77aba33..d99c016 100644 --- a/noncore/multimedia/camera/lib/avi.c +++ b/noncore/multimedia/camera/lib/avi.c | |||
@@ -1,236 +1,237 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** Based on work from Andrew Tridgell and the jpegtoavi project | 3 | ** Based on work from Andrew Tridgell and the jpegtoavi project |
4 | ** | 4 | ** |
5 | ** This file is part of Opie Environment. | 5 | ** This file is part of Opie Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | **********************************************************************/ | 15 | **********************************************************************/ |
16 | 16 | ||
17 | #include "avi.h" | 17 | #include "avi.h" |
18 | 18 | ||
19 | #include <string.h> | 19 | #include <string.h> |
20 | #include <stdio.h> | 20 | #include <stdio.h> |
21 | #include <stdlib.h> | ||
21 | 22 | ||
22 | int nframes; | 23 | int nframes; |
23 | int totalsize; | 24 | int totalsize; |
24 | unsigned int* sizes; | 25 | unsigned int* sizes; |
25 | 26 | ||
26 | void fprint_quartet(int fd, unsigned int i) | 27 | void fprint_quartet(int fd, unsigned int i) |
27 | { | 28 | { |
28 | char data[4]; | 29 | char data[4]; |
29 | 30 | ||
30 | data[0] = (char) i%0x100; | 31 | data[0] = (char) i%0x100; |
31 | i /= 0x100; | 32 | i /= 0x100; |
32 | data[1] = (char) i%0x100; | 33 | data[1] = (char) i%0x100; |
33 | i /= 0x100; | 34 | i /= 0x100; |
34 | data[2] = (char) i%0x100; | 35 | data[2] = (char) i%0x100; |
35 | i /= 0x100; | 36 | i /= 0x100; |
36 | data[3] = (char) i%0x100; | 37 | data[3] = (char) i%0x100; |
37 | 38 | ||
38 | write( fd, &data, 4 ); | 39 | write( fd, &data, 4 ); |
39 | } | 40 | } |
40 | 41 | ||
41 | // start writing an AVI file | 42 | // start writing an AVI file |
42 | 43 | ||
43 | void avi_start(int fd, int frames) | 44 | void avi_start(int fd, int frames) |
44 | { | 45 | { |
45 | int ofs = sizeof(struct riff_head)+ | 46 | int ofs = sizeof(struct riff_head)+ |
46 | sizeof(struct list_head)+ | 47 | sizeof(struct list_head)+ |
47 | sizeof(struct avi_head)+ | 48 | sizeof(struct avi_head)+ |
48 | sizeof(struct list_head)+ | 49 | sizeof(struct list_head)+ |
49 | sizeof(struct stream_head)+ | 50 | sizeof(struct stream_head)+ |
50 | sizeof(struct frame_head)+ | 51 | sizeof(struct frame_head)+ |
51 | sizeof(struct list_head)+ | 52 | sizeof(struct list_head)+ |
52 | sizeof(struct dmlh_head)+ | 53 | sizeof(struct dmlh_head)+ |
53 | sizeof(struct list_head); | 54 | sizeof(struct list_head); |
54 | 55 | ||
55 | printf( "avi_start: frames = %d\n", frames ); | 56 | printf( "avi_start: frames = %d\n", frames ); |
56 | 57 | ||
57 | lseek(fd, ofs, SEEK_SET); | 58 | lseek(fd, ofs, SEEK_SET); |
58 | 59 | ||
59 | nframes = 0; | 60 | nframes = 0; |
60 | totalsize = 0; | 61 | totalsize = 0; |
61 | 62 | ||
62 | sizes = (unsigned int*) calloc( sizeof(unsigned int), frames ); // hold size of each frame | 63 | sizes = (unsigned int*) calloc( sizeof(unsigned int), frames ); // hold size of each frame |
63 | } | 64 | } |
64 | 65 | ||
65 | // add a jpeg frame to an AVI file | 66 | // add a jpeg frame to an AVI file |
66 | void avi_add(int fd, u8 *buf, int size) | 67 | void avi_add(int fd, u8 *buf, int size) |
67 | { | 68 | { |
68 | struct db_head db = {"00db", 0}; | 69 | struct db_head db = {"00db", 0}; |
69 | 70 | ||
70 | printf( "avi_add: nframes = %d, totalsize = %d, size = %d\n", nframes, totalsize, size ); | 71 | printf( "avi_add: nframes = %d, totalsize = %d, size = %d\n", nframes, totalsize, size ); |
71 | 72 | ||
72 | // overwrite JFIF type with AVI1 | 73 | // overwrite JFIF type with AVI1 |
73 | buf[6]='A'; | 74 | buf[6]='A'; |
74 | buf[7]='V'; | 75 | buf[7]='V'; |
75 | buf[8]='I'; | 76 | buf[8]='I'; |
76 | buf[9]='1'; | 77 | buf[9]='1'; |
77 | 78 | ||
78 | while( size%4 ) size++; // align 0 modulo 4*/ | 79 | while( size%4 ) size++; // align 0 modulo 4*/ |
79 | db.size = size; | 80 | db.size = size; |
80 | 81 | ||
81 | write( fd, &db, sizeof(db) ); | 82 | write( fd, &db, sizeof(db) ); |
82 | write( fd, buf, size ); | 83 | write( fd, buf, size ); |
83 | 84 | ||
84 | sizes[nframes] = size; | 85 | sizes[nframes] = size; |
85 | 86 | ||
86 | nframes++; | 87 | nframes++; |
87 | totalsize += size; // total frame size | 88 | totalsize += size; // total frame size |
88 | } | 89 | } |
89 | 90 | ||
90 | // finish writing the AVI file - filling in the header | 91 | // finish writing the AVI file - filling in the header |
91 | void avi_end(int fd, int width, int height, int fps) | 92 | void avi_end(int fd, int width, int height, int fps) |
92 | { | 93 | { |
93 | struct idx1_head idx = {"idx1", 16*nframes }; | 94 | struct idx1_head idx = {"idx1", 16*nframes }; |
94 | struct db_head db = {"00db", 0}; | 95 | struct db_head db = {"00db", 0}; |
95 | struct riff_head rh = { "RIFF", 0, "AVI "}; | 96 | struct riff_head rh = { "RIFF", 0, "AVI "}; |
96 | struct list_head lh1 = {"LIST", 0, "hdrl"}; | 97 | struct list_head lh1 = {"LIST", 0, "hdrl"}; |
97 | struct avi_head ah; | 98 | struct avi_head ah; |
98 | struct list_head lh2 = {"LIST", 0, "strl"}; | 99 | struct list_head lh2 = {"LIST", 0, "strl"}; |
99 | struct stream_head sh; | 100 | struct stream_head sh; |
100 | struct frame_head fh; | 101 | struct frame_head fh; |
101 | struct list_head lh3 = {"LIST", 0, "odml" }; | 102 | struct list_head lh3 = {"LIST", 0, "odml" }; |
102 | struct dmlh_head dh = {"dmlh", 4, nframes }; | 103 | struct dmlh_head dh = {"dmlh", 4, nframes }; |
103 | struct list_head lh4 = {"LIST", 0, "movi"}; | 104 | struct list_head lh4 = {"LIST", 0, "movi"}; |
104 | int i; | 105 | int i; |
105 | unsigned int offset = 4; | 106 | unsigned int offset = 4; |
106 | 107 | ||
107 | printf( "avi_end: nframes = %d, fps = %d\n", nframes, fps ); | 108 | printf( "avi_end: nframes = %d, fps = %d\n", nframes, fps ); |
108 | 109 | ||
109 | // write index | 110 | // write index |
110 | 111 | ||
111 | write(fd, &idx, sizeof(idx)); | 112 | write(fd, &idx, sizeof(idx)); |
112 | 113 | ||
113 | for ( i = 0; i < nframes; i++ ) | 114 | for ( i = 0; i < nframes; i++ ) |
114 | { | 115 | { |
115 | write(fd, &db, 4 ); // only need the 00db | 116 | write(fd, &db, 4 ); // only need the 00db |
116 | fprint_quartet( fd, 18 ); // ??? | 117 | fprint_quartet( fd, 18 ); // ??? |
117 | fprint_quartet( fd, offset ); | 118 | fprint_quartet( fd, offset ); |
118 | fprint_quartet( fd, sizes[i] ); | 119 | fprint_quartet( fd, sizes[i] ); |
119 | offset += sizes[i] + 8; //+8 (for the additional header) | 120 | offset += sizes[i] + 8; //+8 (for the additional header) |
120 | } | 121 | } |
121 | 122 | ||
122 | free( sizes ); | 123 | free( sizes ); |
123 | 124 | ||
124 | bzero( &ah, sizeof(ah) ); | 125 | bzero( &ah, sizeof(ah) ); |
125 | strcpy(ah.avih, "avih"); | 126 | strcpy(ah.avih, "avih"); |
126 | ah.time = 1000000 / fps; | 127 | ah.time = 1000000 / fps; |
127 | ah.maxbytespersec = 1000000.0*(totalsize/nframes)/ah.time; | 128 | ah.maxbytespersec = 1000000.0*(totalsize/nframes)/ah.time; |
128 | ah.nframes = nframes; | 129 | ah.nframes = nframes; |
129 | ah.numstreams = 1; | 130 | ah.numstreams = 1; |
130 | ah.flags = AVIF_HASINDEX; | 131 | ah.flags = AVIF_HASINDEX; |
131 | ah.width = width; | 132 | ah.width = width; |
132 | ah.height = height; | 133 | ah.height = height; |
133 | 134 | ||
134 | bzero(&sh, sizeof(sh)); | 135 | bzero(&sh, sizeof(sh)); |
135 | strcpy(sh.strh, "strh"); | 136 | strcpy(sh.strh, "strh"); |
136 | strcpy(sh.vids, "vids"); | 137 | strcpy(sh.vids, "vids"); |
137 | strcpy(sh.codec, "MJPG"); | 138 | strcpy(sh.codec, "MJPG"); |
138 | sh.scale = ah.time; | 139 | sh.scale = ah.time; |
139 | sh.rate = 1000000; | 140 | sh.rate = 1000000; |
140 | sh.length = nframes; | 141 | sh.length = nframes; |
141 | 142 | ||
142 | bzero(&fh, sizeof(fh)); | 143 | bzero(&fh, sizeof(fh)); |
143 | strcpy(fh.strf, "strf"); | 144 | strcpy(fh.strf, "strf"); |
144 | fh.width = width; | 145 | fh.width = width; |
145 | fh.height = height; | 146 | fh.height = height; |
146 | fh.planes = 1; | 147 | fh.planes = 1; |
147 | fh.bitcount = 24; | 148 | fh.bitcount = 24; |
148 | strcpy(fh.codec,"MJPG"); | 149 | strcpy(fh.codec,"MJPG"); |
149 | fh.unpackedsize = 3*width*height; | 150 | fh.unpackedsize = 3*width*height; |
150 | 151 | ||
151 | rh.size = sizeof(lh1)+sizeof(ah)+sizeof(lh2)+sizeof(sh)+ | 152 | rh.size = sizeof(lh1)+sizeof(ah)+sizeof(lh2)+sizeof(sh)+ |
152 | sizeof(fh)+sizeof(lh3)+sizeof(dh)+sizeof(lh4)+ | 153 | sizeof(fh)+sizeof(lh3)+sizeof(dh)+sizeof(lh4)+ |
153 | nframes*sizeof(struct db_head)+ | 154 | nframes*sizeof(struct db_head)+ |
154 | totalsize + sizeof(struct idx1_head)+ (16*nframes) +4; // FIXME:16 bytes per nframe // the '4' - what for??? | 155 | totalsize + sizeof(struct idx1_head)+ (16*nframes) +4; // FIXME:16 bytes per nframe // the '4' - what for??? |
155 | 156 | ||
156 | lh1.size = 4+sizeof(ah)+sizeof(lh2)+sizeof(sh)+sizeof(fh)+sizeof(lh3)+sizeof(dh); | 157 | lh1.size = 4+sizeof(ah)+sizeof(lh2)+sizeof(sh)+sizeof(fh)+sizeof(lh3)+sizeof(dh); |
157 | ah.size = sizeof(ah)-8; | 158 | ah.size = sizeof(ah)-8; |
158 | lh2.size = 4+sizeof(sh)+sizeof(fh)+sizeof(lh3)+sizeof(dh); //4+sizeof(sh)+sizeof(fh); | 159 | lh2.size = 4+sizeof(sh)+sizeof(fh)+sizeof(lh3)+sizeof(dh); //4+sizeof(sh)+sizeof(fh); |
159 | sh.size = sizeof(sh)-8; | 160 | sh.size = sizeof(sh)-8; |
160 | fh.size = sizeof(fh)-8; | 161 | fh.size = sizeof(fh)-8; |
161 | fh.size2 = fh.size; | 162 | fh.size2 = fh.size; |
162 | lh3.size = 4+sizeof(dh); | 163 | lh3.size = 4+sizeof(dh); |
163 | lh4.size = 4+ nframes*sizeof(struct db_head)+ totalsize; | 164 | lh4.size = 4+ nframes*sizeof(struct db_head)+ totalsize; |
164 | 165 | ||
165 | lseek(fd, 0, SEEK_SET); | 166 | lseek(fd, 0, SEEK_SET); |
166 | 167 | ||
167 | write(fd, &rh, sizeof(rh)); | 168 | write(fd, &rh, sizeof(rh)); |
168 | write(fd, &lh1, sizeof(lh1)); | 169 | write(fd, &lh1, sizeof(lh1)); |
169 | write(fd, &ah, sizeof(ah)); | 170 | write(fd, &ah, sizeof(ah)); |
170 | write(fd, &lh2, sizeof(lh2)); | 171 | write(fd, &lh2, sizeof(lh2)); |
171 | write(fd, &sh, sizeof(sh)); | 172 | write(fd, &sh, sizeof(sh)); |
172 | write(fd, &fh, sizeof(fh)); | 173 | write(fd, &fh, sizeof(fh)); |
173 | write(fd, &lh3, sizeof(lh3)); | 174 | write(fd, &lh3, sizeof(lh3)); |
174 | write(fd, &dh, sizeof(dh)); | 175 | write(fd, &dh, sizeof(dh)); |
175 | write(fd, &lh4, sizeof(lh4)); | 176 | write(fd, &lh4, sizeof(lh4)); |
176 | } | 177 | } |
177 | 178 | ||
178 | 179 | ||
179 | /* NOTE: This is not a general purpose routine - it is meant to only | 180 | /* NOTE: This is not a general purpose routine - it is meant to only |
180 | cope with AVIs saved using the other functions in this file | 181 | cope with AVIs saved using the other functions in this file |
181 | void avi_explode(char *fname) | 182 | void avi_explode(char *fname) |
182 | { | 183 | { |
183 | struct riff_head rh; | 184 | struct riff_head rh; |
184 | struct list_head lh1; | 185 | struct list_head lh1; |
185 | struct avi_head ah; | 186 | struct avi_head ah; |
186 | struct list_head lh2; | 187 | struct list_head lh2; |
187 | struct stream_head sh; | 188 | struct stream_head sh; |
188 | struct frame_head fh; | 189 | struct frame_head fh; |
189 | struct list_head lh3; | 190 | struct list_head lh3; |
190 | int hsize, qsize; | 191 | int hsize, qsize; |
191 | u16 *htables = jpeg_huffman_tables(&hsize); | 192 | u16 *htables = jpeg_huffman_tables(&hsize); |
192 | u16 *qtables = jpeg_quantisation_tables(&qsize, image_quality); | 193 | u16 *qtables = jpeg_quantisation_tables(&qsize, image_quality); |
193 | int fd, i; | 194 | int fd, i; |
194 | 195 | ||
195 | fd = open(fname,O_RDONLY); | 196 | fd = open(fname,O_RDONLY); |
196 | if (fd == -1) { | 197 | if (fd == -1) { |
197 | perror(fname); | 198 | perror(fname); |
198 | return; | 199 | return; |
199 | } | 200 | } |
200 | 201 | ||
201 | read(fd, &rh, sizeof(rh)); | 202 | read(fd, &rh, sizeof(rh)); |
202 | read(fd, &lh1, sizeof(lh1)); | 203 | read(fd, &lh1, sizeof(lh1)); |
203 | read(fd, &ah, sizeof(ah)); | 204 | read(fd, &ah, sizeof(ah)); |
204 | read(fd, &lh2, sizeof(lh2)); | 205 | read(fd, &lh2, sizeof(lh2)); |
205 | read(fd, &sh, sizeof(sh)); | 206 | read(fd, &sh, sizeof(sh)); |
206 | read(fd, &fh, sizeof(fh)); | 207 | read(fd, &fh, sizeof(fh)); |
207 | read(fd, &lh3, sizeof(lh3)); | 208 | read(fd, &lh3, sizeof(lh3)); |
208 | 209 | ||
209 | for (i=0; ; i++) { | 210 | for (i=0; ; i++) { |
210 | u8 buf[500*1024]; | 211 | u8 buf[500*1024]; |
211 | struct db_head db; | 212 | struct db_head db; |
212 | char fname[100]; | 213 | char fname[100]; |
213 | int fd2; | 214 | int fd2; |
214 | 215 | ||
215 | if (read(fd, &db, sizeof(db)) != sizeof(db) || | 216 | if (read(fd, &db, sizeof(db)) != sizeof(db) || |
216 | read(fd, buf, db.size) != db.size) break; | 217 | read(fd, buf, db.size) != db.size) break; |
217 | 218 | ||
218 | snprintf(fname, sizeof(fname)-1,"frame.%d", i); | 219 | snprintf(fname, sizeof(fname)-1,"frame.%d", i); |
219 | 220 | ||
220 | fd2 = open(fname,O_WRONLY|O_CREAT, 0644); | 221 | fd2 = open(fname,O_WRONLY|O_CREAT, 0644); |
221 | if (fd2 == -1) { | 222 | if (fd2 == -1) { |
222 | perror(fname); | 223 | perror(fname); |
223 | continue; | 224 | continue; |
224 | } | 225 | } |
225 | write(fd2, buf, 2); | 226 | write(fd2, buf, 2); |
226 | write(fd2, qtables, qsize); | 227 | write(fd2, qtables, qsize); |
227 | write(fd2, htables, hsize); | 228 | write(fd2, htables, hsize); |
228 | write(fd2, buf+2, db.size-2); | 229 | write(fd2, buf+2, db.size-2); |
229 | close(fd2); | 230 | close(fd2); |
230 | } | 231 | } |
231 | close(fd); | 232 | close(fd); |
232 | printf("exploded %d frames\n", i); | 233 | printf("exploded %d frames\n", i); |
233 | } | 234 | } |
234 | 235 | ||
235 | */ | 236 | */ |
236 | 237 | ||