• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

imagepreview.cpp
00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <tdeprint@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 <tqpainter.h>
00023 #include <tqpixmap.h>
00024 #include <tqpaintdevice.h>
00025 
00026 // forward definition
00027 TQImage convertImage(const TQImage& image, int hue, int saturation, int brightness, int gamma);
00028 
00029 ImagePreview::ImagePreview(TQWidget *parent, const char *name ) : TQWidget(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 TQImage& 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(TQPaintEvent*){
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     TQPixmap    buffer(width(), height());
00062     buffer.fill(parentWidget(), 0, 0);
00063     TQPainter   p(&buffer);
00064     p.drawImage(x,y,tmpImage);
00065     p.end();
00066 
00067     bitBlt(this, TQPoint(0, 0), &buffer, buffer.rect(), TQt::CopyROP);
00068 }
00069 
00070 void ImagePreview::setBlackAndWhite(bool on){
00071     bw_ = on;
00072     update();
00073 }
00074 
00075 TQSize ImagePreview::minimumSizeHint() const
00076 {
00077     return image_.size();
00078 }

tdeprint

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

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.7.6.1
This website is maintained by Timothy Pearson.