diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2021-09-16 19:58:34 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2021-09-16 20:14:06 +0200 |
commit | ddcc878424ebb8879ace2bd8238b7bd92d7143cf (patch) | |
tree | 62dbd5ac03a8ca2276d5999013418f2dd4b19162 | |
parent | a6982bcc3bf7dce09be61eb09fba946ef5c92b30 (diff) | |
download | fiv-ddcc878424ebb8879ace2bd8238b7bd92d7143cf.tar.gz fiv-ddcc878424ebb8879ace2bd8238b7bd92d7143cf.tar.xz fiv-ddcc878424ebb8879ace2bd8238b7bd92d7143cf.zip |
Make the background black, center the image
It might be a good idea to make the colour adjustable, at least being
able to switch to white, for certain partly-transparent pictures.
-rw-r--r-- | fastiv-view.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/fastiv-view.c b/fastiv-view.c index a692285..d06dc57 100644 --- a/fastiv-view.c +++ b/fastiv-view.c @@ -88,8 +88,25 @@ fastiv_view_draw(GtkWidget *widget, cairo_t *cr) if (!self->surface) return TRUE; + // TODO(p): Make this adjustable later. + cairo_set_source_rgb(cr, 0, 0, 0); + cairo_paint(cr); + + GtkAllocation allocation; + gtk_widget_get_allocation(widget, &allocation); + + int w = cairo_image_surface_get_width(self->surface); + int h = cairo_image_surface_get_height(self->surface); + + double x = 0; + double y = 0; + if (w < allocation.width) + x = (allocation.width - w) / 2; + if (h < allocation.height) + y = (allocation.height - h) / 2; + // TODO(p): Times the zoom. - cairo_set_source_surface(cr, self->surface, 0, 0); + cairo_set_source_surface(cr, self->surface, x, y); cairo_paint(cr); return TRUE; } |