Compare commits

...

2 Commits

Author SHA1 Message Date
fa7b1631f0
Round coordinates for image centring 2021-10-16 10:07:32 +02:00
70a4729f36
Use bilinear filtering
It could be both faster and more accurate,
though currently it's a good compromise.
2021-10-16 10:04:50 +02:00

View File

@ -129,14 +129,17 @@ fastiv_view_draw(GtkWidget *widget, cairo_t *cr)
double x = 0;
double y = 0;
if (w < allocation.width)
x = (allocation.width - w) / 2;
x = round((allocation.width - w) / 2.);
if (h < allocation.height)
y = (allocation.height - h) / 2;
y = round((allocation.height - h) / 2.);
cairo_scale(cr, self->scale, self->scale);
cairo_set_source_surface(cr, self->surface,
x / self->scale, y / self->scale);
// TODO(p): Prescale it ourselves to an off-screen bitmap, gamma-correctly.
cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_GOOD);
cairo_paint(cr);
return TRUE;
}