Loads a palette from FileName into the current image's palette.
| 20 | |
| 21 | //! Loads a palette from FileName into the current image's palette. |
| 22 | ILboolean 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. |
nothing calls this directly
no test coverage detected