Logo image shows upside down if CGContextDrawImage is used


#1

Hi,

I’ve tried to use CGContextDrawImage() instead of UIImage, and when I tried it, it shows image up side down.

Here is the code:

    
    CGRect imageBounds = CGRectMake(self.bounds.origin.x+kUIImageOffset, self.bounds.origin.y+kUIImageOffset, self.bounds.size.width-(kUIImageOffset*2), self.bounds.size.height-(kUIImageOffset*2));

    NSString *source = [[NSBundle mainBundle] pathForResource:@"logo" ofType:@"png"];
    CFURLRef imageFilePath = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)source, kCFURLPOSIXPathStyle, false);
    
    CGDataProviderRef imageFile = CGDataProviderCreateWithURL(imageFilePath);
    if ( imageFile )
    {
        CGImageRef logoImage = CGImageCreateWithPNGDataProvider( imageFile, NULL, true, kCGRenderingIntentDefault);
        if ( logoImage ) {
            CGContextDrawImage( currentContext, imageBounds, logoImage );
            CGImageRelease( logoImage );
        }
        CGDataProviderRelease( imageFile );
    }

Do you know why?