00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "imageio.h"
00017
00018 #include <opie2/odebug.h>
00019 #include <qimage.h>
00020
00021 using namespace Opie::Core;
00022
00023 void bufferToImage( int _width, int _height, unsigned char* bp, QImage* image )
00024 {
00025 unsigned char* p;
00026
00027 image->create( _width, _height, 16 );
00028 for ( int i = 0; i < _height; ++i )
00029 {
00030 p = image->scanLine( i );
00031 for ( int j = 0; j < _width; j++ )
00032 {
00033 *p = *bp;
00034 p++;
00035 bp++;
00036 *p = *bp;
00037 p++;
00038 bp++;
00039 }
00040 }
00041 }
00042
00043
00044 void imageToFile( QImage* i, const QString& name, const QString& format, int quality )
00045 {
00046 QImage im = i->convertDepth( 32 );
00047 bool result = im.save( name, format, quality );
00048 if ( !result )
00049 {
00050 oerr << "imageio-Problem while writing to " << name << oendl;
00051 }
00052 else
00053 {
00054 odebug << format << "-image has been successfully captured" << oendl;
00055 }
00056 }