- unsigned char *imago_pixels;
- if(!(imago_pixels = (unsigned char *)img_load_pixels(fname, &w, &h))) {
- fprintf(stderr, "Failed to load pixels from file: %s.\n", fname);
+ free(pixels);
+
+ img_pixmap ipm;
+ img_init(&ipm);
+
+ if(img_load(&ipm, fname) == -1) {
+ fprintf(stderr, "Failed to load image: %s.\n", fname);
+
+ img_destroy(&ipm);
+ return false;
+ }
+
+ printf("Successfully loaded image: %s\n", fname);
+
+ img_fmt format = img_is_float(&ipm) ? IMG_FMT_RGBAF : IMG_FMT_RGBA32;
+ if(img_convert(&ipm, format) == -1) {
+ fprintf(stderr, "Failed to convert image %s.\n", fname);
+
+ img_destroy(&ipm);