A minimal 16×16 pixel art editor built with WPF and C#. Made as a learning project — exports raw binary sprite data that can be consumed directly by a game runtime or asset pipeline.
- Language: C# / .NET
- UI Framework: WPF (Windows Presentation Foundation)
- Rendering: WriteableBitmap with nearest-neighbor scaling
- Dependencies: None (no NuGet packages, no MVVM frameworks)
┌─────────────────────────────────────────────────┐
│ MainWindow │
│ │
│ ┌─────────────────────┐ ┌───────────────┐ │
│ │ │ │ Palette │ │
│ │ WriteableBitmap │ │ [#051f39] │ │
│ │ (16×16 grid) │ │ [#28225d] │ │
│ │ │ │ [#4a2480] │ │
│ │ ↑ displayed via │ │ [#882f8f] │ │
│ │ Image control │ │ [#c53a9d] │ │
│ │ (320×320, │ │ [#e2648f] │ │
│ │ nearest- │ │ [#ff8e80] │ │
│ │ neighbor) │ │ [#ffa4a4] │ │
│ │ │ │ │ │
│ │ Mouse click/drag │ │ [Erase] │ │
│ │ → writes to │ │ [Export] │ │
│ │ pixelData[] │ │ [Clear] │ │
│ │ → re-renders │ │ │ │
│ │ bitmap │ │ │ │
│ └─────────────────────┘ └───────────────┘ │
└─────────────────────────────────────────────────┘
-
Initialization — A 16×16
WriteableBitmapis created along with abyte[256]array (pixelData) that stores a color index (0–8) for each pixel. Index 0 represents white (empty). -
Drawing — Mouse events on the Image control map screen coordinates to grid cells. Each click or drag writes the currently selected color index into
pixelDataand callsRenderToBitmap(), which converts the index array into BGRA pixel data and writes it back to the bitmap. -
Palette Selection — Clicking a color button sets
currentColorIndexto that color's index. The Erase button sets it to 0 (white). The Clear button resets all indices to 0. -
Export — The Export button opens a save dialog and writes the raw
pixelDataarray (256 bytes) to a.binfile. Each byte is a direct color index — no headers, no compression, no metadata.
| Offset | Size | Description |
|---|---|---|
| 0 | 1 byte | Color index for pixel (0,0) |
| 1 | 1 byte | Color index for pixel (1,0) |
| ... | ... | Row-major, left to right, top to bottom |
| 255 | 1 byte | Color index for pixel (15,15) |
Total file size: 256 bytes (16 × 16 × 1 byte per pixel)
| Index | Color (R,G,B) (Hex) |
|---|---|
| 0 | (255,255,255) (#ffffff) |
| 1 | (5,31,57) (#051f39) |
| 2 | (40,34,93) (#28225d) |
| 3 | (74,36,128) (#4a2480) |
| 4 | (136,47,143) (#882f8f) |
| 5 | (197,58,157) (#c53a9d) |
| 6 | (226,100,143) (#e2648f) |
| 7 | (255,142,128) (#ff8e80) |
| 8 | (255,164,164) (#ffa4a4) |
'LAVA-GBA EXTENDED PALETTE' by ryanbrooks-dev on https://lospec.com
dotnet new wpf -o PixelEditor
cd PixelEditor
dotnet runPixelEditor/
├── PixelEditor.csproj
├── App.xaml
├── App.xaml.cs
├── MainWindow.xaml
└── MainWindow.xaml.cs