blob: 8a83b38c6d6c8632f14aa466ff3566ed375c4cb1 (
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
#ifndef _INCLUDED_IFF_ILBM_HPP_
#define _INCLUDED_IFF_ILBM_HPP_
#include "iff.hpp"
namespace IFF
{
class IlbmBmhdChunk : public Chunk
{
public:
UINT16 width;
UINT16 height;
UINT16 xTopLeft;
UINT16 yTopLeft;
UBYTE nBitPlanes;
enum
{
MASK_NONE = 0,
MASK_HASMASK = 1,
MASK_TRANSPARENTCOL = 2,
MASK_LASSO = 3
};
UBYTE eMasking;
enum
{
COMPRESS_NONE = 0,
COMPRESS_RUNLENGTH = 1,
COMPRESS_S3TC =2 //will have s3tc chunk instead of body chunk
};
UBYTE eCompression;
UBYTE flags;
UINT16 iTranspCol;
UBYTE xAspectRatio;
UBYTE yAspectRatio;
UINT16 xMax;
UINT16 yMax;
IlbmBmhdChunk() { m_idCk = "BMHD"; }
protected:
virtual void Serialize(Archive * pArchv);
};
class IlbmCmapChunk : public Chunk
{
public:
unsigned nEntries;
RGBTriple * pTable;
void CreateNew(unsigned nSize);
IlbmCmapChunk() : pTable(NULL) { m_idCk = "CMAP"; }
virtual ~IlbmCmapChunk();
protected:
virtual void Serialize(Archive * pArchv);
};
inline void IlbmCmapChunk::CreateNew(unsigned nSize)
{
if (pTable) delete[] pTable;
pTable = new RGBTriple [nSize];
nEntries = nSize;
}
class IlbmBodyChunk : public Chunk
{
public:
IlbmBodyChunk() : pData(NULL), pDecodeDst(NULL)
#ifndef IFF_READ_ONLY
, pEncodeDst(NULL), pEncodeSrc(NULL)
#endif
{ m_idCk = "BODY"; }
virtual ~IlbmBodyChunk();
#ifndef IFF_READ_ONLY
bool BeginEncode();
bool EncodeFirstRow(unsigned const * pRow);
bool EncodeNextRow(unsigned const * pRow);
bool EndEncode();
float GetCompressionRatio() const;
#endif
bool BeginDecode() const;
unsigned const * DecodeFirstRow() const;
unsigned const * DecodeNextRow() const;
bool EndDecode() const;
protected:
virtual void Serialize(Archive * pArchv);
virtual bool GetHeaderInfo() const; // fills in these three data members
mutable unsigned nWidth;
mutable unsigned eCompression;
mutable unsigned nBitPlanes;
private:
unsigned nSize;
UBYTE * pData;
mutable UBYTE const * pDecodeSrc;
mutable unsigned nRemaining;
mutable unsigned * pDecodeDst;
#ifndef IFF_READ_ONLY
DataBlock * pEncodeDst;
UBYTE * pEncodeSrc;
unsigned nSizeNonCprss;
unsigned nSizeCprss;
#endif
};
#ifndef IFF_READ_ONLY
inline bool IlbmBodyChunk::EncodeFirstRow(unsigned const * pRow)
{
if (BeginEncode())
return EncodeNextRow(pRow);
else
return false;
}
inline float IlbmBodyChunk::GetCompressionRatio() const
{
if (!nSizeNonCprss) return 0.0F;
return (static_cast<float>(nSizeNonCprss)-static_cast<float>(nSizeCprss))/static_cast<float>(nSizeNonCprss);
}
#endif
inline unsigned const * IlbmBodyChunk::DecodeFirstRow() const
{
if (BeginDecode())
return DecodeNextRow();
else
return NULL;
}
inline bool IlbmBodyChunk::EndDecode() const
{
if (pDecodeDst)
{
delete[] pDecodeDst;
pDecodeDst = NULL;
return true;
}
else return false;
}
class IlbmGrabChunk : public Chunk
{
public:
UINT16 xHotSpot;
UINT16 yHotSpot;
IlbmGrabChunk() { m_idCk = "GRAB"; }
protected:
virtual void Serialize(Archive * pArchv);
};
}
#endif // ! _INCLUDED_IFF_ILBM_HPP_
|