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/k9drawimage.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/k9drawimage.cpp')
-rw-r--r-- | libk9copy/k9drawimage.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/libk9copy/k9drawimage.cpp b/libk9copy/k9drawimage.cpp new file mode 100644 index 0000000..89aba8f --- /dev/null +++ b/libk9copy/k9drawimage.cpp @@ -0,0 +1,49 @@ +// +// C++ Implementation: k9drawimage +// +// Description: +// +// +// Author: Jean-Michel PETIT <[email protected]>, (C) 2007 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "k9drawimage.h" +#include <qpainter.h> + +k9DrawImage::k9DrawImage(QWidget *parent, const char *name) + : QWidget(parent, name) +{ +} + + +k9DrawImage::~k9DrawImage() +{ +} + +void k9DrawImage::setImage(const QImage &_image){ + m_pixmap =_image; + repaint(); +} + +void k9DrawImage::setImage(QString _fileName) { + m_pixmap.load(_fileName); + repaint(); +} + +void k9DrawImage::paintEvent ( QPaintEvent * ) { + int top,left; + QPainter p(this); + + double wratio=(double)width()/(double)m_pixmap.width(); + double hratio=(double)height()/(double)m_pixmap.height(); + double ratio= wratio < hratio ? wratio:hratio; + + top =(int) (height() -m_pixmap.height()*ratio)/2+1; + left =(int) (width() -m_pixmap.width()*ratio)/2 ; + + p.scale(ratio,ratio); + p.drawPixmap((int)(left/ratio),(int)(top/ratio),m_pixmap); + } +#include "k9drawimage.moc" |