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

Function iCheckSun

DevIL/src-IL/src/il_sun.cpp:117–138  ·  view source on GitHub ↗

Internal function used to check if the HEADER is a valid SUN header.

Source from the content-addressed store, hash-verified

115
116// Internal function used to check if the HEADER is a valid SUN header.
117ILboolean iCheckSun(SUNHEAD *Header)
118{
119 if (Header->MagicNumber != 0x59A66A95) // Magic number is always 0x59A66A95.
120 return IL_FALSE;
121 if (Header->Width == 0 || Header->Height == 0) // 0 dimensions are meaningless.
122 return IL_FALSE;
123 // These are the only valid depths that I know of.
124 if (Header->Depth != 1 && Header->Depth != 8 && Header->Depth != 24 && Header->Depth != 32)
125 return IL_FALSE;
126 if (Header->Type > IL_SUN_RGB) //@TODO: Support further types.
127 return IL_FALSE;
128 if (Header->ColorMapType > IL_SUN_RGB_MAP) //@TODO: Find out more about raw map.
129 return IL_FALSE;
130 // Color map cannot be 0 if there is a map indicated.
131 if (Header->ColorMapType > IL_SUN_NO_MAP && Header->ColorMapLength == 0)
132 return IL_FALSE;
133 //@TODO: These wouldn't make sense. Are they valid somehow? Find out...
134 if ((Header->Depth == 1 || Header->Depth == 32) && Header->Type == IL_SUN_BYTE_ENC)
135 return IL_FALSE;
136
137 return IL_TRUE;
138}
139
140
141// Internal function to get the header and check it.

Callers 2

iIsValidSunFunction · 0.85
iLoadSunInternalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected