MCPcopy Create free account
hub / github.com/DentonW/DevIL / WriteHeader

Function WriteHeader

DevIL/src-IL/src/il_dds-save.cpp:188–307  ·  view source on GitHub ↗

@TODO: Finish this, as it is incomplete.

Source from the content-addressed store, hash-verified

186
187// @TODO: Finish this, as it is incomplete.
188ILboolean WriteHeader(ILimage *Image, ILenum DXTCFormat, ILuint CubeFlags)
189{
190 ILuint i, FourCC, Flags1 = 0, Flags2 = 0, ddsCaps1 = 0,
191 LinearSize, BlockSize, ddsCaps2 = 0;
192
193 Flags1 |= DDS_LINEARSIZE | DDS_MIPMAPCOUNT
194 | DDS_WIDTH | DDS_HEIGHT | DDS_CAPS | DDS_PIXELFORMAT;
195 Flags2 |= DDS_FOURCC;
196
197 if (Image->Depth > 1)
198 Flags1 |= DDS_DEPTH;
199
200 // @TODO: Fix the pre-multiplied alpha problem.
201 if (DXTCFormat == IL_DXT2)
202 DXTCFormat = IL_DXT3;
203 else if (DXTCFormat == IL_DXT4)
204 DXTCFormat = IL_DXT5;
205
206 switch (DXTCFormat)
207 {
208 case IL_DXT1:
209 case IL_DXT1A:
210 FourCC = IL_MAKEFOURCC('D','X','T','1');
211 break;
212 case IL_DXT2:
213 FourCC = IL_MAKEFOURCC('D','X','T','2');
214 break;
215 case IL_DXT3:
216 FourCC = IL_MAKEFOURCC('D','X','T','3');
217 break;
218 case IL_DXT4:
219 FourCC = IL_MAKEFOURCC('D','X','T','4');
220 break;
221 case IL_DXT5:
222 FourCC = IL_MAKEFOURCC('D','X','T','5');
223 break;
224 case IL_ATI1N:
225 FourCC = IL_MAKEFOURCC('A', 'T', 'I', '1');
226 break;
227 case IL_3DC:
228 FourCC = IL_MAKEFOURCC('A','T','I','2');
229 break;
230 case IL_RXGB:
231 FourCC = IL_MAKEFOURCC('R','X','G','B');
232 break;
233 default:
234 // Error!
235 ilSetError(IL_INTERNAL_ERROR); // Should never happen, though.
236 return IL_FALSE;
237 }
238
239 iwrite("DDS ", 1, 4);
240 SaveLittleUInt(124); // Size1
241 SaveLittleUInt(Flags1); // Flags1
242 SaveLittleUInt(Image->Height);
243 SaveLittleUInt(Image->Width);
244
245 if (DXTCFormat == IL_DXT1 || DXTCFormat == IL_DXT1A || DXTCFormat == IL_ATI1N) {

Callers 1

iSaveDdsInternalFunction · 0.85

Calls 2

ilSetErrorFunction · 0.85
SaveLittleUIntFunction · 0.85

Tested by

no test coverage detected