Line | |
---|
1 | #ifndef QT_CLEAN_NAMESPACE
|
---|
2 | #define QT_CLEAN_NAMESPACE
|
---|
3 | #endif
|
---|
4 | #include <qimageformatplugin.h>
|
---|
5 |
|
---|
6 | #ifndef QT_NO_IMAGEFORMATPLUGIN
|
---|
7 |
|
---|
8 | #ifdef QT_NO_IMAGEIO_JPEG
|
---|
9 | #undef QT_NO_IMAGEIO_JPEG
|
---|
10 | #endif
|
---|
11 | #include "../../../../src/kernel/qjpegio.cpp"
|
---|
12 |
|
---|
13 | class JPEGFormat : public QImageFormatPlugin
|
---|
14 | {
|
---|
15 | public:
|
---|
16 | JPEGFormat();
|
---|
17 |
|
---|
18 | QStringList keys() const;
|
---|
19 | bool loadImage( const QString &format, const QString &filename, QImage * );
|
---|
20 | bool saveImage( const QString &format, const QString &filename, const QImage & );
|
---|
21 | bool installIOHandler( const QString & );
|
---|
22 | };
|
---|
23 |
|
---|
24 | JPEGFormat::JPEGFormat()
|
---|
25 | {
|
---|
26 | }
|
---|
27 |
|
---|
28 |
|
---|
29 | QStringList JPEGFormat::keys() const
|
---|
30 | {
|
---|
31 | QStringList list;
|
---|
32 | list << "JPEG";
|
---|
33 |
|
---|
34 | return list;
|
---|
35 | }
|
---|
36 |
|
---|
37 | bool JPEGFormat::loadImage( const QString &format, const QString &filename, QImage *image )
|
---|
38 | {
|
---|
39 | if ( format != "JPEG" )
|
---|
40 | return FALSE;
|
---|
41 |
|
---|
42 | QImageIO io;
|
---|
43 | io.setFileName( filename );
|
---|
44 | io.setImage( *image );
|
---|
45 |
|
---|
46 | read_jpeg_image( &io );
|
---|
47 |
|
---|
48 | return TRUE;
|
---|
49 | }
|
---|
50 |
|
---|
51 | bool JPEGFormat::saveImage( const QString &format, const QString &filename, const QImage &image )
|
---|
52 | {
|
---|
53 | if ( format != "JPEG" )
|
---|
54 | return FALSE;
|
---|
55 |
|
---|
56 | QImageIO io;
|
---|
57 | io.setFileName( filename );
|
---|
58 | io.setImage( image );
|
---|
59 |
|
---|
60 | write_jpeg_image( &io );
|
---|
61 |
|
---|
62 | return TRUE;
|
---|
63 | }
|
---|
64 |
|
---|
65 | bool JPEGFormat::installIOHandler( const QString &name )
|
---|
66 | {
|
---|
67 | if ( name.upper() != "JPEG" )
|
---|
68 | return FALSE;
|
---|
69 |
|
---|
70 | qInitJpegIO();
|
---|
71 | return TRUE;
|
---|
72 | }
|
---|
73 |
|
---|
74 | Q_EXPORT_PLUGIN( JPEGFormat )
|
---|
75 |
|
---|
76 | #endif // QT_NO_IMAGEFORMATPLUGIN
|
---|
Note:
See
TracBrowser
for help on using the repository browser.