summaryrefslogtreecommitdiffstats
path: root/plugins/src/imageformats/jpeg/main.cpp
blob: 3d795b4b163863e114dd58dacc3c8b7e76111248 (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
#include <tqimageformatplugin.h>

#ifndef TQT_NO_IMAGEFORMATPLUGIN

#ifdef TQT_NO_IMAGEIO_JPEG
#undef TQT_NO_IMAGEIO_JPEG
#endif
#include "../../../../src/kernel/tqjpegio.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;
}

TQ_EXPORT_PLUGIN( JPEGFormat )

#endif // TQT_NO_IMAGEFORMATPLUGIN