diff options
author | mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-12-15 12:35:17 +0000 |
---|---|---|
committer | mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-12-15 12:35:17 +0000 |
commit | 5bff6ec39f30f99a0029a498f5e4745badb960ba (patch) | |
tree | 8c26de509c7dd1b9d223d6a7d20eb65bb8150407 /src | |
parent | a7aedfec9e28db36c97e49f11f2bc2e0eb624c30 (diff) |
if CG fails to decode an image, check to see if it was a problem in the colorspace
git-svn-id: http://skia.googlecode.com/svn/trunk@6830 2bbb7eff-a529-9590-31e7-b0007b416f81
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); |