Blurry GtkImage when snapshooting a widget at a bigger size

Hello,

I’m using a Gtk.WidgetPaintable to take screenshots of some widgets for documentation purposes. It works perfectly when I snapshot the paintable at the same size as the widget:

Widget at scale 1

However, when I snapshot it at a bigger size (applying a scale factor to the dimensions passed to Gtk.WidgetPaintable.snapshot()), the text is clear but the image (although it is an SVG) is upscaled:

Widget at scale 2 with blurry image

Is there a way to have the GtkImage rendered at the given size?

I’m using this in a headless Weston compositor, I tried to set its scale setting to the same value but it did not seem to change anything.

After further testing, the headless backend of Weston doesn’t honor the scale setting, running it nested with the Wayland backend, it works as expected:

Widget at scale 2

[EDIT: Weston 9.0.0 headless backend can be scaled.)

Still, it would be great if snapshooting the paintable at a bigger size renders a crisp image.

I’m currently trying to do very similar things in C (taking screenshots of GtkWidgets headless). Is your project public and can you point to some real code? I’m mostly interested how to do it headless.

Yes, my code is here, it’s in Rust: Romain / UI Shooter · GitLab

The container image is not yet updated to support scaling widgets.

Thanks a lot & merci beaucoup

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.