diff --git a/img2cpi.c b/img2cpi.c index defe99f..790df88 100644 --- a/img2cpi.c +++ b/img2cpi.c @@ -139,52 +139,6 @@ int main(int argc, char **argv) { fprintf(stderr, "Fatal error occurred, exiting.\n"); return EXIT_FAILURE; } - - printf("fast_mode = %s\n", args.fast_mode ? "true" : "false"); - printf("size = %dx%d\n", args.width, args.height); - printf("version = %s\n", - args.cpi_version == CPI_VERSION_AUTO ? "AUTO" : ( - args.cpi_version == CPI_VERSION_RAW ? "RAW" : ( - args.cpi_version == CPI_VERSION_0 ? "0" : ( - args.cpi_version == CPI_VERSION_1 ? "1" : ( - args.cpi_version == CPI_VERSION_2 ? "2" : ( - "UNKNOWN" - ) - ) - ) - ) - )); - printf("placement = %s\n", - args.placement == PLACEMENT_CENTER ? "CENTER" : ( - args.placement == PLACEMENT_COVER ? "COVER" : ( - args.placement == PLACEMENT_TILE ? "TILE" : ( - args.placement == PLACEMENT_FULL ? "FULL" : ( - args.placement == PLACEMENT_EXTEND ? "EXTEND" : ( - args.placement == PLACEMENT_FILL ? "FILL" : ( - "UNKNOWN" - ) - ) - ) - ) - ) - )); - printf("palette = %s => %s\n", - args.palette_type == PALETTE_DEFAULT ? "DEFAULT" : ( - args.palette_type == PALETTE_DEFAULT_GRAY ? "DEFAULTGRAY" : ( - args.palette_type == PALETTE_AUTO ? "AUTO" : ( - args.palette_type == PALETTE_PATH ? "PATH" : ( - args.palette_type == PALETTE_LIST ? "LIST" : ( - "UNKNOWN" - ) - ) - ) - ) - ), - args.palette - ); - printf("input: %s\n", args.input_path); - printf("output: %s\n", args.output_path); - struct image *src_image = image_load(args.input_path); if (!src_image) { fprintf(stderr, "Error: failed to open the file\n"); @@ -220,8 +174,11 @@ int main(int argc, char **argv) { int new_w, new_h; get_size_keep_aspect(src_image->w, src_image->h, canvas->w, canvas->h, &new_w, &new_h); - printf("new size: %dx%d\n", new_w, new_h); scaled_image = image_resize(src_image, new_w, new_h); + if (!scaled_image) { + fprintf(stderr, "Error: failed to open the file\n"); + return EXIT_FAILURE; + } } // TODO: position image properly @@ -238,6 +195,10 @@ int main(int argc, char **argv) { struct cc_char *characters = calloc(args.width * args.height, sizeof(struct cc_char)); struct image_pal *quantized_image = image_quantize(canvas, palette, 16); + if (!quantized_image) { + fprintf(stderr, "Error: failed to open the file\n"); + return EXIT_FAILURE; + } FILE *tmp = fopen("/tmp/img.raw", "wb"); for (int i = 0; i < quantized_image->w * quantized_image->h; i++) {