PNGParvus is C# implementation of svpng, which is a minimalistic PNG encoder.
- Define a
Color
stuct. Names of struct and fields are free to take, it's size of struct that matters.struct Color { byte R, G, B, A; //A is optional }
- Implement the interface
IPNG<Color>
. - Invoke
or
Write<TPNG, TColor>(ReadOnlySpan<char> path, TPNG png)
Write<TPNG, TColor, TStream>(TStream stream, TPNG png)
Generic type parameter TStream
allows any class inheriting form Stream
, thus you can output png to other streams, for example:
PNGParvus.Write<.., .., System.Stream>(Console.OpenStandardOutput(), ..);
This will output the png to console.
Run the PNGParvusTest
project, and a 256 * 256 PNG test.png
will be created at the folder where the compiled files locate, showing elapsed milliseconds.