mirror of
https://github.com/brl/mutter.git
synced 2024-11-10 07:56:14 -05:00
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: <Error>: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 24 bits/pixel; 3-component colorspace; kCGImageAlphaNone; 3072 bytes/row. <Error>: 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 <ebassi@linux.intel.com>
This commit is contained in:
parent
339b447075
commit
544543e249
@ -160,17 +160,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
|
|||||||
|
|
||||||
/* allocate buffer big enough to hold pixel data */
|
/* allocate buffer big enough to hold pixel data */
|
||||||
size_t rowstride;
|
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);
|
guint8 *out_data = g_malloc0 (height * rowstride);
|
||||||
|
|
||||||
/* render to buffer */
|
/* render to buffer */
|
||||||
@ -178,7 +168,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
|
|||||||
CGContextRef bitmap_context = CGBitmapContextCreate (out_data,
|
CGContextRef bitmap_context = CGBitmapContextCreate (out_data,
|
||||||
width, height, 8,
|
width, height, 8,
|
||||||
rowstride, color_space,
|
rowstride, color_space,
|
||||||
bitmap_info);
|
kCGImageAlphaPremultipliedFirst);
|
||||||
CGColorSpaceRelease (color_space);
|
CGColorSpaceRelease (color_space);
|
||||||
|
|
||||||
const CGRect rect = {{0, 0}, {width, height}};
|
const CGRect rect = {{0, 0}, {width, height}};
|
||||||
@ -189,9 +179,7 @@ _cogl_bitmap_from_file (CoglBitmap *bmp,
|
|||||||
|
|
||||||
/* store bitmap info */
|
/* store bitmap info */
|
||||||
bmp->data = out_data;
|
bmp->data = out_data;
|
||||||
bmp->format = bitmap_info == kCGImageAlphaPremultipliedFirst
|
bmp->format = COGL_PIXEL_FORMAT_ARGB_8888;
|
||||||
? COGL_PIXEL_FORMAT_ARGB_8888
|
|
||||||
: COGL_PIXEL_FORMAT_RGB_888;
|
|
||||||
bmp->width = width;
|
bmp->width = width;
|
||||||
bmp->height = height;
|
bmp->height = height;
|
||||||
bmp->rowstride = rowstride;
|
bmp->rowstride = rowstride;
|
||||||
|
Loading…
Reference in New Issue
Block a user