00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __koPicture_h__
00021 #define __koPicture_h__
00022
00023 #include <QString>
00024 #include <QIODevice>
00025 #include <QPixmap>
00026 #include <koffice_export.h>
00027
00028 #include "KoPictureKey.h"
00029
00030 class KoXmlWriter;
00031 class QPainter;
00032 class QSize;
00033 class Q3DragObject;
00034 class KUrl;
00035
00036 class KoPictureShared;
00037
00043 class KOFFICECORE_EXPORT KoPicture
00044 {
00045 public:
00049 KoPicture(void);
00050
00054 ~KoPicture(void);
00055
00059 KoPicture(const KoPicture &other);
00060
00064 KoPicture& operator=(const KoPicture& other);
00065
00066 KoPictureType::Type getType(void) const;
00067
00071 KoPictureKey getKey(void) const;
00072
00076 void setKey(const KoPictureKey& key);
00077
00081 bool isNull(void) const;
00082
00097 void draw(QPainter& painter, int x, int y, int width, int height, int sx = 0, int sy = 0,
00098 int sw = -1, int sh = -1, bool fastMode = false);
00099
00106 Q3DragObject* dragObject( QWidget *dragSource = 0L, const char *name = 0L );
00107
00108 bool load(QIODevice* io, const QString& extension);
00109
00114 bool save(QIODevice* io) const;
00115
00126 bool saveAsBase64( KoXmlWriter& writer ) const;
00127
00131 QString getExtension(void) const;
00132
00136 QString getMimeType(void) const;
00137
00141 QSize getOriginalSize(void) const;
00142
00148 void clearAndSetMode(const QString& newMode);
00149
00153 void clear(void);
00154
00158 bool loadFromFile(const QString& fileName);
00159
00163 bool loadFromBase64(const QByteArray& str);
00164
00168 bool loadXpm(QIODevice* io);
00169
00176 QPixmap generatePixmap(const QSize& size, bool smoothScale = false);
00177
00186 bool setKeyAndDownloadPicture(const KUrl& url, QWidget *window);
00187
00194 QImage generateImage(const QSize& size);
00195
00199 bool hasAlphaBuffer() const;
00200
00204 void setAlphaBuffer(bool enable);
00205
00212 QImage createAlphaMask(Qt::ImageConversionFlags flags = Qt::AutoColor) const;
00213
00220 void clearCache(void);
00221
00222 QString uniquePictureId() const;
00223 void assignPictureId( uint _id);
00224
00225 protected:
00230 void unlinkSharedData(void);
00235 void linkSharedData(void) const;
00240 void createSharedData(void);
00241 QString uniqueName() const;
00242
00243 protected:
00248 KoPictureKey m_key;
00253 KoPictureShared* m_sharedData;
00254 static uint uniqueValue;
00255
00256 QString m_uniqueName;
00257 };
00258
00259 #endif