photomosaics

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 94c9cf42466549865991c7b5560e3081241357a5
parent 59596010c6a3aec4d11fcf5d1c1495b831aa162d
Author: Wilson Gheen <wilson@wilsonrgheen.com>
Date:   Sun,  1 Jan 2023 09:19:10 -0600

WIP: Document for later, quick caching function

Diffstat:
Mphotomosaics.c | 18++++++++++++++++++
1 file changed, 18 insertions(+), 0 deletions(-)

diff --git a/photomosaics.c b/photomosaics.c @@ -14,6 +14,8 @@ typedef struct { unsigned int r, g, b; } Pixel; +static FILE *cache = NULL; + static bool parse_float(char *str, float *out) { char *endptr; const char *old_locale = setlocale(LC_ALL, NULL); @@ -47,6 +49,20 @@ static bool parse_ulong(char *str, unsigned long *out) { return strncmp(str, endptr, strlen(str)); } +static bool cache_put(int nargs, ...) { + if(!cache) cache = fopen("~/.cache/photomosaics/avgs"); + if(!cache) return false; + char *buf; + int ind = 0, chars_written; + va_list vl; + va_start(vl, nargs); + for(int i=0; i < nargs-1; i++, ind += chars_written) + chars_written = sprintf(buf[ind], "%s\t", va_arg(vl, char *)); + sprintf(buf[ind], "%s\n", va_arg(vl, char *)); + va_end(vl); + return true; +} + static Image *resize_image_to(Image *image, const size_t new_width, const size_t new_height, ExceptionInfo *exception) { Image *new_image = ResizeImage(image, new_width, new_height, LanczosFilter, exception); @@ -386,6 +402,8 @@ int main(int argc, char **argv) { if(exception->severity != UndefinedException) CatchException(exception); + + if(cache) fclose(cache); DestroyImage(input_img); DestroyImageInfo(image_info); if(output_img) {