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

tdeprint

  • tdeprint
  • cups
imagepreview.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License version 2 as published by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  **/
19 
20 #include "imagepreview.h"
21 
22 #include <tqpainter.h>
23 #include <tqpixmap.h>
24 #include <tqpaintdevice.h>
25 
26 // forward definition
27 TQImage convertImage(const TQImage& image, int hue, int saturation, int brightness, int gamma);
28 
29 ImagePreview::ImagePreview(TQWidget *parent, const char *name ) : TQWidget(parent,name) {
30  brightness_ = 100;
31  hue_ = 0;
32  saturation_ = 100;
33  gamma_ = 1000;
34  bw_ = false;
35 
36  setBackgroundMode(NoBackground);
37 }
38 
39 ImagePreview::~ImagePreview(){
40 }
41 
42 void ImagePreview::setImage(const TQImage& image){
43  image_ = image.convertDepth(32);
44  image_.detach();
45  resize(image_.size());
46  update();
47 }
48 
49 void ImagePreview::setParameters(int brightness, int hue, int saturation, int gamma){
50  brightness_ = brightness;
51  hue_ = hue;
52  saturation_ = saturation;
53  gamma_ = gamma;
54  repaint();
55 }
56 
57 void ImagePreview::paintEvent(TQPaintEvent*){
58  TQImage tmpImage = convertImage(image_,hue_,(bw_ ? 0 : saturation_),brightness_,gamma_);
59  int x = (width()-tmpImage.width())/2, y = (height()-tmpImage.height())/2;
60 
61  TQPixmap buffer(width(), height());
62  buffer.fill(parentWidget(), 0, 0);
63  TQPainter p(&buffer);
64  p.drawImage(x,y,tmpImage);
65  p.end();
66 
67  bitBlt(this, TQPoint(0, 0), &buffer, buffer.rect(), TQt::CopyROP);
68 }
69 
70 void ImagePreview::setBlackAndWhite(bool on){
71  bw_ = on;
72  update();
73 }
74 
75 TQSize ImagePreview::minimumSizeHint() const
76 {
77  return image_.size();
78 }

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.9.1
This website is maintained by Timothy Pearson.