Internal function used to check if the HEADER is a valid SUN header.
| 115 | |
| 116 | // Internal function used to check if the HEADER is a valid SUN header. |
| 117 | ILboolean 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. |
no outgoing calls
no test coverage detected