blob: 424920221d4e78b59e6fc47e09a8aec91371dd87 (
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
// kimgio module for SGI images
//
// Copyright (C) 2004 Melchior FRANZ <mfranz@kde.org>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Lesser GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
#ifndef KIMG_RGB_H
#define KIMG_RGB_H
#include <tqmap.h>
#include <tqptrvector.h>
class TQImage;
class TQImageIO;
extern "C" {
void kimgio_rgb_read(TQImageIO *);
void kimgio_rgb_write(TQImageIO *);
}
class RLEData : public TQMemArray<uchar> {
public:
RLEData() {}
RLEData(const uchar *d, uint l, uint o) : m_offset(o) { duplicate(d, l); }
bool operator<(const RLEData&) const;
void write(TQDataStream& s);
void print(TQString) const; // TODO remove
uint offset() { return m_offset; }
private:
uint m_offset;
};
class RLEMap : public TQMap<RLEData, uint> {
public:
RLEMap() : m_counter(0), m_offset(0) {}
uint insert(const uchar *d, uint l);
TQPtrVector<RLEData> vector();
void setBaseOffset(uint o) { m_offset = o; }
private:
uint m_counter;
uint m_offset;
};
class SGIImage {
public:
SGIImage(TQImageIO *);
~SGIImage();
bool readImage(TQImage&);
bool writeImage(TQImage&);
private:
enum { NORMAL, DITHERED, SCREEN, COLORMAP }; // colormap
QImageIO *m_io;
QIODevice *m_dev;
QDataStream m_stream;
TQ_UINT8 m_rle;
TQ_UINT8 m_bpc;
TQ_UINT16 m_dim;
TQ_UINT16 m_xsize;
TQ_UINT16 m_ysize;
TQ_UINT16 m_zsize;
TQ_UINT32 m_pixmin;
TQ_UINT32 m_pixmax;
char m_imagename[80];
TQ_UINT32 m_colormap;
TQ_UINT32 *m_starttab;
TQ_UINT32 *m_lengthtab;
QByteArray m_data;
TQByteArray::Iterator m_pos;
RLEMap m_rlemap;
TQPtrVector<RLEData> m_rlevector;
uint m_numrows;
bool readData(TQImage&);
bool getRow(uchar *dest);
void writeHeader();
void writeRle();
void writeVerbatim(const TQImage&);
bool scanData(const TQImage&);
uint compact(uchar *, uchar *);
uchar intensity(uchar);
};
#endif
|