Skip to content

Commit 1e0f9f8

Browse files
committed
show ratio in crop preview
1 parent fb61be6 commit 1e0f9f8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/iop/crop.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,15 @@ void gui_post_expose(dt_iop_module_t *self,
15641564
pango_layout_set_font_description(layout, desc);
15651565

15661566
char dimensions[64] = { '\0' };
1567-
snprintf(dimensions, sizeof(dimensions), "%d x %d", width - diff_w, height - diff_h);
1567+
const double ratio = (double)(width - diff_w)/(height - diff_h);
1568+
char ratio_str[15] = { '\0' };
1569+
if(ratio<1)
1570+
snprintf(ratio_str, sizeof(ratio_str), "(1 : %.2f)", (double)1/ratio);
1571+
else if(ratio>1)
1572+
snprintf(ratio_str, sizeof(ratio_str), "(%.2f : 1)", ratio);
1573+
else
1574+
snprintf(ratio_str, sizeof(ratio_str), "(1 : 1)");
1575+
snprintf(dimensions, sizeof(dimensions), "%d x %d %s", width - diff_w, height - diff_h, ratio_str);
15681576

15691577
pango_layout_set_text(layout, dimensions, -1);
15701578
pango_layout_get_pixel_extents(layout, NULL, &ext);

0 commit comments

Comments
 (0)