Reputation: 3354
I've gotten the task to create a color lookup table for a program in C. The table should be stored in a lut file. Ok, I understand that "lut" stands for lookup table, but why is there this special file type? I have seen lut-examples inside code, where they are simply stored as arrays, I understand that. But what do I write in a file? I guess I'd just write the rgb-values into it without any brackets or commas and read it with fread(). But this also works if I saved the file as .c or whatever. So I feel that I don't quite get the idea of it.
Any help would be appreciated.
Upvotes: 0
Views: 1146
Reputation: 13256
There is nothing particularly special about a lookup table file, and there is no standardized format for such files. It all depends on the trade-offs you are looking to deal with. If the table needs to be accessed at compile time, then it will probably just be a C file (as you have already seen). If it needs to be accessed at run time in a separate file, then you will need to come up with a suitable format.
"Lookup table" often implies that looking up a value will be fast. Perhaps a binary file format will be most suitable (vs. a text format that you have to parse). If you have 256 RGB values, each consisting of 3 bytes, you can look up a particular RGB value in the file by taking the color number, multiplying by 3, and seeking to that location in the file.
Upvotes: 1