A minimal PPM (P6) image viewer written in C using SDL2.
The program reads a PPM image from stdin and renders it pixel-by-pixel using an SDL_Surface.
This project is focused on learning low-level image rendering and SDL basics.
Tutorial : Video Tutorial Available(by Daniel Hirsch)
- PPM (P6 – binary)
- 8-bit RGB
- No scaling or color correction
- Reads and ignores the PPM magic number (
P6) - Reads image
widthandheight - Reads raw RGB bytes (
R G Bper pixel) - Draws each pixel directly onto an SDL window surface
Make sure SDL2 is installed.
gcc image.c -o image `sdl2-config --cflags --libs`./image < image.ppm- The SDL window size matches the PPM image dimensions. Rendering is done on the CPU, one pixel at a time
- Pixels are drawn using SDL_FillRect with a 1×1 SDL_Rect
- Correct (x, y) mapping is required to avoid image rotation
- An event loop is required to keep the window responsive