CLSEncoderDecoder 1.0.0

dotnet add package CLSEncoderDecoder --version 1.0.0
NuGet\Install-Package CLSEncoderDecoder -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CLSEncoderDecoder" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CLSEncoderDecoder --version 1.0.0
#r "nuget: CLSEncoderDecoder, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CLSEncoderDecoder as a Cake Addin
#addin nuget:?package=CLSEncoderDecoder&version=1.0.0

// Install CLSEncoderDecoder as a Cake Tool
#tool nuget:?package=CLSEncoderDecoder&version=1.0.0

Download

A simple Encoder/Decoder for Color Set files from Clip Studio Paint (.cls)

Examples

Saving

ClsColorSet set = new(
    new List<ClsColor>()
    {
        new ClsColor(123, 234, 243, 255),
        new ClsColor(123, 234, 243, 0),
    },
    "Color Set Name");
set.Save("TwoColors.cls");

Loading

ClsColorSet set = ClsColorSet.Load(@"LightGrayish.cls");

.cls file format

I reverse-engineered the format myself, so this is not a complete spec. I don't know if the values are signed or unsigned, but it shouldn't matter for any reasonable color set. I assume unsigned in the code.

CSP seems to treat any colors with non-zero alpha as fully opaque, so the only alpha values you should use are 0 and 255.

Types

type description
int32 number, 32 bit
int16 number, 16 bit
rgba 4 bytes with RGBA values
ascii text encoded as ASCII, 1 byte/character (without string terminators or anything else)
utf8 text encoded as UTF-8, 1-4 bytes/character

File sections

Signature
type value
ascii SLCC
int16 256

I put 256 as a part of the signature, but it could also be an indication of the version

type value
int32 length of the rest of the header in bytes
int16 length of the following string in bytes
ascii name of the color set
int32 0
int16 length of the following string in bytes
utf8 name of the color set

CSP ignored the ASCII name.

The zero in the middle seems to be useless, changing it to any other value doesn't prevent CSP from loading the file.

Colors
type value
int32 4
int32 number of colors
int32 length of the next section in bytes

"4" might be the number of channels, values above 4 prevent CSP from loading the file. 0-3 are treated the same as 4.

The next section contains all colors written one after another in the following format:

type value
int32 length of the rest of this block in bytes, always 8
rgba the color
int32 0

The 0 in the end doesn't do anything as far as I can tell, but it has to be a zero. Curiously, you can omit the 0 and set the length to 4, and the file loads just fine. Increasing the length and appending more zeros also doesn't break the file. I don't recommend doing any of that though, as CSP itself outputs colors with length 8 and a trailing 0.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on CLSEncoderDecoder:

Repository Stars
PixiEditor/PixiEditor
PixiEditor is a lightweight pixel art editor made with .NET 7
Version Downloads Last updated
1.0.0 1,819 6/12/2022