{"id":16245835,"url":"https://github.com/equbuxu/clsencoderdecoder","last_synced_at":"2025-03-19T19:30:30.231Z","repository":{"id":92787297,"uuid":"502437136","full_name":"Equbuxu/CLSEncoderDecoder","owner":"Equbuxu","description":"A simple Encoder/Decoder for Color Set files from Clip Studio Paint (.cls)","archived":false,"fork":false,"pushed_at":"2022-06-12T16:43:10.000Z","size":13,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-14T13:18:13.696Z","etag":null,"topics":["binary-format","clip-studio-paint","library","palette","reverse-engineering"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Equbuxu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-11T19:21:15.000Z","updated_at":"2025-01-29T01:26:52.000Z","dependencies_parsed_at":"2023-06-03T03:30:20.151Z","dependency_job_id":null,"html_url":"https://github.com/Equbuxu/CLSEncoderDecoder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Equbuxu%2FCLSEncoderDecoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Equbuxu%2FCLSEncoderDecoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Equbuxu%2FCLSEncoderDecoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Equbuxu%2FCLSEncoderDecoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Equbuxu","download_url":"https://codeload.github.com/Equbuxu/CLSEncoderDecoder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244014029,"owners_count":20383714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary-format","clip-studio-paint","library","palette","reverse-engineering"],"created_at":"2024-10-10T14:28:14.151Z","updated_at":"2025-03-19T19:30:30.222Z","avatar_url":"https://github.com/Equbuxu.png","language":"C#","readme":"[![Download](https://img.shields.io/badge/nuget-download-blue)](https://www.nuget.org/packages/CLSEncoderDecoder/)\n\n# A simple Encoder/Decoder for Color Set files from Clip Studio Paint (.cls)\n## Examples\n### Saving\n```csharp\nClsColorSet set = new(\n    new List\u003cClsColor\u003e()\n    {\n        new ClsColor(123, 234, 243, 255),\n        new ClsColor(123, 234, 243, 0),\n    },\n    \"Color Set Name\");\nset.Save(\"TwoColors.cls\");\n```\n### Loading\n```csharp\nClsColorSet set = ClsColorSet.Load(@\"LightGrayish.cls\");\n```\n## .cls file format\n\nI reverse-engineered the format myself, so this is not a complete spec. \nI don't know if the values are signed or unsigned, \nbut it shouldn't matter for any reasonable color set. I assume unsigned in the code.\n\nCSP seems to treat any colors with non-zero alpha as fully opaque, \nso the only alpha values you should use are 0 and 255.\n\n### Types\n|  type   | description                                                                           |\n|:-------:|:--------------------------------------------------------------------------------------|\n|  int32  | number, 32 bit                                                                        |\n|  int16  | number, 16 bit                                                                        |\n|  rgba   | 4 bytes with RGBA values                                                              |\n|  ascii  | text encoded as ASCII, 1 byte/character (without string terminators or anything else) |\n|  utf8   | text encoded as UTF-8, 1-4 bytes/character                                            |\n\n### File sections\n\n#### Signature\n\n| type  | value |\n|:-----:|:-----:|\n| ascii | SLCC  |\n| int16 |  256  |\n\nI put 256 as a part of the signature, but it could also be an indication of the version\n\n#### Header\n\n| type  |                   value                   |\n|:-----:|:-----------------------------------------:|\n| int32 | length of the rest of the header in bytes |\n| int16 |  length of the following string in bytes  |\n| ascii |           name of the color set           |\n| int32 |                     0                     |\n| int16 |  length of the following string in bytes  |\n| utf8  |           name of the color set           |\n\nCSP ignored the ASCII name.\n\nThe zero in the middle seems to be useless, changing it to any other value doesn't prevent CSP from loading the file.\n\n#### Colors\n\n| type  |                   value                   |\n|:-----:|:-----------------------------------------:|\n| int32 |                     4                     |\n| int32 |             number of colors              |\n| int32 |    length of the next section in bytes    |\n\n\"4\" might be the number of channels, values above 4 prevent CSP from loading the file. 0-3 are treated the same as 4.\n\nThe next section contains all colors written one after another in the following format:\n\n| type  |                        value                        |\n|:-----:|:---------------------------------------------------:|\n| int32 | length of the rest of this block in bytes, always 8 |\n| rgba  |                      the color                      |\n| int32 |                          0                          |\n\nThe 0 in the end doesn't do anything as far as I can tell, but it has to be a zero. \nCuriously, you can omit the 0 and set the length to 4, and the file loads just fine.\nIncreasing the length and appending more zeros also doesn't break the file.\nI don't recommend doing any of that though, as CSP itself outputs colors with length 8 and a trailing 0.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fequbuxu%2Fclsencoderdecoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fequbuxu%2Fclsencoderdecoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fequbuxu%2Fclsencoderdecoder/lists"}