How qaptivator/plainimg2 works
Project type and purpose
• This is a Windows-only, native desktop image-viewer application written in C.
• It uses SDL3 and SDL3_image (statically linked) to provide a minimal UI and fast image rendering.
• Build scripts produce both the standalone executable and an Inno Setup installer.
File structure
• Top-level files & scripts:
• build.sh / release.sh / tag_release.sh – orchestrate compilation, packaging, versioning
• installer.iss – Inno Setup script to generate a Windows installer
• src/ tree:
• src/main.c – application entry point, SDL event loop, settings & menu logic
• src/SDL3/ & src/SDL3_Image/ – embedded third-party static libraries with include/ lib/ cmake/ pkgconfig subtrees
• VERSION.txt, LICENSE.txt, README.md – metadata & documentation
Extract insights from the README
• Single-process, event-driven architecture
• Uses SDL3 for window creation, input handling, rendering surface
• Uses SDL3_image for image file decoding (PNG, JPEG, BMP)
• Settings serialized to settings.txt (simple 0/1 flags)
• Installer registers file associations for common image types
Main components
a. Runtime components:
1) plainIMG.exe (C code)
• Core modules:
– Init & teardown (SDL_Init / SDL_Quit)
– Event loop (keyboard, mouse, window events)
– Menu & settings manager (serialize/deserialize settings.txt)
– Image loader (calls IMG_Load via SDL3_image)
– Renderer (SDL_Texture → SDL_RenderCopy)
2) Embedded libraries (static .a):
– libSDL3.a
– libSDL3_image.a
3) Windows OS services:
– Window Manager (create native window, message pump)
– Filesystem (open image, read/write settings)
– Registry (file association via installer)
b. Build-time components:
1) GCC toolchain & windres – compile .c and .rc to .exe
2) CMake files inside src/SDL3 and src/SDL3_Image – document how static libs were built
3) build.sh – invokes windres and gcc to produce debug/release binaries
4) release.sh + installer.iss – wrap binaries into Inno Setup installer
c. External services (optional):
– GitHub (release artifacts upload via release.sh)
– VirusTotal (bad-actor check links in README)
Relationships & data flows
• Build pipeline: source files + embedded libs → compile/link (build.sh) → plainIMG.exe
• Packaging pipeline: executable + VERSION.txt + installer script → installer.exe (release.sh)
• Runtime flow:
1) User launches plainIMG.exe (or double-clicks image associated)
2) OS passes image path argument to exe
3) Application loads settings.txt → SDL_Init → IMG_Init
4) IMG_Load reads image bytes → SDL_Texture creation
5) Event loop listens for SDL_Event (keyboard, right-click, drag)
6) Renderer draws texture each frame (with/without antialiasing, black/white bg)
7) User actions toggle flags → settings updated in memory → rendered next frame
8) On exit, serialize settings.txt → SDL_Quit
Architectural patterns & design principles
• Layered architecture:
• Presentation layer (SDL window + rendering)
• Application logic layer (event handling, menu, settings)
• Data access layer (SDL_image file I/O, settings.txt I/O)
• Single responsibility per module: loading, rendering, settings management
• Event-driven loop as the core control flow
• Static linking to minimize external deployment dependencies