diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c index 9cb3a6af7..79f507095 100644 --- a/cogl/cogl-texture.c +++ b/cogl/cogl-texture.c @@ -1198,14 +1198,17 @@ cogl_texture_get_data (CoglTexture *texture, int y; int tex_width; int tex_height; + CoglPixelFormat texture_format; CoglTextureGetData tg_data; _COGL_GET_CONTEXT (ctx, 0); + texture_format = cogl_texture_get_format (texture); + /* Default to internal format if none specified */ if (format == COGL_PIXEL_FORMAT_ANY) - format = cogl_texture_get_format (texture); + format = texture_format; tex_width = cogl_texture_get_width (texture); tex_height = cogl_texture_get_height (texture); @@ -1226,6 +1229,12 @@ cogl_texture_get_data (CoglTexture *texture, &closest_gl_type); closest_bpp = _cogl_pixel_format_get_bytes_per_pixel (closest_format); + /* We can assume that whatever data GL gives us will have the + premult status of the original texture */ + if ((closest_format & COGL_A_BIT)) + closest_format = ((closest_format & ~COGL_PREMULT_BIT) | + (texture_format & COGL_PREMULT_BIT)); + /* Is the requested format supported? */ if (closest_format == format) /* Target user data directly */