summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/camera/cmd/capture.cpp2
-rw-r--r--noncore/multimedia/camera/gui/main.cpp2
-rw-r--r--noncore/multimedia/camera/gui/mainwindow.cpp5
-rw-r--r--noncore/multimedia/camera/lib/imageio.cpp1
-rw-r--r--noncore/multimedia/camera/lib/zcameraio.cpp2
-rw-r--r--noncore/multimedia/opierec/helpwindow.cpp2
-rw-r--r--noncore/multimedia/opierec/main.cpp2
7 files changed, 14 insertions, 2 deletions
diff --git a/noncore/multimedia/camera/cmd/capture.cpp b/noncore/multimedia/camera/cmd/capture.cpp
index 64c223c..688622b 100644
--- a/noncore/multimedia/camera/cmd/capture.cpp
+++ b/noncore/multimedia/camera/cmd/capture.cpp
@@ -1,190 +1,192 @@
/**********************************************************************
** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#include "capture.h"
#include "zcameraio.h"
#include "imageio.h"
#include "avi.h"
#include <opie2/oapplication.h>
#include <opie2/odebug.h>
#include <qimage.h>
+using namespace Opie::Core;
+using namespace Opie::Core;
Capturer::Capturer()
:QFrame( 0 ), height( 320 ), width( 240 ), zoom( 1 ), quality( 90 ),
flip( "A" ), format( "JPEG" ), name( "Untitled" )
{
}
Capturer::~Capturer()
{
}
void Capturer::checkSettings()
{
if ( width > height )
{
if ( 0 != width % 16 || width < 16 || width > 640 )
{
printf( "Warning: Corrected X resolution to 320 px\n" );
width = 320;
}
if ( 0 != height % 16 || height < 16 || height > 480 )
{
printf( "Warning: Corrected Y resolution to 240 px\n" );
height = 240;
}
}
else
{
if ( 0 != width % 16 || width < 16 || width > 480 )
{
printf( "Warning: Corrected X resolution to 240 px\n" );
width = 240;
}
if ( 0 != height % 16 || height < 16 || height > 640 )
{
printf( "Warning: Corrected Y resolution to 320 px\n" );
height = 320;
}
}
if ( quality > 100 || quality < 10 )
{
printf( "Warning: Corrected quality to 75%%\n" );
quality = 75;
}
if ( zoom > 2 || zoom < 1 )
{
printf( "Warning: Corrected zoom to x1\n" );
zoom = 1;
}
if ( format != "JPEG" && format != "PNG" && format != "BMP" )
{
printf( "Warning: Corrected format to 'JPEG'\n" );
format = "JPEG";
}
}
void Capturer::capture()
{
if ( flip == "A" )
ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP );
else if ( flip == "0" )
ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP );
else if ( flip == "X" )
ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP );
else if ( flip == "Y" )
ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP );
else if ( flip == "*" )
ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP );
ZCameraIO::instance()->captureFrame( width, height, zoom, &image );
QImage im = image.convertDepth( 32 );
bool result = im.save( name, format, quality );
if ( !result )
{
printf( "QImageio-Problem while writing.\n" );
}
else
{
printf( "Ok.\n" );
}
}
void usage()
{
printf( "Usage: ./capture [options] filename\n\n" );
printf( " -x xresolution (dividable by 16) [default=240]\n" );
printf( " -y xresolution (dividable by 16) [default=320]\n" );
printf( " -q quality (10-100) [default=75]\n" );
printf( " -f flip (A=auto, 0, X, Y, *=both) [default=Auto]\n" );
printf( " -o output format (JPEG,BMP,PNG) [default=JPEG]\n" );
printf( " -z zoom (1-2) [default=1]\n" );
}
int main( int argc, char** argv )
{
OApplication* a = new OApplication( argc, argv, "Capture" );
Capturer* c = new Capturer();
if ( argc < 2 )
{
usage();
return -1;
}
#define I_HATE_WRITING_HARDCODED_PARSES
int i = 1;
while ( i < argc )
{
// check for filename
if ( argv[i][0] != '-' )
{
if ( argc != i+1 )
{
usage();
return -1;
}
else
{
c->name = argv[i];
break;
}
}
else
{
i++;
if ( argc == i )
{
usage();
return -1;
}
switch ( argv[i-1][1] )
{
case 'x': c->width = QString( argv[i] ).toInt(); break;
case 'y': c->height = QString( argv[i] ).toInt(); break;
case 'z': c->zoom = QString( argv[i] ).toInt(); break;
case 'o': c->format = QString( argv[i] ); break;
case 'q': c->quality = QString( argv[i] ).toInt(); break;
case 'f': c->flip = QString( argv[i] )[0]; break;
default: usage(); return -1;
}
i++;
}
#undef I_HATE_WRITING_HARDCODED_PARSES
}
if ( !ZCameraIO::instance()->isOpen() )
{
printf( "Error: Can't detect your camera. Exiting.\n" );
return -1;
}
c->checkSettings();
c->capture();
return 0;
}
diff --git a/noncore/multimedia/camera/gui/main.cpp b/noncore/multimedia/camera/gui/main.cpp
index f25475c..7d6b3bb 100644
--- a/noncore/multimedia/camera/gui/main.cpp
+++ b/noncore/multimedia/camera/gui/main.cpp
@@ -1,28 +1,30 @@
/**********************************************************************
** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
+
#include "mainwindow.h"
#include <opie2/oapplication.h>
+using namespace Opie::Core;
int main( int argc, char **argv )
{
OApplication a( argc, argv, "Opie-Camera" );
CameraMainWindow* w = new CameraMainWindow();
a.showMainWidget( w );
a.exec();
delete w;
return 0;
}
diff --git a/noncore/multimedia/camera/gui/mainwindow.cpp b/noncore/multimedia/camera/gui/mainwindow.cpp
index e4e1b6c..7f2a9bd 100644
--- a/noncore/multimedia/camera/gui/mainwindow.cpp
+++ b/noncore/multimedia/camera/gui/mainwindow.cpp
@@ -1,450 +1,453 @@
/**********************************************************************
** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#include "mainwindow.h"
#include "previewwidget.h"
#include "zcameraio.h"
#include "imageio.h"
#include "avi.h"
/* OPIE */
#include <opie2/ofiledialog.h>
#include <opie2/odevice.h>
#include <opie2/oapplication.h>
#include <opie2/oconfig.h>
#include <opie2/odebug.h>
#include <qpe/global.h>
#include <qpe/resource.h>
#include <qpe/qcopenvelope_qws.h>
-using namespace Opie;
/* QT */
#include <qapplication.h>
#include <qaction.h>
#include <qvbox.h>
#include <qcombobox.h>
#include <qcursor.h>
#include <qdatastream.h>
#include <qdir.h>
#include <qfile.h>
#include <qimage.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpopupmenu.h>
#include <qprogressbar.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qlayout.h>
#include <qdirectpainter_qws.h>
/* STD */
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#define CAPTUREFILE "/tmp/capture.dat"
#define OUTPUTFILE "/tmp/output.avi"
#define OUTPUT_TO_CUSTOM 250
#define OUTPUT_TO_DOCFOLDER 251
+
+using namespace Opie::Ui;
+using namespace Opie::Core;
+
CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f )
:QMainWindow( parent, name, f ),
_rotation( 270 ), // FIXME: get this from current settings (ODevice?)
_capturing( false ),
_pics( 1 ), _videos( 1 )
{
#ifdef QT_NO_DEBUG
if ( !ZCameraIO::instance()->isOpen() )
{
QVBox* v = new QVBox( this );
v->setMargin( 10 );
QLabel* l1 = new QLabel( v );
l1->setPixmap( Resource::loadPixmap( "camera/error" ) );
QLabel* l2 = new QLabel( v );
l2->setText( "<b>Sorry. could not detect your camera :-(</b><p>"
"* Is the sharpzdc_cs module loaded ?<br>"
"* Is /dev/sharpzdc read/writable ?<p>" );
connect( new QPushButton( "Exit", v ), SIGNAL( clicked() ), this, SLOT( close() ) );
setCentralWidget( v );
return;
}
#endif
init();
_rotation = 270; //TODO: grab these from the actual settings
preview = new PreviewWidget( this, "camera preview widget" );
//setCentralWidget( preview ); <--- don't do this!
preview->resize( QSize( 240, 288 ) );
preview->show();
// construct a System Channel to receive setRotation messages
_sysChannel = new QCopChannel( "QPE/System", this );
connect( _sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
connect( preview, SIGNAL( contextMenuRequested() ), this, SLOT( showContextMenu() ) );
connect( ZCameraIO::instance(), SIGNAL( shutterClicked() ), this, SLOT( shutterClicked() ) );
updateCaption();
};
CameraMainWindow::~CameraMainWindow()
{
// write back configuration
OConfigGroupSaver cgs( oApp->config(), "General" );
cgs.config()->writeEntry( "flip", flip );
cgs.config()->writeEntry( "quality", quality );
cgs.config()->writeEntry( "zoom", zoom );
cgs.config()->writeEntry( "captureX", captureX );
cgs.config()->writeEntry( "captureY", captureY );
cgs.config()->writeEntry( "captureFormat", captureFormat );
cgs.config()->writeEntry( "outputTo", outputTo );
cgs.config()->writeEntry( "prefix", prefix );
cgs.config()->writeEntry( "appendSettings", appendSettings );
}
void CameraMainWindow::init()
{
// get values from configuration
OConfigGroupSaver cgs( oApp->config(), "General" );
flip = cgs.config()->readEntry( "flip", "A" );
quality = cgs.config()->readNumEntry( "quality", 50 );
zoom = cgs.config()->readNumEntry( "zoom", 1 );
captureX = cgs.config()->readNumEntry( "captureX", 480 );
captureY = cgs.config()->readNumEntry( "captureY", 640 );
captureFormat = cgs.config()->readEntry( "captureFormat", "JPEG" );
outputTo = cgs.config()->readEntry( "outputTo", "Documents Folder" );
prefix = cgs.config()->readEntry( "prefix", "Untitled" );
appendSettings = cgs.config()->readBoolEntry( "appendSettings", true );
// create action groups
QAction* a;
resog = new QActionGroup( 0, "reso", true );
resog->setToggleAction( true );
new QAction( " 64 x 48", 0, 0, resog, "64x48", true );
new QAction( "128 x 96", 0, 0, resog, "128x96", true );
new QAction( "192 x 144", 0, 0, resog, "192x144", true );
new QAction( "256 x 192", 0, 0, resog, "256x192", true );
new QAction( "320 x 240", 0, 0, resog, "320x240", true );
new QAction( "384 x 288", 0, 0, resog, "384x288", true );
new QAction( "448 x 336", 0, 0, resog, "448x336", true );
new QAction( "512 x 384", 0, 0, resog, "512x384", true );
new QAction( "576 x 432", 0, 0, resog, "576x432", true );
new QAction( "640 x 480", 0, 0, resog, "640x480", true );
a = (QAction*) resog->child( QString().sprintf( "%dx%d", captureX>captureY ? captureX:captureY, captureX>captureY ? captureY:captureX ) );
if ( a ) a->setOn( true );
else owarn << "can't set resolution" << oendl;
qualityg = new QActionGroup( 0, "quality", true );
qualityg->setToggleAction( true );
new QAction( " 0 (&minimal)", 0, 0, qualityg, "0", true );
new QAction( " 25 (&low)", 0, 0, qualityg, "25", true );
new QAction( " 50 (&good)", 0, 0, qualityg, "50", true );
new QAction( " 75 (&better)", 0, 0, qualityg, "75", true );
new QAction( "100 (bes&t)", 0, 0, qualityg, "100", true );
a = (QAction*) qualityg->child( QString().sprintf( "%d", quality ) );
if ( a ) a->setOn( true );
else owarn << "can't set quality" << oendl;
zoomg = new QActionGroup( 0, "zoom", true );
zoomg->setToggleAction( true );
new QAction( "x 1", 0, 0, zoomg, "1", true );
new QAction( "x 2", 0, 0, zoomg, "2", true );
a = (QAction*) zoomg->child( QString().sprintf( "%d", zoom ) );
if ( a ) a->setOn( true );
else owarn << "can't set zoom" << oendl;
flipg = new QActionGroup( 0, "flip", true );
flipg->setToggleAction( true );
new QAction( "Auto (recommended)", 0, 0, flipg, "A", true );
new QAction( "0 (always off)", 0, 0, flipg, "0", true );
new QAction( "X (always horizontal)", 0, 0, flipg, "X", true );
new QAction( "Y (always vertical)", 0, 0, flipg, "Y", true );
new QAction( "* (always both)", 0, 0, flipg, "*", true );
a = (QAction*) flipg->child( QString().sprintf( "%s", (const char*) flip ) );
if ( a ) a->setOn( true );
else owarn << "can't set flip" << oendl;
outputTog = new QActionGroup( 0, "output", true );
outputTog->setToggleAction( true );
new QAction( "/tmp/", 0, 0, outputTog, "/tmp/", true );
new QAction( "/mnt/card/", 0, 0, outputTog, "/mnt/card/", true );
new QAction( "/mnt/cf/", 0, 0, outputTog, "/mnt/cf/", true );
docfolder = new QAction( "Documents Folder", 0, 0, outputTog, "Documents Folder", true );
custom = new QAction( "&Custom...", 0, 0, outputTog, "custom", true ); //TODO: How to save custom!?
a = (QAction*) outputTog->child( QString().sprintf( "%s", (const char*) outputTo ) );
if ( a ) a->setOn( true );
else owarn << "can't set outputTo" << oendl;
outputg = new QActionGroup( 0, "output", true );
outputg->setToggleAction( true );
new QAction( "JPEG", 0, 0, outputg, "JPEG", true );
new QAction( "PNG", 0, 0, outputg, "PNG", true );
new QAction( "BMP", 0, 0, outputg, "BMP", true );
new QAction( "AVI", 0, 0, outputg, "AVI", true );
a = (QAction*) outputg->child( QString().sprintf( "%s", (const char*) captureFormat ) );
if ( a ) a->setOn( true );
else owarn << "can't set output format" << oendl;
connect( resog, SIGNAL( selected(QAction*) ), this, SLOT( resoMenuItemClicked(QAction*) ) );
connect( qualityg, SIGNAL( selected(QAction*) ), this, SLOT( qualityMenuItemClicked(QAction*) ) );
connect( zoomg, SIGNAL( selected(QAction*) ), this, SLOT( zoomMenuItemClicked(QAction*) ) );
connect( flipg, SIGNAL( selected(QAction*) ), this, SLOT( flipMenuItemClicked(QAction*) ) );
connect( outputTog, SIGNAL( selected(QAction*) ), this, SLOT( outputToMenuItemClicked(QAction*) ) );
connect( outputg, SIGNAL( selected(QAction*) ), this, SLOT( outputMenuItemClicked(QAction*) ) );
}
void CameraMainWindow::systemMessage( const QCString& msg, const QByteArray& data )
{
int _newrotation;
QDataStream stream( data, IO_ReadOnly );
odebug << "received system message: " << msg << oendl;
if ( msg == "setCurrentRotation(int)" )
{
stream >> _newrotation;
odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl;
switch ( _newrotation )
{
case 270: preview->resize( QSize( 240, 288 ) ); break;
case 180: preview->resize( QSize( 320, 208 ) ); break;
default: QMessageBox::warning( this, "opie-camera",
"This rotation is not supported.\n"
"Supported are 180° and 270°" );
}
if ( _newrotation != _rotation )
{
int tmp = captureX;
captureX = captureY;
captureY = tmp;
_rotation = _newrotation;
}
updateCaption();
}
}
void CameraMainWindow::changeZoom( int zoom )
{
int z;
switch ( zoom )
{
case 0: z = 128; break;
case 1: z = 256; break;
case 2: z = 512; break;
default: assert( 0 ); break;
}
ZCameraIO::instance()->setCaptureFrame( 240, 160, z );
}
void CameraMainWindow::showContextMenu()
{
QPopupMenu reso;
reso.setCheckable( true );
resog->addTo( &reso );
QPopupMenu quality;
quality.setCheckable( true );
qualityg->addTo( &quality );
QPopupMenu flip;
flip.setCheckable( true );
flipg->addTo( &flip );
QPopupMenu zoom;
zoom.setCheckable( true );
zoomg->addTo( &zoom );
QPopupMenu prefix;
prefix.insertItem( "&Choose...", this, SLOT( prefixItemChoosen() ) );
int id = prefix.insertItem( "&Append Settings", this, SLOT( appendSettingsChoosen() ) );
prefix.setItemChecked( id, appendSettings );
QPopupMenu outputTo;
outputTo.setCheckable( true );
outputTog->addTo( &outputTo );
QPopupMenu output;
output.setCheckable( true );
outputg->addTo( &output );
QPopupMenu m( this );
m.insertItem( "&Resolution", &reso );
m.insertItem( "&Zoom", &zoom );
m.insertItem( "&Flip", &flip );
m.insertItem( "&Quality", &quality );
m.insertSeparator();
m.insertItem( "&Prefix", &prefix );
m.insertItem( "Output &To", &outputTo );
m.insertItem( "&Output As", &output );
#ifndef QT_NO_DEBUG
m.insertItem( "&Debug!", this, SLOT( doSomething() ) );
#endif
m.exec( QCursor::pos() );
}
void CameraMainWindow::resoMenuItemClicked( QAction* a )
{
switch ( _rotation )
{
case 270:
captureY = a->text().left(3).toInt();
captureX = a->text().right(3).toInt();
break;
case 180:
captureX = a->text().left(3).toInt();
captureY = a->text().right(3).toInt();
break;
default: QMessageBox::warning( this, "opie-camera",
"This rotation is not supported.\n"
"Supported are 180° and 270°" );
}
odebug << "Capture Resolution now: " << captureX << ", " << captureY << oendl;
updateCaption();
}
void CameraMainWindow::qualityMenuItemClicked( QAction* a )
{
quality = a->text().left(3).toInt();
odebug << "Quality now: " << quality << oendl;
updateCaption();
}
void CameraMainWindow::zoomMenuItemClicked( QAction* a )
{
zoom = QString( a->text().at(2) ).toInt();
odebug << "Zoom now: " << zoom << oendl;
ZCameraIO::instance()->setZoom( zoom );
updateCaption();
}
void CameraMainWindow::flipMenuItemClicked( QAction* a )
{
flip = QString( a->text().at(0) );
odebug << "Flip now: " << flip << oendl;
if ( flip == "A" )
ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP );
else if ( flip == "0" )
ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP );
else if ( flip == "X" )
ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP );
else if ( flip == "Y" )
ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP );
else if ( flip == "*" )
ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP );
updateCaption();
}
void CameraMainWindow::outputToMenuItemClicked( QAction* a )
{
if ( a->text() == "&Custom..." )
{
QMap<QString, QStringList> map;
map.insert( tr("All"), QStringList() );
QStringList text;
text << "text/*";
map.insert(tr("Text"), text );
text << "*";
map.insert(tr("All"), text );
QString str;
str = OFileDialog::getSaveFileName( 2, "/", QString::null, map );
if ( str.isEmpty() || !QFileInfo(str).isDir() )
{
docfolder->setOn( true );
outputTo = "Documents Folder";
}
else
{
outputTo = str;
}
}
else
{
outputTo = a->text();
}
odebug << "Output to now: " << outputTo << oendl;
}
void CameraMainWindow::outputMenuItemClicked( QAction* a )
{
captureFormat = a->text();
odebug << "Output format now: " << captureFormat << oendl;
updateCaption();
}
void CameraMainWindow::prefixItemChoosen()
{
QDialog* d = new QDialog( this, "dialog", true );
d->setCaption( "Enter Prefix..." );
QVBoxLayout* v = new QVBoxLayout( d );
QLineEdit* le = new QLineEdit( prefix, d );
v->addWidget( le );
le->setFixedWidth( 150 ); //FIXME: 'tis a bit dirty
if ( d->exec() == QDialog::Accepted )
prefix = le->text();
odebug << "Prefix now: " << prefix << oendl;
}
void CameraMainWindow::appendSettingsChoosen()
{
appendSettings = !appendSettings;
odebug << "appendSettings now: " << appendSettings << oendl;
}
void CameraMainWindow::shutterClicked()
{
if ( captureFormat != "AVI" ) // capture one photo per shutterClick
{
Global::statusMessage( "CAPTURING..." );
qApp->processEvents();
odebug << "Shutter has been pressed" << oendl;
ODevice::inst()->playTouchSound();
performCapture( captureFormat );
}
else // capture video! start with one shutter click and stop with the next
{
diff --git a/noncore/multimedia/camera/lib/imageio.cpp b/noncore/multimedia/camera/lib/imageio.cpp
index ed0d39f..7d20848 100644
--- a/noncore/multimedia/camera/lib/imageio.cpp
+++ b/noncore/multimedia/camera/lib/imageio.cpp
@@ -1,55 +1,56 @@
/**********************************************************************
** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#include "imageio.h"
#include <opie2/odebug.h>
#include <qimage.h>
+using namespace Opie::Core;
void bufferToImage( int _width, int _height, unsigned char* bp, QImage* image )
{
unsigned char* p;
image->create( _width, _height, 16 );
for ( int i = 0; i < _height; ++i )
{
p = image->scanLine( i );
for ( int j = 0; j < _width; j++ )
{
*p = *bp;
p++;
bp++;
*p = *bp;
p++;
bp++;
}
}
}
void imageToFile( QImage* i, const QString& name, const QString& format, int quality )
{
QImage im = i->convertDepth( 32 );
bool result = im.save( name, format, quality );
if ( !result )
{
oerr << "imageio-Problem while writing to " << name << oendl;
}
else
{
odebug << format << "-image has been successfully captured" << oendl;
}
}
diff --git a/noncore/multimedia/camera/lib/zcameraio.cpp b/noncore/multimedia/camera/lib/zcameraio.cpp
index d59cbbb..c4be42f 100644
--- a/noncore/multimedia/camera/lib/zcameraio.cpp
+++ b/noncore/multimedia/camera/lib/zcameraio.cpp
@@ -1,315 +1,317 @@
/**********************************************************************
** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#include "zcameraio.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <qimage.h>
#include <qdatetime.h>
#include <opie2/odebug.h>
#define SHARPZDC "/dev/sharp_zdc"
+using namespace Opie::Core;
+
ZCameraIO* ZCameraIO::_instance = 0;
ZCameraIO* ZCameraIO::instance()
{
if ( !ZCameraIO::_instance )
{
odebug << "Creating ZCameraIO::_instance" << oendl;
ZCameraIO::_instance = new ZCameraIO();
}
return ZCameraIO::_instance;
}
ZCameraIO::ZCameraIO()
: _pressed( false ), _height( 0 ), _width( 0 ), _zoom( 0 ),
_flip( -1 ), _rot( 0 ), _readlen( 0 )
{
_driver = ::open( SHARPZDC, O_RDWR );
if ( _driver == -1 )
oerr << "Can't open camera driver: " << strerror(errno) << oendl;
else
init();
}
void ZCameraIO::init()
{
if ( ZCameraIO::_instance )
ofatal << "Don't create more than one ZCameraIO instances." << oendl;
else
{
_timer = new QTime();
setReadMode( STATUS );
}
}
ZCameraIO::~ZCameraIO()
{
if ( _driver != -1 )
{
setReadMode( 0 );
::close( _driver );
}
}
bool ZCameraIO::isOpen() const
{
return _driver != -1;
}
bool ZCameraIO::isShutterPressed()
{
if ( _status[0] == 'S' )
{
if ( !_pressed ) // wasn't pressed before, but is now!
{
_pressed = true;
_timer->start();
return true;
}
if ( _timer->elapsed() > 2000 ) // the press is pretty old now
{
clearShutterLatch();
_status[0] = 's';
_pressed = false;
}
}
return false;
}
bool ZCameraIO::isFinderReversed() const
{
return _status[1] == 'M';
}
bool ZCameraIO::isCapturing() const
{
return _status[2] == 'C';
}
bool ZCameraIO::isAvailable() const
{
return _status[3] == 'A';
}
bool ZCameraIO::setCaptureFrame( int width, int height, int zoom, bool rot )
{
odebug << "setCaptureFrame( " << width << ", " << height << ", " << zoom << ", " << rot << " )" << oendl;
char b[100];
sprintf( b, "%c=%d,%d,%d,%d", rot ? 'R':'S', width, height, zoom, width*2 );
if ( write( b ) )
{
_width = width;
_height = height;
_zoom = zoom;
_rot = rot;
_readlen = 2 * _width * _height; // camera is fixed @ 16 bits per pixel
return true;
}
owarn << "couldn't write to driver" << oendl;
return false;
}
bool ZCameraIO::setZoom( int zoom )
{
return setCaptureFrame( _width, _height, zoom*256, _rot );
}
void ZCameraIO::setReadMode( int mode )
{
char b[10];
sprintf( b, "M=%d", mode );
write( b, mode <= 9 ? 3 : 4 );
if ( mode & STATUS ) // STATUS bit is set
{
read( _status, 4 );
if ( isShutterPressed() )
{
emit shutterClicked();
}
}
}
void ZCameraIO::setFlip( int flip )
{
_flip = flip;
}
void ZCameraIO::clearShutterLatch()
{
write( "B", 1 );
}
bool ZCameraIO::read( char* b, int len )
{
#ifndef NO_TIMING
QTime t;
t.start();
#endif
int rlen = ::read( _driver, b, len );
#ifndef NO_TIMING
int time = t.elapsed();
#else
int time = -1;
#endif
if ( rlen )
odebug << "read " << rlen << " ('" << b[0] << b[1] << b[2] << b[3] << "') [" << time << " ms] from driver." << oendl;
else
odebug << "read nothing from driver." << oendl;
return rlen == len;
}
bool ZCameraIO::write( char* buf, int len )
{
if ( !len )
len = strlen( buf );
odebug << "writing '" << buf << "' to driver." << oendl;
return ::write( _driver, buf, len ) == len;
}
bool ZCameraIO::snapshot( QImage* image )
{
setReadMode( STATUS );
odebug << "finder reversed = " << isFinderReversed() << oendl;
odebug << "rotation = " << _rot << oendl;
odebug << "w=" << _width << " h= " << _height << " readlen= " << _readlen << oendl;
int readmode;
if ( _flip == -1 ) // AUTO
{
if ( _rot ) // Portrait
{
readmode = IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0;
}
else // Landscape
{
readmode = IMAGE | XFLIP | YFLIP;
}
}
else // OVERRIDE
{
readmode = IMAGE | _flip;
}
setReadMode( readmode );
char buf[_readlen];
char* bp = buf;
unsigned char* p;
read( bp, _readlen );
image->create( _width, _height, 16 );
for ( int i = 0; i < _height; ++i )
{
p = image->scanLine( i );
for ( int j = 0; j < _width; j++ )
{
*p = *bp;
p++;
bp++;
*p = *bp;
p++;
bp++;
}
}
return true;
}
bool ZCameraIO::snapshot( unsigned char* buf )
{
setReadMode( STATUS );
odebug << "finder reversed = " << isFinderReversed() << oendl;
odebug << "rotation = " << _rot << oendl;
int readmode;
if ( _flip == -1 ) // AUTO
{
if ( _rot ) // Portrait
{
readmode = IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0;
}
else // Landscape
{
readmode = IMAGE | XFLIP | YFLIP;
}
}
else // OVERRIDE
{
readmode = IMAGE | _flip;
}
setReadMode( readmode );
read( (char*) buf, _readlen );
}
void ZCameraIO::captureFrame( int w, int h, int zoom, QImage* image )
{
int prot = _rot;
int pw = _width;
int ph = _height;
setCaptureFrame( w, h, zoom*256, w<h );
snapshot( image );
setCaptureFrame( pw, ph, _zoom, prot );
}
void ZCameraIO::captureFrame( int w, int h, int zoom, unsigned char* buf )
{
//FIXME: this is too slow
int pw = _width;
int ph = _height;
setCaptureFrame( w, h, zoom*256, _rot );
snapshot( buf );
setCaptureFrame( pw, ph, _zoom, _rot );
}
diff --git a/noncore/multimedia/opierec/helpwindow.cpp b/noncore/multimedia/opierec/helpwindow.cpp
index a3b29fa..6aebaa1 100644
--- a/noncore/multimedia/opierec/helpwindow.cpp
+++ b/noncore/multimedia/opierec/helpwindow.cpp
@@ -1,196 +1,196 @@
/****************************************************************************
** $Id$
**
** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
**
** This file is part of an example program for Qt. This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
#include "helpwindow.h"
#include <qlayout.h>
-#include <qpe/qpetoolbar.h>
+#include <qtoolbar.h>
#include <qpe/resource.h>
#include <qaction.h>
#include <qmenubar.h>
#include <ctype.h>
HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name )
: QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL()
{
QGridLayout *layout = new QGridLayout( this );
layout->setSpacing( 2);
layout->setMargin( 2);
qDebug(_path);
browser = new QTextBrowser( this );
QStringList Strlist;
Strlist.append( home_);
browser->mimeSourceFactory()->setFilePath( Strlist );
browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );
connect( browser, SIGNAL( textChanged() ), this, SLOT( textChanged() ) );
if ( !home_.isEmpty() )
browser->setSource( home_ );
QToolBar *toolbar = new QToolBar( this );
QAction *a = new QAction( tr( "Backward" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), browser, SLOT( backward() ) );
a->addTo( toolbar );
a = new QAction( tr( "Forward" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), browser, SLOT( forward() ) );
a->addTo( toolbar );
layout->addMultiCellWidget( toolbar, 0, 0, 0, 0);
layout->addMultiCellWidget( browser, 1, 2, 0, 2);
browser->setFocus();
}
void HelpWindow::setBackwardAvailable( bool b)
{
menuBar()->setItemEnabled( backwardId, b);
}
void HelpWindow::setForwardAvailable( bool b)
{
menuBar()->setItemEnabled( forwardId, b);
}
void HelpWindow::textChanged()
{
if ( browser->documentTitle().isNull() ) {
setCaption( "QpeRec - Helpviewer - " + browser->context() );
selectedURL = browser->context();
}
else {
setCaption( "QpeRec - Helpviewer - " + browser->documentTitle() ) ;
selectedURL = browser->documentTitle();
}
// if ( !selectedURL.isEmpty() && pathCombo ) {
// bool exists = FALSE;
// int i;
// for ( i = 0; i < pathCombo->count(); ++i ) {
// if ( pathCombo->text( i ) == selectedURL ) {
// exists = TRUE;
// break;
// }
// }
// if ( !exists ) {
// pathCombo->insertItem( selectedURL, 0 );
// pathCombo->setCurrentItem( 0 );
// mHistory[ hist->insertItem( selectedURL ) ] = selectedURL;
// } else
// pathCombo->setCurrentItem( i );
// selectedURL = QString::null;
// }
}
HelpWindow::~HelpWindow()
{
history.clear();
QMap<int, QString>::Iterator it = mHistory.begin();
for ( ; it != mHistory.end(); ++it )
history.append( *it );
QFile f( QDir::currentDirPath() + "/.history" );
f.open( IO_WriteOnly );
QDataStream s( &f );
s << history;
f.close();
bookmarks.clear();
QMap<int, QString>::Iterator it2 = mBookmarks.begin();
for ( ; it2 != mBookmarks.end(); ++it2 )
bookmarks.append( *it2 );
QFile f2( QDir::currentDirPath() + "/.bookmarks" );
f2.open( IO_WriteOnly );
QDataStream s2( &f2 );
s2 << bookmarks;
f2.close();
}
void HelpWindow::openFile()
{
#ifndef QT_NO_FILEDIALOG
#endif
}
void HelpWindow::newWindow()
{
( new HelpWindow(browser->source(), "qbrowser") )->show();
}
void HelpWindow::print()
{
#ifndef QT_NO_PRINTER
#endif
}
void HelpWindow::pathSelected( const QString &_path )
{
browser->setSource( _path );
QMap<int, QString>::Iterator it = mHistory.begin();
bool exists = FALSE;
for ( ; it != mHistory.end(); ++it ) {
if ( *it == _path ) {
exists = TRUE;
break;
}
}
if ( !exists )
mHistory[ hist->insertItem( _path ) ] = _path;
}
void HelpWindow::readHistory()
{
if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) {
QFile f( QDir::currentDirPath() + "/.history" );
f.open( IO_ReadOnly );
QDataStream s( &f );
s >> history;
f.close();
while ( history.count() > 20 )
history.remove( history.begin() );
}
}
void HelpWindow::readBookmarks()
{
if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) {
QFile f( QDir::currentDirPath() + "/.bookmarks" );
f.open( IO_ReadOnly );
QDataStream s( &f );
s >> bookmarks;
f.close();
}
}
void HelpWindow::histChosen( int i )
{
if ( mHistory.contains( i ) )
browser->setSource( mHistory[ i ] );
}
void HelpWindow::bookmChosen( int i )
{
if ( mBookmarks.contains( i ) )
browser->setSource( mBookmarks[ i ] );
}
void HelpWindow::addBookmark()
{
mBookmarks[ bookm->insertItem( caption() ) ] = caption();
}
diff --git a/noncore/multimedia/opierec/main.cpp b/noncore/multimedia/opierec/main.cpp
index bb51446..a435d8e 100644
--- a/noncore/multimedia/opierec/main.cpp
+++ b/noncore/multimedia/opierec/main.cpp
@@ -1,31 +1,33 @@
/***************************************************************************
+
main.cpp - main routine
***************************************************************************/
//// main.cpp
//// copyright 2001, 2002, by L. J. Potter <ljp@llornkcor.com>
/***************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "qtrec.h"
#ifdef PDAUDIO
int main(int argc, char* argv[]) {
QPEApplication a(argc, argv);
QtRec qtrec;
a.showMainWidget( &qtrec);
return a.exec();
}
#else
#include <opie2/oapplicationfactory.h>
+using namespace Opie::Core;
OPIE_EXPORT_APP( OApplicationFactory<QtRec> )
#endif