Skip to content

Commit 0322571

Browse files
committed
better antialising for zoom out
Use trilinear for zoom out, nearest for zoom in. This can greatly improve antialiasing for some images. see libvips/vipsdisp#43
1 parent 5e512bb commit 0322571

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/tilecache.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,13 @@ tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
10181018
graphene_rect_t bounds;
10191019

10201020
#if GTK_CHECK_VERSION(4, 10, 0)
1021+
/* If we are zooming in beyond 1:1, we want nearest so we don't
1022+
* blur the image. For zooming out, we want trilinear to get
1023+
* mipmaps and antialiasing.
1024+
*/
1025+
GskScalingFilter filter = scale > 1.0 ?
1026+
GSK_SCALING_FILTER_NEAREST : GSK_SCALING_FILTER_TRILINEAR;
1027+
10211028
// add a margin along the right and bottom to prevent black seams
10221029
// at tile joins
10231030
bounds.origin.x = tile->bounds.left * scale - x + paint_rect->left;
@@ -1026,9 +1033,7 @@ tilecache_snapshot(Tilecache *tilecache, GtkSnapshot *snapshot,
10261033
bounds.size.height = tile->bounds.height * scale + 2;
10271034

10281035
gtk_snapshot_append_scaled_texture(snapshot,
1029-
tile_get_texture(tile),
1030-
GSK_SCALING_FILTER_NEAREST,
1031-
&bounds);
1036+
tile_get_texture(tile), filter, &bounds);
10321037
#else
10331038
bounds.origin.x = tile->bounds.left * scale - x + paint_rect->left;
10341039
bounds.origin.y = tile->bounds.top * scale - y + paint_rect->top;

0 commit comments

Comments
 (0)