From 2395bba1e66a2623cb288e13effc206f86e5e62e Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 4 Jul 2009 18:31:49 +0100 Subject: [PATCH] [any2ppm] Choose a more appropriate format for the replay content Actually select a format that matches the request content when replaying the script to an image. --- test/any2ppm.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/any2ppm.c b/test/any2ppm.c index 31dd0eb4b..f35891fbe 100644 --- a/test/any2ppm.c +++ b/test/any2ppm.c @@ -240,7 +240,20 @@ _create_image (void *closure, //csi_object_t *dictionary) { cairo_surface_t **out = closure; - *out = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); + cairo_format_t format; + switch (content) { + case CAIRO_CONTENT_ALPHA: + format = CAIRO_FORMAT_A8; + break; + case CAIRO_CONTENT_COLOR: + format = CAIRO_FORMAT_RGB24; + break; + default: + case CAIRO_CONTENT_COLOR_ALPHA: + format = CAIRO_FORMAT_ARGB32; + break; + } + *out = cairo_image_surface_create (format, width, height); return cairo_surface_reference (*out); }