From fcd8237ac5f5dc7bc485b8b5726824129215beea Mon Sep 17 00:00:00 2001 From: Tim Horton Date: Fri, 6 Nov 2009 11:57:43 +0000 Subject: [PATCH] osx: CGBitmapContextCreate can't make 24bpp, alphaless offscreen pixmaps While loading a JPEG from disk (with clutter_texture_new_from_file), I got the following: : CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 24 bits/pixel; 3-component colorspace; kCGImageAlphaNone; 3072 bytes/row. : CGContextDrawImage: invalid context Looking around, I found that CGBitmapContextCreate can't make 24bpp offscreen pixmaps without an alpha channel... This fixes the bug, and seems to not break other things... http://bugzilla.openedhand.com/show_bug.cgi?id=1159 Signed-off-by: Emmanuele Bassi --- clutter/cogl/cogl/cogl-bitmap-pixbuf.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/clutter/cogl/cogl/cogl-bitmap-pixbuf.c b/clutter/cogl/cogl/cogl-bitmap-pixbuf.c index 1b75cd0ba..79ed62a7f 100644 --- a/clutter/cogl/cogl/cogl-bitmap-pixbuf.c +++ b/clutter/cogl/cogl/cogl-bitmap-pixbuf.c @@ -160,17 +160,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp, /* allocate buffer big enough to hold pixel data */ size_t rowstride; - CGBitmapInfo bitmap_info = CGImageGetBitmapInfo (image); - if ((bitmap_info & kCGBitmapAlphaInfoMask) == kCGImageAlphaNone) - { - bitmap_info = kCGImageAlphaNone; - rowstride = 3 * width; - } - else - { - bitmap_info = kCGImageAlphaPremultipliedFirst; - rowstride = 4 * width; - } + rowstride = 4 * width; guint8 *out_data = g_malloc0 (height * rowstride); /* render to buffer */ @@ -178,7 +168,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp, CGContextRef bitmap_context = CGBitmapContextCreate (out_data, width, height, 8, rowstride, color_space, - bitmap_info); + kCGImageAlphaPremultipliedFirst); CGColorSpaceRelease (color_space); const CGRect rect = {{0, 0}, {width, height}}; @@ -189,9 +179,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp, /* store bitmap info */ bmp->data = out_data; - bmp->format = bitmap_info == kCGImageAlphaPremultipliedFirst - ? COGL_PIXEL_FORMAT_ARGB_8888 - : COGL_PIXEL_FORMAT_RGB_888; + bmp->format = COGL_PIXEL_FORMAT_ARGB_8888; bmp->width = width; bmp->height = height; bmp->rowstride = rowstride;