KImgIO
rgb.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef KIMG_RGB_H
00012 #define KIMG_RGB_H
00013
00014 #include <qmap.h>
00015 #include <qptrvector.h>
00016
00017
00018 class QImage;
00019 class QImageIO;
00020
00021 extern "C" {
00022 void kimgio_rgb_read(QImageIO *);
00023 void kimgio_rgb_write(QImageIO *);
00024 }
00025
00026
00027 class RLEData : public QMemArray<uchar> {
00028 public:
00029 RLEData() {}
00030 RLEData(const uchar *d, uint l, uint o) : m_offset(o) { duplicate(d, l); }
00031 bool operator<(const RLEData&) const;
00032 void write(QDataStream& s);
00033 void print(QString) const;
00034 uint offset() { return m_offset; }
00035 private:
00036 uint m_offset;
00037 };
00038
00039
00040 class RLEMap : public QMap<RLEData, uint> {
00041 public:
00042 RLEMap() : m_counter(0), m_offset(0) {}
00043 uint insert(const uchar *d, uint l);
00044 QPtrVector<RLEData> vector();
00045 void setBaseOffset(uint o) { m_offset = o; }
00046 private:
00047 uint m_counter;
00048 uint m_offset;
00049 };
00050
00051
00052 class SGIImage {
00053 public:
00054 SGIImage(QImageIO *);
00055 ~SGIImage();
00056
00057 bool readImage(QImage&);
00058 bool writeImage(QImage&);
00059
00060 private:
00061 enum { NORMAL, DITHERED, SCREEN, COLORMAP };
00062 QImageIO *m_io;
00063 QIODevice *m_dev;
00064 QDataStream m_stream;
00065
00066 Q_UINT8 m_rle;
00067 Q_UINT8 m_bpc;
00068 Q_UINT16 m_dim;
00069 Q_UINT16 m_xsize;
00070 Q_UINT16 m_ysize;
00071 Q_UINT16 m_zsize;
00072 Q_UINT32 m_pixmin;
00073 Q_UINT32 m_pixmax;
00074 char m_imagename[80];
00075 Q_UINT32 m_colormap;
00076
00077 Q_UINT32 *m_starttab;
00078 Q_UINT32 *m_lengthtab;
00079 QByteArray m_data;
00080 QByteArray::Iterator m_pos;
00081 RLEMap m_rlemap;
00082 QPtrVector<RLEData> m_rlevector;
00083 uint m_numrows;
00084
00085 bool readData(QImage&);
00086 bool getRow(uchar *dest);
00087
00088 void writeHeader();
00089 void writeRle();
00090 void writeVerbatim(const QImage&);
00091 bool scanData(const QImage&);
00092 uint compact(uchar *, uchar *);
00093 uchar intensity(uchar);
00094 };
00095
00096 #endif
00097