/* Library to make sure that each image is read only once. This means stdin and named pipes would work without surprises, at the cost of more memory. */ #ifndef PNG_CACHE_H_ #define PNG_CACHE_H_ #include /* Linked list of cached files. Linked list means updates require quadratic time, but we expect the list to only contain a few files because they came from argv. */ typedef struct image_cache { /* Input file name, not owned by this struct. */ const char *filename; /* Image handle. */ png_image image; /* Pixel data, owned by this struct. */ png_bytep pixels; /* Pointer to next image. */ struct image_cache *next; } ImageCache; /* Add image to cache. Returns pointer to image data on success, or NULL on error. */ ImageCache *LoadImage(const char *filename, ImageCache **cache); /* Release memory. */ void FreeImageCache(ImageCache **cache); #endif /* PNG_CACHE_H_ */