public static class PngCodecPNG, encoded and decoded, in about two hundred lines and with no imaging dependency.
Remarks
A reference picture nobody can open is a reference picture nobody will look at, and looking at it is the entire workflow when one fails. So baselines are PNGs rather than a raw blob: viewable in any file browser, diffable by eye, and small in git.
Written by hand rather than taken from a package. ImageSharp is in the dependency register but ADR-015 confines it to editor and tooling assemblies for licence reasons, and this assembly ships to game developers. PNG's baseline — one colour type, one bit depth, one interlace mode — is a couple of hundred lines, and the compression is System.IO.Compression's.
Written for Vixen.Graphics.Golden.Tests, then owned by Vixen.Ui.Testing, and now here. Each move was the same argument one step further down: a picture is written by more things than the one that needed it first, and the assembly a consumer cannot reference is the assembly that forces a second encoder. A UI testing library was the wrong owner for the last of those reasons — a game head that wants to write its own frame to a file cannot reference a test framework to do it, and Platform/ could not reference it at all.
⚠ The direction of the reference is the whole reason it can be shared. Everything that encodes a picture — the golden suites, the UI baselines, a --vixen-capture run — is above this assembly, and none of them is above each other. Sitting under all three is what stops the count of hand-written PNG encoders in this repository from going back up.
Methods (4)
public static byte[] Encode(in Bitmap image)Encodes a picture.
public static Bitmap Decode(ReadOnlySpan<byte> data)Decodes a picture.
public static Bitmap Load(string path)Reads a picture from disk.
public static void Save(string path, in Bitmap image)Writes a picture to disk, creating the directory if it is not there.
Used by (33)
- PaintedLayersTestsThirdPersonShooter.Frame.Tests
- BakedMaterialImageTestsVixen.Graphics.Golden.Tests
- CompositorImageTestsVixen.Graphics.Golden.Tests
- FrameCaptureVixen.App.Hosting
- GoldenImageVixen.Graphics.Golden.Tests
- LayeredMaterialImageTestsVixen.Graphics.Golden.Tests
- PngCodecTestsVixen.Core.Imaging.Tests
- RasterizerTestsVixen.Ui.Testing.Tests
- SmaaImageTestsVixen.Graphics.Golden.Tests
- StandardFrameTierImageTestsVixen.Graphics.Golden.Tests
- VfxBackendPictureTestsVixen.Vfx.Gpu.Tests
- VirtualGeometryGoldenTestsVixen.Graphics.Golden.Tests
- VisualBaselineVixen.Ui.Testing
- ComposedPaneCaptureTestsVixen.Editor.App.Tests
- EditorUiCompositingDeviceTestsVixen.Editor.App.Tests
- FixtureProjectVixen.Editor.Assets.Tests
- FrameCaptureTestsVixen.App.Tests
- LayerStackBakeRouteDeviceTestsVixen.Editor.Texturing.Tests
- LayerStackPanelDeviceTestsVixen.Editor.Texturing.Tests
- MaterialBakeVixen.Editor.Assets
- MaterialBakeAssetTestsVixen.Editor.Assets.Tests
- MaterialBakeRouteDeviceTestsVixen.Editor.Texturing.Tests
- MaterialBakeTestsVixen.Editor.Assets.Tests
- MaterialSplatTestsVixen.Editor.Assets.Tests
- MeshMapBakeVixen.Editor.Assets
- MeshMapCommandTestsVixen.Cli.Tests
- MeshMapEncodingTestsVixen.Editor.Assets.Tests
- MeshMapLibraryTestsVixen.Editor.App.Tests
- SplatBakeDeviceTestsVixen.Editor.Texturing.Tests
- TextureBakeVixen.Editor.TextureGraph
- TextureCommandTestsVixen.Cli.Tests
- TexturePlanDeviceTestsVixen.Editor.TextureGraph.Tests
- TextureRunnerVixen.Cli