author | mickeyl <mickeyl> | 2003-05-07 16:14:40 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-07 16:14:40 (UTC) |
commit | 1e9e3371d61cfc404329a8bad51f8b061c1ad73d (patch) (unidiff) | |
tree | ede98f5b571543cef4047c3a33e314ffee91a94c | |
parent | 7c8110d568ac60517916114ac5fc4e850156d4e5 (diff) | |
download | opie-1e9e3371d61cfc404329a8bad51f8b061c1ad73d.zip opie-1e9e3371d61cfc404329a8bad51f8b061c1ad73d.tar.gz opie-1e9e3371d61cfc404329a8bad51f8b061c1ad73d.tar.bz2 |
reenable sounds now that they work on the Z again
-rw-r--r-- | noncore/multimedia/camera/gui/mainwindow.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/multimedia/camera/gui/mainwindow.cpp b/noncore/multimedia/camera/gui/mainwindow.cpp index 49c7cbf..0854f0d 100644 --- a/noncore/multimedia/camera/gui/mainwindow.cpp +++ b/noncore/multimedia/camera/gui/mainwindow.cpp | |||
@@ -271,422 +271,422 @@ void CameraMainWindow::showContextMenu() | |||
271 | m.insertItem( "&Prefix", &prefix ); | 271 | m.insertItem( "&Prefix", &prefix ); |
272 | m.insertItem( "Output &To", &outputTo ); | 272 | m.insertItem( "Output &To", &outputTo ); |
273 | m.insertItem( "&Output As", &output ); | 273 | m.insertItem( "&Output As", &output ); |
274 | 274 | ||
275 | #ifndef QT_NO_DEBUG | 275 | #ifndef QT_NO_DEBUG |
276 | m.insertItem( "&Debug!", this, SLOT( doSomething() ) ); | 276 | m.insertItem( "&Debug!", this, SLOT( doSomething() ) ); |
277 | #endif | 277 | #endif |
278 | 278 | ||
279 | m.exec( QCursor::pos() ); | 279 | m.exec( QCursor::pos() ); |
280 | } | 280 | } |
281 | 281 | ||
282 | 282 | ||
283 | void CameraMainWindow::resoMenuItemClicked( QAction* a ) | 283 | void CameraMainWindow::resoMenuItemClicked( QAction* a ) |
284 | { | 284 | { |
285 | switch ( _rotation ) | 285 | switch ( _rotation ) |
286 | { | 286 | { |
287 | case 270: | 287 | case 270: |
288 | captureY = a->text().left(3).toInt(); | 288 | captureY = a->text().left(3).toInt(); |
289 | captureX = a->text().right(3).toInt(); | 289 | captureX = a->text().right(3).toInt(); |
290 | break; | 290 | break; |
291 | case 180: | 291 | case 180: |
292 | captureX = a->text().left(3).toInt(); | 292 | captureX = a->text().left(3).toInt(); |
293 | captureY = a->text().right(3).toInt(); | 293 | captureY = a->text().right(3).toInt(); |
294 | break; | 294 | break; |
295 | default: QMessageBox::warning( this, "opie-camera", | 295 | default: QMessageBox::warning( this, "opie-camera", |
296 | "This rotation is not supported.\n" | 296 | "This rotation is not supported.\n" |
297 | "Supported are 180° and 270°" ); | 297 | "Supported are 180° and 270°" ); |
298 | } | 298 | } |
299 | odebug << "Capture Resolution now: " << captureX << ", " << captureY << oendl; | 299 | odebug << "Capture Resolution now: " << captureX << ", " << captureY << oendl; |
300 | updateCaption(); | 300 | updateCaption(); |
301 | } | 301 | } |
302 | 302 | ||
303 | 303 | ||
304 | void CameraMainWindow::qualityMenuItemClicked( QAction* a ) | 304 | void CameraMainWindow::qualityMenuItemClicked( QAction* a ) |
305 | { | 305 | { |
306 | quality = a->text().left(3).toInt(); | 306 | quality = a->text().left(3).toInt(); |
307 | odebug << "Quality now: " << quality << oendl; | 307 | odebug << "Quality now: " << quality << oendl; |
308 | updateCaption(); | 308 | updateCaption(); |
309 | } | 309 | } |
310 | 310 | ||
311 | 311 | ||
312 | void CameraMainWindow::zoomMenuItemClicked( QAction* a ) | 312 | void CameraMainWindow::zoomMenuItemClicked( QAction* a ) |
313 | { | 313 | { |
314 | zoom = QString( a->text().at(2) ).toInt(); | 314 | zoom = QString( a->text().at(2) ).toInt(); |
315 | odebug << "Zoom now: " << zoom << oendl; | 315 | odebug << "Zoom now: " << zoom << oendl; |
316 | ZCameraIO::instance()->setZoom( zoom ); | 316 | ZCameraIO::instance()->setZoom( zoom ); |
317 | updateCaption(); | 317 | updateCaption(); |
318 | } | 318 | } |
319 | 319 | ||
320 | 320 | ||
321 | void CameraMainWindow::flipMenuItemClicked( QAction* a ) | 321 | void CameraMainWindow::flipMenuItemClicked( QAction* a ) |
322 | { | 322 | { |
323 | flip = QString( a->text().at(0) ); | 323 | flip = QString( a->text().at(0) ); |
324 | odebug << "Flip now: " << flip << oendl; | 324 | odebug << "Flip now: " << flip << oendl; |
325 | if ( flip == "A" ) | 325 | if ( flip == "A" ) |
326 | ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP ); | 326 | ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP ); |
327 | else if ( flip == "0" ) | 327 | else if ( flip == "0" ) |
328 | ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP ); | 328 | ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP ); |
329 | else if ( flip == "X" ) | 329 | else if ( flip == "X" ) |
330 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP ); | 330 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP ); |
331 | else if ( flip == "Y" ) | 331 | else if ( flip == "Y" ) |
332 | ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP ); | 332 | ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP ); |
333 | else if ( flip == "*" ) | 333 | else if ( flip == "*" ) |
334 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP ); | 334 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP ); |
335 | 335 | ||
336 | updateCaption(); | 336 | updateCaption(); |
337 | } | 337 | } |
338 | 338 | ||
339 | 339 | ||
340 | void CameraMainWindow::outputToMenuItemClicked( QAction* a ) | 340 | void CameraMainWindow::outputToMenuItemClicked( QAction* a ) |
341 | { | 341 | { |
342 | if ( a->text() == "&Custom..." ) | 342 | if ( a->text() == "&Custom..." ) |
343 | { | 343 | { |
344 | QMap<QString, QStringList> map; | 344 | QMap<QString, QStringList> map; |
345 | map.insert( tr("All"), QStringList() ); | 345 | map.insert( tr("All"), QStringList() ); |
346 | QStringList text; | 346 | QStringList text; |
347 | text << "text/*"; | 347 | text << "text/*"; |
348 | map.insert(tr("Text"), text ); | 348 | map.insert(tr("Text"), text ); |
349 | text << "*"; | 349 | text << "*"; |
350 | map.insert(tr("All"), text ); | 350 | map.insert(tr("All"), text ); |
351 | 351 | ||
352 | QString str; | 352 | QString str; |
353 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); | 353 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); |
354 | if ( str.isEmpty() || !QFileInfo(str).isDir() ) | 354 | if ( str.isEmpty() || !QFileInfo(str).isDir() ) |
355 | { | 355 | { |
356 | docfolder->setOn( true ); | 356 | docfolder->setOn( true ); |
357 | outputTo = "Documents Folder"; | 357 | outputTo = "Documents Folder"; |
358 | } | 358 | } |
359 | else | 359 | else |
360 | { | 360 | { |
361 | outputTo = str; | 361 | outputTo = str; |
362 | } | 362 | } |
363 | } | 363 | } |
364 | else | 364 | else |
365 | { | 365 | { |
366 | outputTo = a->text(); | 366 | outputTo = a->text(); |
367 | } | 367 | } |
368 | odebug << "Output to now: " << outputTo << oendl; | 368 | odebug << "Output to now: " << outputTo << oendl; |
369 | } | 369 | } |
370 | 370 | ||
371 | 371 | ||
372 | void CameraMainWindow::outputMenuItemClicked( QAction* a ) | 372 | void CameraMainWindow::outputMenuItemClicked( QAction* a ) |
373 | { | 373 | { |
374 | captureFormat = a->text(); | 374 | captureFormat = a->text(); |
375 | odebug << "Output format now: " << captureFormat << oendl; | 375 | odebug << "Output format now: " << captureFormat << oendl; |
376 | updateCaption(); | 376 | updateCaption(); |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | void CameraMainWindow::prefixItemChoosen() | 380 | void CameraMainWindow::prefixItemChoosen() |
381 | { | 381 | { |
382 | QDialog* d = new QDialog( this, "dialog", true ); | 382 | QDialog* d = new QDialog( this, "dialog", true ); |
383 | d->setCaption( "Enter Prefix..." ); | 383 | d->setCaption( "Enter Prefix..." ); |
384 | QVBoxLayout* v = new QVBoxLayout( d ); | 384 | QVBoxLayout* v = new QVBoxLayout( d ); |
385 | QLineEdit* le = new QLineEdit( prefix, d ); | 385 | QLineEdit* le = new QLineEdit( prefix, d ); |
386 | v->addWidget( le ); | 386 | v->addWidget( le ); |
387 | le->setFixedWidth( 150 ); //FIXME: 'tis a bit dirty | 387 | le->setFixedWidth( 150 ); //FIXME: 'tis a bit dirty |
388 | if ( d->exec() == QDialog::Accepted ) | 388 | if ( d->exec() == QDialog::Accepted ) |
389 | prefix = le->text(); | 389 | prefix = le->text(); |
390 | odebug << "Prefix now: " << prefix << oendl; | 390 | odebug << "Prefix now: " << prefix << oendl; |
391 | } | 391 | } |
392 | 392 | ||
393 | 393 | ||
394 | void CameraMainWindow::appendSettingsChoosen() | 394 | void CameraMainWindow::appendSettingsChoosen() |
395 | { | 395 | { |
396 | appendSettings = !appendSettings; | 396 | appendSettings = !appendSettings; |
397 | odebug << "appendSettings now: " << appendSettings << oendl; | 397 | odebug << "appendSettings now: " << appendSettings << oendl; |
398 | } | 398 | } |
399 | 399 | ||
400 | 400 | ||
401 | void CameraMainWindow::shutterClicked() | 401 | void CameraMainWindow::shutterClicked() |
402 | { | 402 | { |
403 | if ( captureFormat != "AVI" ) // capture one photo per shutterClick | 403 | if ( captureFormat != "AVI" ) // capture one photo per shutterClick |
404 | { | 404 | { |
405 | Global::statusMessage( "CAPTURING..." ); | 405 | Global::statusMessage( "CAPTURING..." ); |
406 | qApp->processEvents(); | 406 | qApp->processEvents(); |
407 | 407 | ||
408 | odebug << "Shutter has been pressed" << oendl; | 408 | odebug << "Shutter has been pressed" << oendl; |
409 | ODevice::inst()->touchSound(); | 409 | ODevice::inst()->touchSound(); |
410 | 410 | ||
411 | performCapture( captureFormat ); | 411 | performCapture( captureFormat ); |
412 | } | 412 | } |
413 | else // capture video! start with one shutter click and stop with the next | 413 | else // capture video! start with one shutter click and stop with the next |
414 | { | 414 | { |
415 | !_capturing ? startVideoCapture() : stopVideoCapture(); | 415 | !_capturing ? startVideoCapture() : stopVideoCapture(); |
416 | } | 416 | } |
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | void CameraMainWindow::performCapture( const QString& format ) | 420 | void CameraMainWindow::performCapture( const QString& format ) |
421 | { | 421 | { |
422 | QString name; | 422 | QString name; |
423 | 423 | ||
424 | if ( outputTo == "Documents Folder" ) | 424 | if ( outputTo == "Documents Folder" ) |
425 | { | 425 | { |
426 | name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); | 426 | name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); |
427 | if ( !QDir( name ).exists() ) | 427 | if ( !QDir( name ).exists() ) |
428 | { | 428 | { |
429 | odebug << "creating directory " << name << oendl; | 429 | odebug << "creating directory " << name << oendl; |
430 | QString msg = "mkdir -p " + name; | 430 | QString msg = "mkdir -p " + name; |
431 | system( msg.latin1() ); | 431 | system( msg.latin1() ); |
432 | } | 432 | } |
433 | } | 433 | } |
434 | else | 434 | else |
435 | name = outputTo; | 435 | name = outputTo; |
436 | 436 | ||
437 | name.append( prefix ); | 437 | name.append( prefix ); |
438 | if ( appendSettings ) | 438 | if ( appendSettings ) |
439 | { | 439 | { |
440 | name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) ); | 440 | name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) ); |
441 | } | 441 | } |
442 | name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) ); | 442 | name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) ); |
443 | 443 | ||
444 | QImage i; | 444 | QImage i; |
445 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i ); | 445 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i ); |
446 | QImage im = i.convertDepth( 32 ); | 446 | QImage im = i.convertDepth( 32 ); |
447 | bool result = im.save( name, format, quality ); | 447 | bool result = im.save( name, format, quality ); |
448 | if ( !result ) | 448 | if ( !result ) |
449 | { | 449 | { |
450 | oerr << "imageio-Problem while writing." << oendl; | 450 | oerr << "imageio-Problem while writing." << oendl; |
451 | Global::statusMessage( "Error!" ); | 451 | Global::statusMessage( "Error!" ); |
452 | } | 452 | } |
453 | else | 453 | else |
454 | { | 454 | { |
455 | odebug << captureFormat << "-image has been successfully captured" << oendl; | 455 | odebug << captureFormat << "-image has been successfully captured" << oendl; |
456 | Global::statusMessage( "Ok." ); | 456 | Global::statusMessage( "Ok." ); |
457 | } | 457 | } |
458 | } | 458 | } |
459 | 459 | ||
460 | 460 | ||
461 | void CameraMainWindow::startVideoCapture() | 461 | void CameraMainWindow::startVideoCapture() |
462 | { | 462 | { |
463 | //ODevice::inst()->touchSound(); | 463 | ODevice::inst()->touchSound(); |
464 | ODevice::inst()->setLedState( Led_Mail, Led_BlinkSlow ); | 464 | ODevice::inst()->setLedState( Led_Mail, Led_BlinkSlow ); |
465 | 465 | ||
466 | _capturefd = ::open( CAPTUREFILE, O_WRONLY | O_CREAT | O_TRUNC ); | 466 | _capturefd = ::open( CAPTUREFILE, O_WRONLY | O_CREAT | O_TRUNC ); |
467 | if ( _capturefd == -1 ) | 467 | if ( _capturefd == -1 ) |
468 | { | 468 | { |
469 | owarn << "can't open capture file: " << strerror(errno) << oendl; | 469 | owarn << "can't open capture file: " << strerror(errno) << oendl; |
470 | return; | 470 | return; |
471 | } | 471 | } |
472 | 472 | ||
473 | _capturebuf = new unsigned char[captureX*captureY*2]; | 473 | _capturebuf = new unsigned char[captureX*captureY*2]; |
474 | _capturing = true; | 474 | _capturing = true; |
475 | _videopics = 0; | 475 | _videopics = 0; |
476 | _framerate = 0; | 476 | _framerate = 0; |
477 | updateCaption(); | 477 | updateCaption(); |
478 | _time.start(); | 478 | _time.start(); |
479 | preview->setRefreshingRate( 1000 ); | 479 | preview->setRefreshingRate( 1000 ); |
480 | startTimer( 100 ); // too fast but that is ok | 480 | startTimer( 100 ); // too fast but that is ok |
481 | } | 481 | } |
482 | 482 | ||
483 | 483 | ||
484 | void CameraMainWindow::timerEvent( QTimerEvent* ) | 484 | void CameraMainWindow::timerEvent( QTimerEvent* ) |
485 | { | 485 | { |
486 | if ( !_capturing ) | 486 | if ( !_capturing ) |
487 | { | 487 | { |
488 | odebug << "timer event in CameraMainWindow without capturing video ?" << oendl; | 488 | odebug << "timer event in CameraMainWindow without capturing video ?" << oendl; |
489 | return; | 489 | return; |
490 | } | 490 | } |
491 | 491 | ||
492 | odebug << "timer event during video - now capturing frame #" << _videopics+1 << oendl; | 492 | odebug << "timer event during video - now capturing frame #" << _videopics+1 << oendl; |
493 | 493 | ||
494 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, _capturebuf ); | 494 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, _capturebuf ); |
495 | _videopics++; | 495 | _videopics++; |
496 | ::write( _capturefd, _capturebuf, captureX*captureY*2 ); | 496 | ::write( _capturefd, _capturebuf, captureX*captureY*2 ); |
497 | setCaption( QString().sprintf( "Capturing %dx%d @ %.2f fps %d", | 497 | setCaption( QString().sprintf( "Capturing %dx%d @ %.2f fps %d", |
498 | captureX, captureY, 1000.0 / (_time.elapsed()/_videopics), _videopics ) ); | 498 | captureX, captureY, 1000.0 / (_time.elapsed()/_videopics), _videopics ) ); |
499 | } | 499 | } |
500 | 500 | ||
501 | 501 | ||
502 | void CameraMainWindow::stopVideoCapture() | 502 | void CameraMainWindow::stopVideoCapture() |
503 | { | 503 | { |
504 | killTimers(); | 504 | killTimers(); |
505 | //ODevice::inst()->touchSound(); | 505 | ODevice::inst()->touchSound(); |
506 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); | 506 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); |
507 | _capturing = false; | 507 | _capturing = false; |
508 | updateCaption(); | 508 | updateCaption(); |
509 | ::close( _capturefd ); | 509 | ::close( _capturefd ); |
510 | _framerate = 1000.0 / (_time.elapsed()/_videopics); | 510 | _framerate = 1000.0 / (_time.elapsed()/_videopics); |
511 | 511 | ||
512 | QString name; | 512 | QString name; |
513 | if ( outputTo == "Documents Folder" ) | 513 | if ( outputTo == "Documents Folder" ) |
514 | { | 514 | { |
515 | name.sprintf( "%s/Documents/video/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); | 515 | name.sprintf( "%s/Documents/video/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); |
516 | if ( !QDir( name ).exists() ) | 516 | if ( !QDir( name ).exists() ) |
517 | { | 517 | { |
518 | odebug << "creating directory " << name << oendl; | 518 | odebug << "creating directory " << name << oendl; |
519 | QString msg = "mkdir -p " + name; | 519 | QString msg = "mkdir -p " + name; |
520 | system( msg.latin1() ); | 520 | system( msg.latin1() ); |
521 | } | 521 | } |
522 | } | 522 | } |
523 | else | 523 | else |
524 | name = outputTo; | 524 | name = outputTo; |
525 | 525 | ||
526 | name.append( "/" ); // sure is sure and safe is safe ;-) | 526 | name.append( "/" ); // sure is sure and safe is safe ;-) |
527 | name.append( prefix ); | 527 | name.append( prefix ); |
528 | if ( appendSettings ) | 528 | if ( appendSettings ) |
529 | name.append( QString().sprintf( "_%d_%d_q%d_%dfps", captureX, captureY, quality, _framerate ) ); | 529 | name.append( QString().sprintf( "_%d_%d_q%d_%dfps", captureX, captureY, quality, _framerate ) ); |
530 | name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) ); | 530 | name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) ); |
531 | postProcessVideo( CAPTUREFILE, name ); | 531 | postProcessVideo( CAPTUREFILE, name ); |
532 | 532 | ||
533 | #ifndef QT_NO_DEBUG | 533 | #ifndef QT_NO_DEBUG |
534 | preview->setRefreshingRate( 1500 ); | 534 | preview->setRefreshingRate( 1500 ); |
535 | #else | 535 | #else |
536 | preview->setRefreshingRate( 200 ); | 536 | preview->setRefreshingRate( 200 ); |
537 | #endif | 537 | #endif |
538 | 538 | ||
539 | //delete[] _capturebuf; //FIXME: close memory leak | 539 | //delete[] _capturebuf; //FIXME: close memory leak |
540 | } | 540 | } |
541 | 541 | ||
542 | void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile ) | 542 | void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile ) |
543 | { | 543 | { |
544 | odebug << "post processing " << infile << " --> " << outfile << oendl; | 544 | odebug << "post processing " << infile << " --> " << outfile << oendl; |
545 | 545 | ||
546 | preview->setRefreshingRate( 0 ); | 546 | preview->setRefreshingRate( 0 ); |
547 | 547 | ||
548 | /* | 548 | /* |
549 | unsigned char buf[153600]; | 549 | unsigned char buf[153600]; |
550 | 550 | ||
551 | int fd = ::open( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", O_RDONLY ); | 551 | int fd = ::open( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", O_RDONLY ); |
552 | ::read( fd, &buf, 153600 ); | 552 | ::read( fd, &buf, 153600 ); |
553 | QImage i; | 553 | QImage i; |
554 | bufferToImage( 240, 320, (unsigned char*) &buf, &i ); | 554 | bufferToImage( 240, 320, (unsigned char*) &buf, &i ); |
555 | QPixmap p; | 555 | QPixmap p; |
556 | p.convertFromImage( i ); | 556 | p.convertFromImage( i ); |
557 | preview->setPixmap( p ); | 557 | preview->setPixmap( p ); |
558 | imageToFile( &i, "/tmp/tmpfile", "JPEG", 100 ); | 558 | imageToFile( &i, "/tmp/tmpfile", "JPEG", 100 ); |
559 | return; | 559 | return; |
560 | */ | 560 | */ |
561 | 561 | ||
562 | QDialog* fr = new QDialog( this, "splash", false, QWidget::WStyle_StaysOnTop ); //, false, QWidget::WStyle_NoBorder | QWidget::WStyle_Customize ); | 562 | QDialog* fr = new QDialog( this, "splash", false, QWidget::WStyle_StaysOnTop ); //, false, QWidget::WStyle_NoBorder | QWidget::WStyle_Customize ); |
563 | fr->setCaption( "Please wait..." ); | 563 | fr->setCaption( "Please wait..." ); |
564 | QVBoxLayout* box = new QVBoxLayout( fr, 2, 2 ); | 564 | QVBoxLayout* box = new QVBoxLayout( fr, 2, 2 ); |
565 | QProgressBar* bar = new QProgressBar( fr ); | 565 | QProgressBar* bar = new QProgressBar( fr ); |
566 | bar->setCenterIndicator( true ); | 566 | bar->setCenterIndicator( true ); |
567 | bar->setTotalSteps( _videopics-1 ); | 567 | bar->setTotalSteps( _videopics-1 ); |
568 | QLabel* label = new QLabel( "Post processing frame bla/bla", fr ); | 568 | QLabel* label = new QLabel( "Post processing frame bla/bla", fr ); |
569 | box->addWidget( bar ); | 569 | box->addWidget( bar ); |
570 | box->addWidget( label ); | 570 | box->addWidget( label ); |
571 | fr->show(); | 571 | fr->show(); |
572 | label->show(); | 572 | label->show(); |
573 | bar->show(); | 573 | bar->show(); |
574 | fr->repaint(); | 574 | fr->repaint(); |
575 | qApp->processEvents(); | 575 | qApp->processEvents(); |
576 | 576 | ||
577 | // open files | 577 | // open files |
578 | 578 | ||
579 | int infd = ::open( (const char*) infile, O_RDONLY ); | 579 | int infd = ::open( (const char*) infile, O_RDONLY ); |
580 | if ( infd == -1 ) | 580 | if ( infd == -1 ) |
581 | { | 581 | { |
582 | owarn << "couldn't open capture file: " << strerror(errno) << oendl; | 582 | owarn << "couldn't open capture file: " << strerror(errno) << oendl; |
583 | return; | 583 | return; |
584 | } | 584 | } |
585 | 585 | ||
586 | int outfd = ::open( (const char*) outfile, O_CREAT | O_WRONLY | O_TRUNC, 0644 ); | 586 | int outfd = ::open( (const char*) outfile, O_CREAT | O_WRONLY | O_TRUNC, 0644 ); |
587 | if ( outfd == -1 ) | 587 | if ( outfd == -1 ) |
588 | { | 588 | { |
589 | owarn << "couldn't open output file: " << strerror(errno) << oendl; | 589 | owarn << "couldn't open output file: " << strerror(errno) << oendl; |
590 | return; | 590 | return; |
591 | } | 591 | } |
592 | 592 | ||
593 | int framesize = captureX*captureY*2; | 593 | int framesize = captureX*captureY*2; |
594 | 594 | ||
595 | unsigned char* inbuffer = new unsigned char[ framesize ]; | 595 | unsigned char* inbuffer = new unsigned char[ framesize ]; |
596 | QImage image; | 596 | QImage image; |
597 | 597 | ||
598 | avi_start( outfd, _videopics ); // write preambel | 598 | avi_start( outfd, _videopics ); // write preambel |
599 | 599 | ||
600 | // post process | 600 | // post process |
601 | 601 | ||
602 | for ( int i = 0; i < _videopics; ++i ) | 602 | for ( int i = 0; i < _videopics; ++i ) |
603 | { | 603 | { |
604 | odebug << "processing frame " << i << oendl; | 604 | odebug << "processing frame " << i << oendl; |
605 | 605 | ||
606 | // <gui> | 606 | // <gui> |
607 | label->setText( QString().sprintf( "Post processing frame %d / %d", i+1, _videopics ) ); | 607 | label->setText( QString().sprintf( "Post processing frame %d / %d", i+1, _videopics ) ); |
608 | bar->setProgress( i ); | 608 | bar->setProgress( i ); |
609 | bar->repaint(); | 609 | bar->repaint(); |
610 | qApp->processEvents(); | 610 | qApp->processEvents(); |
611 | // </gui> | 611 | // </gui> |
612 | 612 | ||
613 | int read = ::read( infd, inbuffer, framesize ); | 613 | int read = ::read( infd, inbuffer, framesize ); |
614 | odebug << "read " << read << " bytes" << oendl; | 614 | odebug << "read " << read << " bytes" << oendl; |
615 | bufferToImage( captureX, captureY, inbuffer, &image ); | 615 | bufferToImage( captureX, captureY, inbuffer, &image ); |
616 | 616 | ||
617 | QPixmap p; | 617 | QPixmap p; |
618 | p.convertFromImage( image ); | 618 | p.convertFromImage( image ); |
619 | preview->setPixmap( p ); | 619 | preview->setPixmap( p ); |
620 | preview->repaint(); | 620 | preview->repaint(); |
621 | qApp->processEvents(); | 621 | qApp->processEvents(); |
622 | 622 | ||
623 | #ifdef CAMERA_EXTRA_DEBUG | 623 | #ifdef CAMERA_EXTRA_DEBUG |
624 | QString tmpfilename; | 624 | QString tmpfilename; |
625 | tmpfilename.sprintf( "/tmp/test/%04d.jpg", i ); | 625 | tmpfilename.sprintf( "/tmp/test/%04d.jpg", i ); |
626 | #else | 626 | #else |
627 | QString tmpfilename( "/tmp/tempfile" ); | 627 | QString tmpfilename( "/tmp/tempfile" ); |
628 | #endif | 628 | #endif |
629 | 629 | ||
630 | imageToFile( &image, tmpfilename, "JPEG", quality ); | 630 | imageToFile( &image, tmpfilename, "JPEG", quality ); |
631 | 631 | ||
632 | QFile framefile( tmpfilename ); | 632 | QFile framefile( tmpfilename ); |
633 | if ( !framefile.open( IO_ReadOnly ) ) | 633 | if ( !framefile.open( IO_ReadOnly ) ) |
634 | { | 634 | { |
635 | oerr << "can't process file: %s" << strerror(errno) << oendl; | 635 | oerr << "can't process file: %s" << strerror(errno) << oendl; |
636 | return; // TODO: clean up temp ressources | 636 | return; // TODO: clean up temp ressources |
637 | } | 637 | } |
638 | 638 | ||
639 | int filesize = framefile.size(); | 639 | int filesize = framefile.size(); |
640 | odebug << "filesize for frame " << i << " = " << filesize << oendl; | 640 | odebug << "filesize for frame " << i << " = " << filesize << oendl; |
641 | 641 | ||
642 | unsigned char* tempbuffer = new unsigned char[ filesize ]; | 642 | unsigned char* tempbuffer = new unsigned char[ filesize ]; |
643 | framefile.readBlock( (char*) tempbuffer, filesize ); | 643 | framefile.readBlock( (char*) tempbuffer, filesize ); |
644 | avi_add( outfd, tempbuffer, filesize ); | 644 | avi_add( outfd, tempbuffer, filesize ); |
645 | delete tempbuffer; | 645 | delete tempbuffer; |
646 | framefile.close(); | 646 | framefile.close(); |
647 | 647 | ||
648 | } | 648 | } |
649 | 649 | ||
650 | avi_end( outfd, captureX, captureY, _framerate ); | 650 | avi_end( outfd, captureX, captureY, _framerate ); |
651 | ::close( outfd ); | 651 | ::close( outfd ); |
652 | ::close( infd ); | 652 | ::close( infd ); |
653 | 653 | ||
654 | label->setText( "deleting temp files..." ); | 654 | label->setText( "deleting temp files..." ); |
655 | qApp->processEvents(); | 655 | qApp->processEvents(); |
656 | odebug << "deleting temporary capturefile " << infile << oendl; | 656 | odebug << "deleting temporary capturefile " << infile << oendl; |
657 | QFile::remove( infile ); | 657 | QFile::remove( infile ); |
658 | 658 | ||
659 | fr->hide(); | 659 | fr->hide(); |
660 | delete fr; | 660 | delete fr; |
661 | 661 | ||
662 | updateCaption(); | 662 | updateCaption(); |
663 | 663 | ||
664 | } | 664 | } |
665 | 665 | ||
666 | 666 | ||
667 | void CameraMainWindow::updateCaption() | 667 | void CameraMainWindow::updateCaption() |
668 | { | 668 | { |
669 | if ( !_capturing ) | 669 | if ( !_capturing ) |
670 | setCaption( QString().sprintf( "Opie-Camera: %dx%d %s q%d z%d (%s)", captureX, captureY, (const char*) captureFormat.lower(), quality, zoom, (const char*) flip ) ); | 670 | setCaption( QString().sprintf( "Opie-Camera: %dx%d %s q%d z%d (%s)", captureX, captureY, (const char*) captureFormat.lower(), quality, zoom, (const char*) flip ) ); |
671 | else | 671 | else |
672 | setCaption( "Opie-Camera: => CAPTURING <=" ); | 672 | setCaption( "Opie-Camera: => CAPTURING <=" ); |
673 | qApp->processEvents(); | 673 | qApp->processEvents(); |
674 | } | 674 | } |
675 | 675 | ||
676 | 676 | ||
677 | #ifndef QT_NO_DEBUG | 677 | #ifndef QT_NO_DEBUG |
678 | void CameraMainWindow::doSomething() | 678 | void CameraMainWindow::doSomething() |
679 | { | 679 | { |
680 | captureX = 240; | 680 | captureX = 240; |
681 | captureY = 320; | 681 | captureY = 320; |
682 | _videopics = 50; | 682 | _videopics = 50; |
683 | _framerate = 5; | 683 | _framerate = 5; |
684 | postProcessVideo( "/var/compile/opie/noncore/multimedia/camera/capture.dat", | 684 | postProcessVideo( "/var/compile/opie/noncore/multimedia/camera/capture.dat", |
685 | "/tmp/output.avi" ); | 685 | "/tmp/output.avi" ); |
686 | } | 686 | } |
687 | #else | 687 | #else |
688 | void CameraMainWindow::doSomething() | 688 | void CameraMainWindow::doSomething() |
689 | { | 689 | { |
690 | } | 690 | } |
691 | #endif | 691 | #endif |
692 | 692 | ||