diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ports/SkImageDecoder_CG.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ports/SkImageDecoder_CG.cpp b/src/ports/SkImageDecoder_CG.cpp index d687003b08..afe4cf44ac 100644 --- a/src/ports/SkImageDecoder_CG.cpp +++ b/src/ports/SkImageDecoder_CG.cpp @@ -82,8 +82,13 @@ bool SkImageDecoder_CG::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { // use the same colorspace, so we don't change the pixels at all CGColorSpaceRef cs = CGImageGetColorSpace(image); - CGContextRef cg = CGBitmapContextCreate(bm->getPixels(), width, height, - 8, bm->rowBytes(), cs, BITMAP_INFO); + CGContextRef cg = CGBitmapContextCreate(bm->getPixels(), width, height, 8, bm->rowBytes(), cs, BITMAP_INFO); + if (NULL == cg) { + // perhaps the image's colorspace does not work for a context, so try just rgb + cs = CGColorSpaceCreateDeviceRGB(); + cg = CGBitmapContextCreate(bm->getPixels(), width, height, 8, bm->rowBytes(), cs, BITMAP_INFO); + CFRelease(cs); + } CGContextDrawImage(cg, CGRectMake(0, 0, width, height), image); CGContextRelease(cg); |