Skip to content

Conversation

@City-busz
Copy link
Contributor

Instead of saving the thumbnail into a file and then read it back, read and scale it directly from the surface.

Instead of saving the thumbnail into a file and then read it back, read and
scale it directly from the surface.
var pixbuf = new Gdk.Pixbuf.from_file_at_size (save_path, (int) scaled_width, (int) scaled_height);
var texture = Gdk.Texture.for_pixbuf (pixbuf);
var pixbuf = Gdk.pixbuf_get_from_surface (surface, 0, 0, width, height);
var scaled_pixbuf = pixbuf.scale_simple ((int) scaled_width, (int) scaled_height, Gdk.InterpType.BILINEAR);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, GdkPixbuf's scaling provides a lower quality thumbnail. In the DocumentThumbnail widget we use either a Trilinear interpolation or a nearest interpolation. The latter is supported by GdkPixbuf but the former is not.

I also want to remove GdkPixbuf from the codebase in favor of Glycin since it plays better with GdkTextures and would allow us to remove this ugly scaling implementation I made.

Gsk.ScalingFilter filter = LINEAR;
if (scaled_width > thumbnail_texture.width || scaled_height > thumbnail_texture.height) {
filter = NEAREST;
} else {
filter = TRILINEAR;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants