1
/* This file is part of the KDE project
2
Copyright (c) 2001 Simon Hausmann <hausmann@kde.org>
3
Copyright (C) 2002, 2003, 2004 Nicolas GOUTTE <goutte@kde.org>
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 as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
* Boston, MA 02110-1301, USA.
20
#ifndef __koPictureEps_h__
21
#define __koPictureEps_h__
27
#include "KoPictureBase.h"
33
// TODO: fix documentation
37
* KoPictureEps is a container class for a EPS picture
39
class KoPictureEps : public KoPictureBase
43
* Default constructor.
50
virtual ~KoPictureEps();
52
KoPictureType::Type getType(void) const;
54
KoPictureBase* newCopy(void) const;
57
* Returns true if the picture is null.
59
virtual bool isNull(void) const;
62
* @brief Draw the image in a painter.
64
* No, this isn't as simple as painter.drawPixmap().
65
* This method ensures that the best quality is used when printing, scaling the painter.
67
* The parameter @p fastMode allows the picture to be re-sized and drawn quicker if possible
69
* The parameters @p width, @p height define the desired size for the image
70
* Note that the image is being scaled to that size using scale() - except when printing.
71
* This avoids scaling the image at each paint event.
73
* The other parameters are very similar to QPainter::drawPixmap :
74
* (@p x, @p y) define the position in the painter,
75
* (@p sx, @p sy) specify the top-left point in pixmap that is to be drawn. The default is (0, 0).
76
* (@p sw, @p sh) specify the size of the pixmap that is to be drawn. The default, (-1, -1), means all the way to the bottom
77
* right of the pixmap.
79
virtual void draw(QPainter& painter, int x, int y, int width, int height, int sx = 0, int sy = 0, int sw = -1, int sh = -1, bool fastMode = false);
81
virtual bool loadData(const QByteArray& array, const QString& extension);
83
virtual bool save(QIODevice* io) const;
85
virtual QSize getOriginalSize(void) const;
87
virtual QPixmap generatePixmap(const QSize& size, bool smoothScale = false);
89
virtual QString getMimeType(const QString& extension) const;
93
* (always in slow mode)
95
virtual QImage generateImage(const QSize& size);
97
virtual void clearCache(void);
99
QPixmap getPixmap(QImage& image);
100
void scaleAndCreatePixmap(const QSize& size, bool fastMode, const int resolutionx, const int resolutiony);
101
QImage scaleWithGhostScript(const QSize& size, const int resolutionx, const int resolutiony);
102
bool extractPostScriptStream(void);
105
int tryScaleWithGhostScript(QImage &image, const QSize& size, const int resolutionx, const int resolutiony, const char* device);
107
* @brief Read a line from a PostScript stream in a QByteArray
109
* The PostScript stream is somewhere in the QByteArray and therefore has to be
110
* determined by the start and length of this stream and the current position
112
* @param array the array which is read
113
* @param start start position of the PostScript stream
114
* @param length length of the PostScript stream
115
* @param pos current position (which is also returned)
116
* @param lastCharWasCr defines if the previous line ended with a Carriage Return,
117
* to skip an eventual Line Feed at the start of this line
118
* @return the read line
120
QString readLine(const QByteArray& array, const uint start, const uint length, uint& pos, bool& lastCharWasCr);
124
* Copy of the loaded EPS file
126
QByteArray m_rawData;
127
QPixmap m_cachedPixmap; ///< Cached pixmap
128
QSize m_originalSize; ///< Original size of the EPS picture
129
QSize m_cachedSize; ///< size of the currently cached pixmap @see m_cachedPixmap
130
QRect m_boundingBox; ///< Bounding box, as read from the EPS file
131
uint m_psStreamStart; ///< Start position of the PostScript stream (like if it was a MS-DOS EPS file)
132
uint m_psStreamLength; ///< Length of the PostScript stream (like if it was a MS-DOS EPS file)
134
* true, if the last cached image was done using fast mode.
135
* false, if the last cached image was done using slow mode.
137
bool m_cacheIsInFastMode;
140
#endif /* __koPictureEps_h__ */