2
votes

My application draws some images using cairo like this:

cairo_set_source_surface(cr, _page_down_icon, icon_x, y);
cairo_paint(cr);

where the page down icon is a png I loaded via cairo_image_surface_create_from_png.

This works fine on standard screens but produces a low quality image on retina displays. So I'm thinking of having a second image with double resolution (as it is usual for NSImage). However, if I just draw this image the result is twice as large as the standard image. So my question is: how would I draw the highres image with cairo on a retina display so that it looks crisp?

1

1 Answers

2
votes

cairo_scale is your friend. With this method you can adjust the scaling of the axes of your surface. In order to get the result you want youd scale by 0.5 for your second image (not that you'll have to adjust the targetposition for the image as well!).