A small C library that detects, inspects, decodes, and converts the
classic Amiga image and icon formats into modern RGBA buffers, PNG files,
and (optionally) SDL_Surface objects.
| Format | Description |
|---|---|
| IFF ILBM / PBM | Classic Amiga IFF images: 1–8 bitplanes, 24-bit deep ILBM, HAM6 / HAM8, EHB, ByteRun1 compression, optional mask plane |
| Classic / MagicWB | The original 8-color .info icon (depth-1..4); depth-3 with the standard MagicWB palette is the MagicWB profile |
| NewIcons | Image data hidden inside ToolTypes IM1= / IM2= lines (Dirk Stoecker's spec) |
| GlowIcons | OS 3.5+ truecolor icons; an IFF FORM ICON block appended after the classic .info structure |
The header is iffliction.h. Every function in the public API is prefixed
with iffliction_*; internal helpers are prefixed _iffliction_* and
have file-scope linkage.
int iffliction_is_iff_image (const char *file_path);
int iffliction_is_magicwb_icon (const char *file_path);
int iffliction_is_new_icon (const char *file_path);
int iffliction_is_glow_icon (const char *file_path);
iffliction_type_t iffliction_detect_type(const char *file_path);
const char *iffliction_type_name (iffliction_type_t t);Returns 1 if the file matches that specific format, 0 if it does
not, -1 on I/O error.
iffliction_detect_type() returns the most specific match
(GlowIcons > NewIcons > MagicWB > generic classic icon > IFF image).
int iffliction_get_iff_image_information (const char *path, iffliction_info_t *out);
int iffliction_get_magicwb_icon_information(const char *path, iffliction_info_t *out);
int iffliction_get_new_icon_information (const char *path, iffliction_info_t *out);
int iffliction_get_glow_icon_information (const char *path, iffliction_info_t *out);Fills iffliction_info_t (width, height, depth, num_colors, num_images,
has_transparency, plus format-specific fields like camg, is_ham,
icon_type, etc.). Returns 0 on success, -1 on error.
int iffliction_magicwb_icon_decode(const char *path,
iffliction_image_t *out_normal,
iffliction_image_t *out_selected);
int iffliction_new_icon_decode (const char *path,
iffliction_image_t *out_normal,
iffliction_image_t *out_selected);
int iffliction_glow_icon_decode (const char *path,
iffliction_image_t *out_normal,
iffliction_image_t *out_selected);
int iffliction_iff_decode (const char *path,
iffliction_image_t *out);
void iffliction_free_image (iffliction_image_t *img);Icon decoders return 1 (only normal image) or 2 (normal + selected),
or -1 on error. out_selected may be NULL to skip it. Image buffers
are RGBA8 of width * height * 4 bytes and are owned by the caller —
release with iffliction_free_image() or plain free(img.pixels).
int iffliction_magicwb_icon_save_as_png(const char *path, const char *out_prefix);
int iffliction_new_icon_save_as_png (const char *path, const char *out_prefix);
int iffliction_glow_icon_save_as_png (const char *path, const char *out_prefix);
int iffliction_iff_save_as_png (const char *path, const char *out_path);
int iffliction_save_rgba_as_png(const char *out_path, const uint8_t *rgba,
int w, int h);Icon formats produce <prefix>_1.png for the normal image, and
<prefix>_2.png for the selected one if present. Pass out_prefix = NULL
to derive a prefix from the source path (strips a trailing .info).
IFF images produce a single PNG; pass out_path = NULL to replace the
source extension with .png. Returns the number of PNG files written
or -1 on error.
Built only if compiled with -DIFFLICTION_WITH_SDL.
SDL_Surface *iffliction_magicwb_icon_convert_to_sdl_surface(const char *path);
SDL_Surface *iffliction_new_icon_convert_to_sdl_surface (const char *path);
SDL_Surface *iffliction_glow_icon_convert_to_sdl_surface (const char *path);
SDL_Surface *iffliction_iff_convert_to_sdl_surface (const char *path);
SDL_Surface *iffliction_rgba_to_sdl_surface(const uint8_t *rgba, int w, int h);Returns the normal image (only) as a fresh SDL_Surface in
SDL_PIXELFORMAT_RGBA32. The caller releases it with SDL_FreeSurface().
For both the normal and selected images of an icon, use the *_decode
function with iffliction_rgba_to_sdl_surface().
const char *iffliction_last_error(void);Returns a human-readable message describing the most recent failure, or
NULL if no error has occurred since the last successful call.
Process-wide, single-threaded.
makeProduces:
| Artifact | Built with SDL? | Notes |
|---|---|---|
libiffliction.a |
no | Static, libpng only |
libiffliction-sdl.a |
yes | Static, libpng + SDL2 |
libiffliction.so |
no | Shared, libpng only |
libiffliction-sdl.so |
yes | Shared, libpng + SDL2 |
example |
yes | Demo program |
Dependencies: libpng (always) and SDL2 (only for the SDL build).
cc your.c libiffliction.a -lpng # no SDL
cc your.c libiffliction-sdl.a -lpng -lSDL2 # with SDLWhen using the shared libraries, also pass -DIFFLICTION_WITH_SDL at
compile time if you intend to call any of the SDL helpers, so the SDL
prototypes get pulled in from the header.
#include "iffliction.h"
#include <stdio.h>
int main(void) {
const char *path = "MyIcon.info";
if (iffliction_is_glow_icon(path) == 1) {
iffliction_info_t info;
iffliction_get_glow_icon_information(path, &info);
printf("GlowIcon %dx%d, %d colors\n",
info.width, info.height, info.num_colors);
iffliction_glow_icon_save_as_png(path, NULL); /* writes MyIcon_1.png + _2.png */
#ifdef IFFLICTION_WITH_SDL
SDL_Surface *s = iffliction_glow_icon_convert_to_sdl_surface(path);
if (s) { /* ... use s ... */ SDL_FreeSurface(s); }
#endif
}
return 0;
}See example.c for a full demo program that handles all four formats.
- All multi-byte fields in
.infofiles and IFF chunks are 68k big-endian; the library reads them through dedicated helpers. - The MagicWB profile is not explicitly flagged in the icon format — it is detected heuristically as a classic icon whose normal image has image depth 3.
- The classic MagicWB palette assumes pen 0 is the Workbench background and is emitted as fully transparent.
- GlowIcon
IMAGchunks reuse the palette of the previous chunk when thehas_paletteflag is clear; the library carries the shared palette across IMAG decodes. - IFF ILBM decoding supports 1..8 bitplane indexed, 24-bit deep ILBM, HAM6 / HAM8, EHB, ByteRun1, and an optional mask plane (mapped onto alpha). PBM (DPaint chunky) is not supported.
- The library performs no implicit threading.
iffliction_last_error()is process-wide; do not call across threads without external locking.
Damir Sijakovic (c) 2026.