Authored by Bogdan Poplauschi

Fixed #1668 CGContextDrawImage: invalid context 0x0

@@ -41,6 +41,9 @@ static const size_t kBitsPerComponent = 8; @@ -41,6 +41,9 @@ static const size_t kBitsPerComponent = 8;
41 bytesPerRow, 41 bytesPerRow,
42 colorspaceRef, 42 colorspaceRef,
43 kCGBitmapByteOrderDefault|kCGImageAlphaNoneSkipLast); 43 kCGBitmapByteOrderDefault|kCGImageAlphaNoneSkipLast);
  44 + if (context == NULL) {
  45 + return image;
  46 + }
44 47
45 // Draw the image into the context and retrieve the new bitmap image without alpha 48 // Draw the image into the context and retrieve the new bitmap image without alpha
46 CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef); 49 CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef);
@@ -130,7 +133,7 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over @@ -130,7 +133,7 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over
130 kCGBitmapByteOrderDefault|kCGImageAlphaNoneSkipLast); 133 kCGBitmapByteOrderDefault|kCGImageAlphaNoneSkipLast);
131 134
132 if (destContext == NULL) { 135 if (destContext == NULL) {
133 - free( destBitmapData ); 136 + free(destBitmapData);
134 return image; 137 return image;
135 } 138 }
136 CGContextSetInterpolationQuality(destContext, kCGInterpolationHigh); 139 CGContextSetInterpolationQuality(destContext, kCGInterpolationHigh);