buffer: add buffer_convert_cairo_surface_for_icon()

Which handles:
 - conversion from other pixel formats to ARGB32
 - setting the logical size to the desired display size
 - downscaling very large images using CAIRO_FILTER_GOOD
This commit is contained in:
John Lindgren 2024-10-06 22:28:33 -04:00
parent 22e50aa4e2
commit 2e9b5886ce
2 changed files with 65 additions and 0 deletions

View file

@ -61,6 +61,18 @@ struct lab_data_buffer *buffer_adopt_cairo_surface(cairo_surface_t *surface);
struct lab_data_buffer *buffer_create_cairo(uint32_t logical_width,
uint32_t logical_height, float scale);
/*
* Create a buffer from an image surface, for display as an icon.
*
* The surface is either adopted by the buffer (which takes ownership),
* or copied and then destroyed.
*
* This function allows non-ARGB32 source images and converts to
* CAIRO_FORMAT_ARGB32 if needed.
*/
struct lab_data_buffer *buffer_convert_cairo_surface_for_icon(
cairo_surface_t *surface, uint32_t icon_size, float scale);
/*
* Create a buffer which holds (and takes ownership of) raw pixel data
* in pre-multiplied ARGB32 format.