SVN_SILENT made messages (.desktop file)
[kdegraphics.git] / okular / ui / pagepainter.h
blob4044dd8bcef50c3ef9d7f9faacd33a466bcc9fde
1 /***************************************************************************
2 * Copyright (C) 2005 by Enrico Ros <eros.kde@email.it> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #ifndef _OKULAR_PAGEPAINTER_H_
11 #define _OKULAR_PAGEPAINTER_H_
13 #include <QtGui/QBrush>
14 #include <QtGui/QImage>
15 #include <QtGui/QPen>
17 #include "core/area.h" // for NormalizedPoint
19 class QPainter;
20 class QRect;
21 namespace Okular {
22 class Page;
25 /**
26 * @short Paints a Okular::Page to an open painter using given flags.
28 class PagePainter
30 public:
31 // list of flags passed to the painting function. by OR-ing those flags
32 // you can decide whether or not to permit drawing of a certain feature.
33 enum PagePainterFlags { Accessibility = 1, EnhanceLinks = 2,
34 EnhanceImages = 4, Highlights = 8,
35 TextSelection = 16, Annotations = 32 };
37 // draw (using painter 'p') the 'page' requested by 'id' using features
38 // in 'flags'. 'limits' is the bounding rect of the paint operation,
39 // 'scaledWidth' and 'scaledHeight' the expected size of page contents
40 static void paintPageOnPainter( QPainter * p, const Okular::Page * page, int pixID,
41 int flags, int scaledWidth, int scaledHeight, const QRect & pageLimits );
43 // draw (using painter 'p') the 'page' requested by 'id' using features
44 // in 'flags'.
45 // 'pageLimits' is the bounding rect of the paint operation relative to the
46 // top left of the (cropped) page.
47 // 'scaledWidth' and 'scaledHeight' the size of the page pixmap (before cropping).
48 // 'crop' is the (normalized) cropped rectangle within the page.
49 // The painter's (0,0) is assumed to be top left of the painted ('pageLimits') rect.
50 static void paintCroppedPageOnPainter( QPainter * p, const Okular::Page * page, int pixID,
51 int flags, int scaledWidth, int scaledHeight, const QRect & pageLimits,
52 const Okular::NormalizedRect & crop );
54 private:
55 static void cropPixmapOnImage( QImage & dest, const QPixmap * src, const QRect & r );
57 // create an image taking the 'cropRect' portion of an image scaled
58 // to 'scaledWidth' by 'scaledHeight' pixels. cropRect must be inside
59 // the QRect(0,0, scaledWidth,scaledHeight)
60 static void scalePixmapOnImage( QImage & dest, const QPixmap *src,
61 int scaledWidth, int scaledHeight, const QRect & cropRect, QImage::Format format = QImage::Format_ARGB32_Premultiplied );
63 // set the alpha component of the image to a given value
64 static void changeImageAlpha( QImage & image, unsigned int alpha );
66 // colorize a gray image to the given color
67 static void colorizeImage( QImage & image, const QColor & color,
68 unsigned int alpha = 255 );
70 // my pretty dear raster function
71 typedef QList< Okular::NormalizedPoint > NormalizedPath;
72 enum RasterOperation { Normal, Multiply };
73 static void drawShapeOnImage(
74 QImage & image,
75 const NormalizedPath & imagePoints,
76 bool closeShape = true,
77 const QPen & pen = QPen(),
78 const QBrush & brush = QBrush(),
79 double penWidthMultiplier = 1.0,
80 RasterOperation op = Normal
81 //float antiAliasRadius = 1.0
85 #endif