source: trunk/src/kernel/qimageformatplugin.cpp@ 135

Last change on this file since 135 was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 5.2 KB
Line 
1/****************************************************************************
2** $Id: qimageformatplugin.cpp 2 2005-11-16 15:49:26Z dmik $
3**
4** ...
5**
6** Copyright (C) 2001-2002 Trolltech AS. All rights reserved.
7**
8** This file is part of the kernel module of the Qt GUI Toolkit.
9**
10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file.
13**
14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file.
18**
19** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
20** licenses may use this file in accordance with the Qt Commercial License
21** Agreement provided with the Software.
22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30**
31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you.
33**
34**********************************************************************/
35
36#include "qimageformatplugin.h"
37#ifndef QT_NO_IMAGEFORMATPLUGIN
38#include "qimageformatinterface_p.h"
39#include "qimage.h"
40
41/*!
42 \class QImageFormatPlugin qimageformatplugin.h
43 \brief The QImageFormatPlugin class provides an abstract base for custom image format plugins.
44
45 \ingroup plugins
46
47 The image format plugin is a simple plugin interface that makes
48 it easy to create custom image formats that can be used
49 transparently by applications.
50
51 Writing an image format plugin is achieved by subclassing this
52 base class, reimplementing the pure virtual functions keys() and
53 installIOHandler(), and exporting the class with the
54 Q_EXPORT_PLUGIN macro. See the \link plugins-howto.html Plugins
55 documentation\endlink for details.
56*/
57
58/*!
59 \fn QStringList QImageFormatPlugin::keys() const
60
61 Returns the list of image formats this plugin supports.
62
63 \sa installIOHandler()
64*/
65
66
67/*!
68 \fn bool QImageFormatPlugin::installIOHandler( const QString &format )
69
70 Installs a QImageIO image I/O handler for the image format \a
71 format.
72
73 \sa keys()
74*/
75
76class QImageFormatPluginPrivate : public QImageFormatInterface
77{
78public:
79 QImageFormatPluginPrivate( QImageFormatPlugin *p )
80 : plugin( p )
81 {
82 }
83 virtual ~QImageFormatPluginPrivate();
84
85 QRESULT queryInterface( const QUuid &iid, QUnknownInterface **iface );
86 Q_REFCOUNT;
87
88 QStringList featureList() const;
89
90 QRESULT loadImage( const QString &format, const QString &filename, QImage * );
91 QRESULT saveImage( const QString &format, const QString &filename, const QImage & );
92
93 QRESULT installIOHandler( const QString & );
94
95private:
96 QImageFormatPlugin *plugin;
97};
98
99QImageFormatPluginPrivate::~QImageFormatPluginPrivate()
100{
101 delete plugin;
102}
103
104QRESULT QImageFormatPluginPrivate::queryInterface( const QUuid &iid, QUnknownInterface **iface )
105{
106 *iface = 0;
107
108 if ( iid == IID_QUnknown )
109 *iface = this;
110 else if ( iid == IID_QFeatureList )
111 *iface = this;
112 else if ( iid == IID_QImageFormat )
113 *iface = this;
114 else
115 return QE_NOINTERFACE;
116
117 (*iface)->addRef();
118 return QS_OK;
119}
120
121QStringList QImageFormatPluginPrivate::featureList() const
122{
123 return plugin->keys();
124}
125
126QRESULT QImageFormatPluginPrivate::loadImage( const QString &format, const QString &filename, QImage *image )
127{
128 return plugin->loadImage( format, filename, image ) ? QS_FALSE : QS_OK;
129}
130
131QRESULT QImageFormatPluginPrivate::saveImage( const QString &format, const QString &filename, const QImage &image )
132{
133 return plugin->saveImage( format, filename, image ) ? QS_FALSE : QS_OK;
134}
135
136QRESULT QImageFormatPluginPrivate::installIOHandler( const QString &format )
137{
138 return plugin->installIOHandler( format ) ? QS_FALSE : QS_OK;
139}
140
141/*!
142 Constructs an image format plugin. This is invoked automatically
143 by the Q_EXPORT_PLUGIN macro.
144*/
145QImageFormatPlugin::QImageFormatPlugin()
146 : QGPlugin( d = new QImageFormatPluginPrivate( this ) )
147{
148}
149
150/*!
151 Destroys the image format plugin.
152
153 You never have to call this explicitly. Qt destroys a plugin
154 automatically when it is no longer used.
155*/
156QImageFormatPlugin::~QImageFormatPlugin()
157{
158}
159
160
161/*!\internal
162 */
163bool QImageFormatPlugin::loadImage( const QString &format, const QString &filename, QImage *image )
164{
165 Q_UNUSED( format )
166 Q_UNUSED( filename )
167 Q_UNUSED( image )
168 return FALSE;
169}
170
171/*! \internal
172 */
173bool QImageFormatPlugin::saveImage( const QString &format, const QString &filename, const QImage &image )
174{
175 Q_UNUSED( format )
176 Q_UNUSED( filename )
177 Q_UNUSED( image )
178 return FALSE;
179}
180
181#endif // QT_NO_IMAGEFORMATPLUGIN
Note: See TracBrowser for help on using the repository browser.