Problem
Error message shows in Ti Console when using a backgroundImage
on a label.
Error Message:
<Error>: CGContextConcatCTM: invalid context 0x0
<Error>: CGContextSetInterpolationQuality: invalid context 0x0
<Error>: CGContextDrawImage: invalid context 0x0
<Error>: CGBitmapContextCreateImage: invalid context 0x0
Test Code
var window = Titanium.UI.createWindow({
title:'LabelImageTest',
backgroundColor:'#fff'
});
var label = Titanium.UI.createLabel({
backgroundImage: 'default_app_logo.png',
text: 'This is a label with a backgroundImage'
});
window.add(label);
window.open();
Ticket Reference
http://developer.appcelerator.com/helpdesk/view/76638
I fixed it by commenting out the code that wasn't doing anything anyway: -(void)setBackgroundImage_:(id)url { if (url != nil) { // !!!: this doesn't work because self.frame.size isn't set // UIImage* bgImage = [UIImageResize resizedImage:self.frame.size // interpolationQuality:kCGInterpolationDefault // image:[self loadImage:url] // hires:NO]; // Resizing doesn't preserve stretchability. Should we maybe fix this? UIImage* bgImage = [self loadImage:url]; if (backgroundView == nil) { backgroundView = [[UIImageView alloc] initWithImage:bgImage]; backgroundView.userInteractionEnabled = NO; [self insertSubview:backgroundView atIndex:0]; repad = YES; [self padLabel]; } else { backgroundView.image = bgImage; [backgroundView setNeedsDisplay]; repad = YES; [self padLabel]; } } else { if (backgroundView) { [backgroundView removeFromSuperview]; RELEASE_TO_NIL(backgroundView); } } self.backgroundImage = url; }
Associated Helpdesk Ticket
http://appc.me/c/APP-593963Got this problem as well! Will find another workaround.
Tested with 2.0.1GA2 on a HTC Sensation 4G, unable to reproduce this issue. Ticket closed.
This issue was filed for iOS platform so it needs to be verified against the same platform.
Resolving this since we can't reproduce it with 3.2GA
Verified as fixed using below environment so closing the issue: Environment: Appc Studio: 3.2.2.201402280732 Sdk: 3.2.2.v20140221161255 acs: 1.0.14 npm: 1.3.2 alloy:1.3.1 titanium:3.2.1 titanium-code-processor:1.1.0 Xcode: 5.1-beta5 Osx: Maverick(10.9.2) Device: iPhone 5S (iOS 7.1)