A lightweight image viewer written in C that renders binary PPM (P6) images using SDL2.
PixView is a minimal graphics application built to explore image parsing, raster rendering, and event-driven programming in C. It reads binary PPM (P6) images from standard input, decodes their pixel data, and displays them in an SDL2 window.
The project demonstrates the fundamentals of graphics programming while maintaining a compact and easily understandable codebase.
- Binary PPM (P6) image support
- SDL2-based rendering
- Standard input image streaming
- Lightweight implementation in C
- Event-driven window management
- Portable and easy to build
Screenshot or GIF goes here.
| Component | Technology |
|---|---|
| Language | C |
| Graphics Library | SDL2 |
| Image Format | Binary PPM (P6) |
- GCC or Clang
- SDL2 development libraries
Ubuntu/Debian
sudo apt install libsdl2-devmacOS
brew install sdl2gcc image_viewer.c -o pixview -lSDL2Run the viewer by piping a binary PPM image into standard input.
./pixview < image.ppmOr generate a PPM image dynamically using ImageMagick.
convert input.jpg ppm:- | ./pixviewPixView performs the following steps:
- Parses the PPM header.
- Reads the image dimensions.
- Loads RGB pixel data.
- Creates an SDL2 window.
- Renders each pixel.
- Processes window events until exit.
PixView/
│
├── image_viewer.c
├── README.md
└── LICENSE
| Format | Status |
|---|---|
| PPM (P6) | Supported |
| PPM (P3) | Not supported |
- Supports only binary PPM (P6) images.
- Assumes a maximum colour value of 255.
- Images are rendered pixel-by-pixel.
- Accepts input only through standard input.
- Limited validation of malformed files.
MIT License.