Skip to content

About

A basic 16x16 grid based pixel editor

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Pixel Editor

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.

Tech Stack

  • Language: C# / .NET
  • UI Framework: WPF (Windows Presentation Foundation)
  • Rendering: WriteableBitmap with nearest-neighbor scaling
  • Dependencies: None (no NuGet packages, no MVVM frameworks)

How It Works

┌─────────────────────────────────────────────────┐
│                  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          │   │               │   │
│   └─────────────────────┘   └───────────────┘   │
└─────────────────────────────────────────────────┘

Program Flow

  1. Initialization — A 16×16 WriteableBitmap is created along with a byte[256] array (pixelData) that stores a color index (0–8) for each pixel. Index 0 represents white (empty).

  2. Drawing — Mouse events on the Image control map screen coordinates to grid cells. Each click or drag writes the currently selected color index into pixelData and calls RenderToBitmap(), which converts the index array into BGRA pixel data and writes it back to the bitmap.

  3. Palette Selection — Clicking a color button sets currentColorIndex to that color's index. The Erase button sets it to 0 (white). The Clear button resets all indices to 0.

  4. Export — The Export button opens a save dialog and writes the raw pixelData array (256 bytes) to a .bin file. Each byte is a direct color index — no headers, no compression, no metadata.

Binary Format

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)

Color Index Map

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

Screenshot

Demo

Getting Started

dotnet new wpf -o PixelEditor
cd PixelEditor
dotnet run

Project Structure

PixelEditor/
├── PixelEditor.csproj
├── App.xaml
├── App.xaml.cs
├── MainWindow.xaml
└── MainWindow.xaml.cs

About

A basic 16x16 grid based pixel editor

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages