MCPcopy Create free account
hub / github.com/DentonW/DevIL / ILAPIENTRY ilLoadPal

Function ILAPIENTRY ilLoadPal

DevIL/src-IL/src/il_pal.cpp:22–64  ·  view source on GitHub ↗

Loads a palette from FileName into the current image's palette.

Source from the content-addressed store, hash-verified

20
21//! Loads a palette from FileName into the current image's palette.
22ILboolean ILAPIENTRY ilLoadPal(ILconst_string FileName)
23{
24 FILE *f;
25 ILboolean IsPsp;
26 char Head[8];
27
28 if (FileName == NULL) {
29 ilSetError(IL_INVALID_PARAM);
30 return IL_FALSE;
31 }
32
33 if (iCheckExtension(FileName, IL_TEXT("col"))) {
34 return ilLoadColPal(FileName);
35 }
36 if (iCheckExtension(FileName, IL_TEXT("act"))) {
37 return ilLoadActPal(FileName);
38 }
39 if (iCheckExtension(FileName, IL_TEXT("plt"))) {
40 return ilLoadPltPal(FileName);
41 }
42
43#ifndef _UNICODE
44 f = fopen(FileName, "rt");
45#else
46 f = _wfopen(FileName, L"rt");
47#endif//_UNICODE
48 if (f == NULL) {
49 ilSetError(IL_COULD_NOT_OPEN_FILE);
50 return IL_FALSE;
51 }
52
53 fread(Head, 1, 8, f);
54 if (!strncmp(Head, "JASC-PAL", 8))
55 IsPsp = IL_TRUE;
56 else
57 IsPsp = IL_FALSE;
58
59 fclose(f);
60
61 if (IsPsp)
62 return ilLoadJascPal(FileName);
63 return ilLoadHaloPal(FileName);
64}
65
66
67//! Loads a Paint Shop Pro formatted palette (.pal) file.

Callers

nothing calls this directly

Calls 7

ilSetErrorFunction · 0.85
iCheckExtensionFunction · 0.85
ilLoadColPalFunction · 0.85
ilLoadActPalFunction · 0.85
ilLoadPltPalFunction · 0.85
ilLoadJascPalFunction · 0.85
ilLoadHaloPalFunction · 0.85

Tested by

no test coverage detected