I am trying to draw a png image into a view. I tried copying the code from other sources. Absolutely nothing gets drawn.
I inserted code to draw a background and doodles and that appears fine. Image draw. Nothing. It's reading the file because the image dimensions get filled in correctly.
I am missing some error checks?
The other possibility is that I am drawing entirely outside the view.
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect drawrect ;
CGDataProviderRef provider = CGDataProviderCreateWithFilename([imagePath UTF8String]) ;
if (provider)
{
CGImageRef image = CGImageCreateWithPNGDataProvider(provider, NULL, NO, kCGRenderingIntentDefault);
drawrect.origin = CGPointMake(0, 0) ;
drawrect.size = CGSizeMake(CGImageGetWidth (image), CGImageGetHeight(image)) ;
CGContextTranslateCTM(context, 0, CGImageGetHeight(image));
CGContextScaleCTM(context, 1.0, -1.0);
CGContextDrawImage(context, drawrect, image) ;
CGImageRelease (image) ;
CFRelease (provider) ;
}
]