• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • @topname@
  • Sitemap
  • Contact Us
 

kdeprint

imagepreview.cpp

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License version 2 as published by the Free Software Foundation.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #include "imagepreview.h"
00021 
00022 #include <qpainter.h>
00023 #include <qpixmap.h>
00024 #include <qpaintdevice.h>
00025 
00026 // forward definition
00027 QImage convertImage(const QImage& image, int hue, int saturation, int brightness, int gamma);
00028 
00029 ImagePreview::ImagePreview(QWidget *parent, const char *name ) : QWidget(parent,name) {
00030     brightness_ = 100;
00031     hue_ = 0;
00032     saturation_ = 100;
00033     gamma_ = 1000;
00034     bw_ = false;
00035 
00036     setBackgroundMode(NoBackground);
00037 }
00038 
00039 ImagePreview::~ImagePreview(){
00040 }
00041 
00042 void ImagePreview::setImage(const QImage& image){
00043     image_ = image.convertDepth(32);
00044     image_.detach();
00045     resize(image_.size());
00046     update();
00047 }
00048 
00049 void ImagePreview::setParameters(int brightness, int hue, int saturation, int gamma){
00050     brightness_ = brightness;
00051     hue_ = hue;
00052     saturation_ = saturation;
00053     gamma_ = gamma;
00054     repaint();
00055 }
00056 
00057 void ImagePreview::paintEvent(QPaintEvent*){
00058     QImage  tmpImage = convertImage(image_,hue_,(bw_ ? 0 : saturation_),brightness_,gamma_);
00059     int x = (width()-tmpImage.width())/2, y = (height()-tmpImage.height())/2;
00060 
00061     QPixmap buffer(width(), height());
00062     buffer.fill(parentWidget(), 0, 0);
00063     QPainter    p(&buffer);
00064     p.drawImage(x,y,tmpImage);
00065     p.end();
00066 
00067     bitBlt(this, QPoint(0, 0), &buffer, buffer.rect(), Qt::CopyROP);
00068 }
00069 
00070 void ImagePreview::setBlackAndWhite(bool on){
00071     bw_ = on;
00072     update();
00073 }
00074 
00075 QSize ImagePreview::minimumSizeHint() const
00076 {
00077     return image_.size();
00078 }

kdeprint

Skip menu "kdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

@topname@

Skip menu "@topname@"
  •     kdnssd-avahi
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for @topname@ by doxygen 1.5.5
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal