#include #include #include #include #include #include #include "sod.h" #define MAX_IMG_SZ 1024*1024 int main() { unsigned char *zInpbuf = NULL; zInpbuf = malloc(MAX_IMG_SZ); if (!zInpbuf) { perror("malloc"); return -1; } ssize_t imgSz = read(0, zInpbuf, MAX_IMG_SZ); if (imgSz <= 0) { perror("read"); free(zInpbuf); return -1; } sod_img imgIn = sod_img_load_from_mem(zInpbuf, imgSz, SOD_IMG_COLOR /* full color channels */); if (imgIn.data == 0) { /* Invalid path, unsupported format, memory failure, etc. */ //puts("Cannot load input image..exiting"); printf("Error loading input\n"); free(zInpbuf); return -1; } for (int i = 0; i < imgIn.w * imgIn.h * imgIn.c; i++) { imgIn.data[i] = 255.0f - imgIn.data[i]; } sod_img_save_as_png(imgIn, NULL); sod_free_image(imgIn); free(zInpbuf); return 0; }