From 498c35c28831cf89cc60a773a5c2513c97bc08a3 Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Sun, 25 Aug 2019 13:58:49 +0200 Subject: Added crop scaling method Added a method that scales and crop the image so that the image will fill the whole window. Also made viewport update respect the current scaling mode. --- src/viewport.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/viewport.h') diff --git a/src/viewport.h b/src/viewport.h index 0b9519f..5e5bc24 100644 --- a/src/viewport.h +++ b/src/viewport.h @@ -6,6 +6,14 @@ struct imv_viewport; +enum scaling_mode { + SCALING_NONE, + SCALING_DOWN, + SCALING_FULL, + SCALING_CROP, + SCALING_MODE_COUNT +}; + /* Used to signify how a a user requested a zoom */ enum imv_zoom_source { IMV_ZOOM_MOUSE, @@ -55,10 +63,18 @@ void imv_viewport_center(struct imv_viewport *view, void imv_viewport_scale_to_actual(struct imv_viewport *view, const struct imv_image *image); -/* Scale the view so that the image fills the window */ +/* Scale the view so that the image fits in the window */ void imv_viewport_scale_to_window(struct imv_viewport *view, const struct imv_image *image); +/* Scale the view so that the image fills the window */ +void imv_viewport_crop_to_window(struct imv_viewport *view, + const struct imv_image *image); + +/* Rescale the view with the chosen scaling method */ +void imv_viewport_rescale(struct imv_viewport *view, const struct imv_image *image, + enum scaling_mode); + /* Tell the viewport that it needs to be redrawn */ void imv_viewport_set_redraw(struct imv_viewport *view); @@ -66,7 +82,7 @@ void imv_viewport_set_redraw(struct imv_viewport *view); void imv_viewport_update(struct imv_viewport *view, int window_width, int window_height, int buffer_width, int buffer_height, - struct imv_image *image); + struct imv_image *image, enum scaling_mode); /* Poll whether we need to redraw */ int imv_viewport_needs_redraw(struct imv_viewport *view); -- cgit v1.2.3