summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Schodet2019-11-15 23:54:48 +0100
committerNicolas Schodet2019-11-15 23:54:48 +0100
commit9df5e32b72dee3e4973f00b3048835d58e1550fb (patch)
treef4ef67958305c5381ec75b939756730168ee9c3c
parent7ce1b8358a8c41d2f00e93cfd614dd445c2d1a5c (diff)
Do not scale image if smaller than the screen resolution
-rw-r--r--gui_app_window.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/gui_app_window.c b/gui_app_window.c
index 2e4b7f0..56a42f6 100644
--- a/gui_app_window.c
+++ b/gui_app_window.c
@@ -73,15 +73,15 @@ video_size_update(GuiAppWindowPrivate *priv)
if (source_width > 0 && dest_width > 0) {
double scale_x = (double) source_width / dest_width;
double scale_y = (double) source_height / dest_height;
- double offset_x = 0.0;
- double offset_y = 0.0;
- if (scale_x > scale_y) {
- scale_y = scale_x;
- offset_y = -(dest_height - source_height / scale_y) / 2.0;
- } else {
- scale_x = scale_y;
- offset_x = -(dest_width - source_width / scale_x) / 2.0;
- }
+ double scale;
+ if (scale_x > scale_y)
+ scale = scale_x;
+ else
+ scale = scale_y;
+ if (scale < 1.0)
+ scale = 1.0;
+ double offset_x = -(dest_width - source_width / scale) / 2.0;
+ double offset_y = -(dest_height - source_height / scale) / 2.0;
if (priv->rotate) {
cairo_matrix_init_translate(&priv->transform,
source_width / 2, source_height / 2);
@@ -91,7 +91,7 @@ video_size_update(GuiAppWindowPrivate *priv)
} else {
cairo_matrix_init_identity(&priv->transform);
}
- cairo_matrix_scale(&priv->transform, scale_x, scale_y);
+ cairo_matrix_scale(&priv->transform, scale, scale);
cairo_matrix_translate(&priv->transform, offset_x, offset_y);
}
}