summaryrefslogtreecommitdiffstats
path: root/plugins/src/imageformats/jpeg/main.cpp
blob: ef8fd9dde2605a964f08662a5741503bf84e254b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef QT_CLEAN_NAMESPACE
#define QT_CLEAN_NAMESPACE
#endif
#include <ntqimageformatplugin.h>

#ifndef QT_NO_IMAGEFORMATPLUGIN

#ifdef QT_NO_IMAGEIO_JPEG
#undef QT_NO_IMAGEIO_JPEG
#endif
#include "../../../../src/kernel/qjpegio.cpp"

class JPEGFormat : public TQImageFormatPlugin
{
public:
    JPEGFormat();

    TQStringList keys() const;
    bool loadImage( const TQString &format, const TQString &filename, TQImage * );
    bool saveImage( const TQString &format, const TQString &filename, const TQImage & );
    bool installIOHandler( const TQString & );
};

JPEGFormat::JPEGFormat()
{
}


TQStringList JPEGFormat::keys() const
{
    TQStringList list;
    list << "JPEG";

    return list;
}

bool JPEGFormat::loadImage( const TQString &format, const TQString &filename, TQImage *image )
{
    if ( format != "JPEG" )
	return FALSE;

    TQImageIO io;
    io.setFileName( filename );
    io.setImage( *image );

    read_jpeg_image( &io );

    return TRUE;
}

bool JPEGFormat::saveImage( const TQString &format, const TQString &filename, const TQImage &image )
{
    if ( format != "JPEG" )
	return FALSE;

    TQImageIO io;
    io.setFileName( filename );
    io.setImage( image );

    write_jpeg_image( &io );

    return TRUE;
}

bool JPEGFormat::installIOHandler( const TQString &name )
{
    if ( name.upper() != "JPEG" )
	return FALSE;

    qInitJpegIO();
    return TRUE;
}

Q_EXPORT_PLUGIN( JPEGFormat )

#endif // QT_NO_IMAGEFORMATPLUGIN