diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-17 00:32:19 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-17 00:32:19 +0000 |
commit | 0d382a262c0638d0f572fc37193ccc5ed3dc895f (patch) | |
tree | 8578dcddfce4191f3f7a142a37769df7add48475 /libk9copy/k9saveimage.cpp | |
download | k9copy-0d382a262c0638d0f572fc37193ccc5ed3dc895f.tar.gz k9copy-0d382a262c0638d0f572fc37193ccc5ed3dc895f.zip |
Added old abandoned version of k9copy
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/k9copy@1091546 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libk9copy/k9saveimage.cpp')
-rw-r--r-- | libk9copy/k9saveimage.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/libk9copy/k9saveimage.cpp b/libk9copy/k9saveimage.cpp new file mode 100644 index 0000000..b919510 --- /dev/null +++ b/libk9copy/k9saveimage.cpp @@ -0,0 +1,84 @@ +// +// C++ Implementation: k9saveimage +// +// Description: +// +// +// Author: Jean-Michel PETIT <k9copy@free.fr>, (C) 2007 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "k9saveimage.h" +#include "kdecmpeg2.h" +#include <stdio.h> + +#include <qimage.h> +#include <kstandarddirs.h> + +void k9SaveImage::drawImage(QImage *_image) { + m_cpt++; + if (m_cpt ==20) { + m_image=*_image; + m_decoder->pause(); + } +} + + +k9SaveImage::k9SaveImage() + : QObject(),QThread() +{ + m_tempFile= new KTempFile(locateLocal("tmp", "k9copy/k9p"), ""); + m_tempFile->setAutoDelete(true); + m_decoder=new kDecMPEG2(); + connect(m_decoder, SIGNAL(pixmapReady(QImage *)), this, SLOT(drawImage(QImage *))); +} + + +k9SaveImage::~k9SaveImage() +{ + delete m_decoder; + delete m_tempFile; +} + +void k9SaveImage::play() { + m_cpt=0; + m_stop=false; + m_timer.start(); + m_decoder->start(); +} +void k9SaveImage::stop() { + m_stop=true; + wait(); + m_decoder->stop(); +} + +void k9SaveImage::addData(uchar *_buffer, uint32_t _size) { + if (m_timer.elapsed() >=7000 ) { + if (m_mutex.tryLock()) { + m_size=_size; + + m_buffer=new uchar[m_size]; + tc_memcpy(m_buffer,_buffer,m_size); + m_mutex.unlock(); + start(LowestPriority); + } + m_timer.restart(); + } +} + + +void k9SaveImage::run() { + m_mutex.lock(); + m_cpt=0; + m_decoder->decode(m_buffer ,m_buffer+m_size,0); + delete m_buffer; + QString sFileName=m_tempFile->name(); + m_image.save(sFileName,"PNG"); + sFileName="\rINFOIMAGE:"+sFileName; + fprintf(stderr,sFileName.utf8()); + + m_mutex.unlock(); +} + +#include "k9saveimage.moc" |