author | mickeyl <mickeyl> | 2003-04-01 23:19:16 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-01 23:19:16 (UTC) |
commit | 911a05806c4cce85750f3bd9bca84e18162cb739 (patch) (side-by-side diff) | |
tree | d5bbed42b991968852aa30e702deda95fa7b1393 /noncore | |
parent | 3497616220db68ea4105880c40c4c542d9b5228d (diff) | |
download | opie-911a05806c4cce85750f3bd9bca84e18162cb739.zip opie-911a05806c4cce85750f3bd9bca84e18162cb739.tar.gz opie-911a05806c4cce85750f3bd9bca84e18162cb739.tar.bz2 |
figured out how to get binary RAW data into a QImage
actual capturing is now only a footstep away :-D
-rw-r--r-- | noncore/multimedia/camera/mainwindow.cpp | 11 | ||||
-rw-r--r-- | noncore/multimedia/camera/mainwindow.h | 6 | ||||
-rw-r--r-- | noncore/multimedia/camera/zcameraio.cpp | 35 | ||||
-rw-r--r-- | noncore/multimedia/camera/zcameraio.h | 3 |
4 files changed, 49 insertions, 6 deletions
diff --git a/noncore/multimedia/camera/mainwindow.cpp b/noncore/multimedia/camera/mainwindow.cpp index 6431dfa..2cca9f9 100644 --- a/noncore/multimedia/camera/mainwindow.cpp +++ b/noncore/multimedia/camera/mainwindow.cpp @@ -1,50 +1,57 @@ /********************************************************************** ** 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 "zcameraio.h" #include <qvbox.h> #include <qpushbutton.h> #include <qlabel.h> #include <qpe/resource.h> #include <opie/ofiledialog.h> CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) :QMainWindow( parent, name, f ) { QVBox* v = new QVBox( this ); - QLabel* l = new QLabel( v ); + l = new QLabel( v ); l->setFixedSize( QSize( 240, 160 ) ); QPushButton* p = new QPushButton( "Snapshot", v ); connect( p, SIGNAL( clicked() ), this, SLOT( clickedSnapShot() ) ); v->show(); l->show(); p->show(); setCentralWidget( v ); }; CameraMainWindow::~CameraMainWindow() { } void CameraMainWindow::clickedSnapShot() { - qDebug( "Hello!" ); + QImage i; + QPixmap p; + if ( ZCameraIO::instance()->snapshot( &i ) ) + { + p.convertFromImage( i ); + l->setPixmap( p ); + } } diff --git a/noncore/multimedia/camera/mainwindow.h b/noncore/multimedia/camera/mainwindow.h index a349652..521107b 100644 --- a/noncore/multimedia/camera/mainwindow.h +++ b/noncore/multimedia/camera/mainwindow.h @@ -1,40 +1,42 @@ /********************************************************************** ** 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. ** **********************************************************************/ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <qmainwindow.h> -class Wellenreiter; -class WellenreiterConfigWindow; class QIconSet; class QToolButton; +class QLabel; class CameraMainWindow: public QMainWindow { Q_OBJECT public: CameraMainWindow( QWidget * parent = 0, const char * name = "mainwindow", WFlags f = 0 ); virtual ~CameraMainWindow(); protected: public slots: void clickedSnapShot(); + + private: + QLabel* l; }; #endif diff --git a/noncore/multimedia/camera/zcameraio.cpp b/noncore/multimedia/camera/zcameraio.cpp index aa6cbe3..e74136f 100644 --- a/noncore/multimedia/camera/zcameraio.cpp +++ b/noncore/multimedia/camera/zcameraio.cpp @@ -5,52 +5,85 @@ ** ** 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 <qimage.h> #include <opie2/odebug.h> +ZCameraIO* ZCameraIO::_instance = 0; + ZCameraIO::ZCameraIO() { _driver = open( "/dev/sharp_zdc", O_RDWR ); if ( _driver == -1 ) oerr << "Can't open camera driver: " << strerror(errno) << oendl; + ZCameraIO::_instance = this; }; ZCameraIO::~ZCameraIO() { if ( _driver != -1 ) close( _driver ); } -bool ZCameraIO::snapshot( QImage* img ) +bool ZCameraIO::snapshot( QImage* image ) { + /* + char buf[76800]; write( _driver, "M=13", 4 ); write( _driver, "R=240,160,256,480", 17 ); write( _driver, "M=12", 4 ); int result = read( _driver, &buf, sizeof buf ); return result == sizeof buf; + + */ + + uchar buf[76800]; + uchar* bp = buf; + uchar* p; + + + int fd = open( "/tmp/cam", O_RDONLY ); + if ( read( fd, buf, sizeof buf ) != sizeof buf ) + qDebug( "WARNING: couldn't read image!" ); + + image->create( 240, 160, 16 ); + for ( int i = 0; i < 160; ++i ) + { + p = image->scanLine( i ); + for ( int j = 0; j < 240; j++ ) + { + *p = *bp; + p++; + bp++; + *p = *bp; + p++; + bp++; + } + } + + return true; } diff --git a/noncore/multimedia/camera/zcameraio.h b/noncore/multimedia/camera/zcameraio.h index 817d3b4..1690aa6 100644 --- a/noncore/multimedia/camera/zcameraio.h +++ b/noncore/multimedia/camera/zcameraio.h @@ -4,32 +4,33 @@ ** 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. ** **********************************************************************/ #ifndef ZCAMERAIO_H #define ZCAMERAIO_H class QImage; class ZCameraIO { public: ZCameraIO(); virtual ~ZCameraIO(); bool isOpen() const { return _driver != -1; }; - bool snapshot( QImage* ); + static ZCameraIO* instance() { return _instance; }; private: int _driver; + static ZCameraIO* _instance; }; #endif |