1 // kimgio module for SGI images
3 // Copyright (C) 2004 Melchior FRANZ <mfranz@kde.org>
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the Lesser GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
14 #include <QtGui/QImageIOPlugin>
15 #include <QtCore/QMap>
16 #include <QtCore/QVector>
19 class RGBHandler
: public QImageIOHandler
25 bool read(QImage
*image
);
26 bool write(const QImage
&image
);
27 QByteArray
name() const;
28 static bool canRead(QIODevice
*device
);
32 class RLEData
: public QVector
<uchar
> {
35 RLEData(const uchar
*d
, uint l
, uint o
) : _offset(o
) {
36 for (uint i
= 0; i
< l
; i
++)
39 bool operator<(const RLEData
&) const;
40 void write(QDataStream
& s
);
41 uint
offset() const { return _offset
; }
48 class RLEMap
: public QMap
<RLEData
, uint
> {
50 RLEMap() : _counter(0), _offset(0) {}
51 uint
insert(const uchar
*d
, uint l
);
52 QVector
<const RLEData
*> vector();
53 void setBaseOffset(uint o
) { _offset
= o
; }
63 SGIImage(QIODevice
*device
);
66 bool readImage(QImage
&);
67 bool writeImage(const QImage
&);
70 enum { NORMAL
, DITHERED
, SCREEN
, COLORMAP
}; // colormap
88 QByteArray::Iterator _pos
;
90 QVector
<const RLEData
*> _rlevector
;
93 bool readData(QImage
&);
94 bool getRow(uchar
*dest
);
98 void writeVerbatim(const QImage
&);
99 bool scanData(const QImage
&);
100 uint
compact(uchar
*, uchar
*);
101 uchar
intensity(uchar
);