commit 7b37880b62538c326cb4d73b218b0f3eca27d21c
parent 7d46e3125b1c4276ae020e6e0b59e21e08fc54f4
Author: lumidify <nobody@lumidify.org>
Date: Thu, 13 Jan 2022 12:56:08 +0100
Make cropping rectangle specification more strict; add some todos
Diffstat:
5 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/LICENSE b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2021 lumidify <nobody@lumidify.org>
+Copyright (c) 2022 lumidify <nobody@lumidify.org>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
diff --git a/Makefile b/Makefile
@@ -20,7 +20,7 @@ DB_LDFLAGS = `pkg-config --libs xext`
#DB_CFLAGS = -DNODB
#DB_LDFLAGS =
-CROP_CFLAGS = ${CFLAGS} ${DB_CFLAGS} -D_POSIX_C_SOURCE=200809L `pkg-config --cflags x11` `imlib2-config --cflags`
+CROP_CFLAGS = ${CFLAGS} ${DB_CFLAGS} -Wall -Wextra -D_POSIX_C_SOURCE=200809L `pkg-config --cflags x11` `imlib2-config --cflags`
CROP_LDFLAGS = ${CFLAGS} ${DB_LDFLAGS} `pkg-config --libs x11` `imlib2-config --libs` -lm
all: ${BIN}
diff --git a/TODO b/TODO
@@ -3,3 +3,7 @@
expensive image resizing each time
* Maybe add zooming support
* Maybe optionally show rectangle coordinates on screen
+* Allow to copy/paste selection
+* Key for allowing/disallowing rectangle out of image bounds
+* Read selections from file - to modify again later
+* Better navigation - jump to beginning, etc.
diff --git a/croptool.c b/croptool.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 lumidify <nobody@lumidify.org>
+ * Copyright (c) 2022 lumidify <nobody@lumidify.org>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -152,7 +152,8 @@ static void change_picture(Imlib_Image new_image, int new_selection, int copy_bo
static void get_scaled_size(int orig_w, int orig_h, int *scaled_w, int *scaled_h);
static void set_selection(
struct Selection *sel, int rect_x0, int rect_y0, int rect_x1,
- int rect_y1, int orig_w, int orig_h, int scaled_w, int scaled_h);
+ int rect_y1, int orig_w, int orig_h, int scaled_w, int scaled_h
+);
static void queue_rectangle_redraw(int x0, int y0, int x1, int y1);
static void set_cursor(struct Rect rect);
static void drag_motion(XEvent event);
diff --git a/croptool_crop.c b/croptool_crop.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021 lumidify <nobody@lumidify.org>
+ * Copyright (c) 2022 lumidify <nobody@lumidify.org>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -24,7 +24,7 @@ main(int argc, char *argv[]) {
char *dst_filename;
char *format;
char alpha;
- int w, h, x, y;
+ int w, h, x, y, n;
int orig_w, orig_h;
Imlib_Image src, dst;
Imlib_Load_Error error;
@@ -39,8 +39,8 @@ main(int argc, char *argv[]) {
dst_filename = argv[3];
else
dst_filename = argv[2];
- /* FIXME: proper error checking for this (don't use sscanf) */
- if (sscanf(argv[1], "%dx%d+%d+%d", &w, &h, &x, &y) < 4) {
+ if (sscanf(argv[1], "%dx%d+%d+%d%n", &w, &h, &x, &y, &n) != 4 ||
+ (unsigned)n != strlen(argv[1])) {
fprintf(stderr, "Invalid cropping rectangle specified.\n");
exit(1);
}