Sign in to follow this  
Eldritch

Problems with CGImageGetWidth/-Height methods for iPhone dev

Recommended Posts

Eldritch    154
I am getting some really strange compiler errors in my application for the iPhone. I am using the following code (inspired by the GLSprite sample in the SDK):

-(bool)load :(NSString*)fileName
{
	CGImageRef image = [UIImage imageNamed :fileName].CGImage;
	
	width = CGImageGetWidth(image);
	height = CGImageGetHeight(image);
	
	if (!image)
	{
		NSLog(@"ImageLoader: Failed to load image.");
		return FALSE;
	}
	
	data = (GLubyte*)malloc(width * height * 4);
	
	CGContextRef context = CGBitmapContextCreate(data, width, height, 8, width * 4, CGImageGetColorSpace(image), kCGImageAlphaPremultipliedLast);
	CGContextDrawImage(context, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), image);
	CGContextRelease(context);
	
	return TRUE;
}


I get the following compiler errors:

Line Location Tool:0: collect2: ld returned 1 exit status
Line Location Tool:0: symbol(s) not found
Line Location Tool:0: -[ImageLoader load:] in ImageLoader.o
Line Location Tool:0: "_CGImageGetWidth", referenced from:
Line Location Tool:0: -[ImageLoader load:] in ImageLoader.o
Line Location Tool:0: "_CGBitmapContextCreate", referenced from:
Line Location Tool:0: "_CGContextDrawImage", referenced from:
Line Location Tool:0: "_CGContextRelease", referenced from:
Line Location Tool:0: -[ImageLoader load:] in ImageLoader.o
Line Location Tool:0: "_CGImageGetColorSpace", referenced from:
Line Location Tool:0: -[ImageLoader load:] in ImageLoader.o
Line Location Tool:0: "_CGImageGetHeight", referenced from:
Line Location Tool:0: -[ImageLoader load:] in ImageLoader.o
Line Location Tool:0: -[ImageLoader load:] in ImageLoader.o


I have the following imports: #import <QuartzCore/QuartzCore.h> #import <OpenGLES/EAGLDrawable.h> And the following frameworks: QuartzCore.framework OpenGLES.framework UIKit.framework Foundation.framework What might be causing this problem? The CGImageRef class seems to be working just fine... but not the "global" CGx" methods I am using (which is in accordance to the documentation).

Share this post


Link to post
Share on other sites
Maddi    132
Based on the documentation my guess would be that you need to link against the "ApplicationServices" Framework too. Can't try it so I'm not sure.

Share this post


Link to post
Share on other sites
Maddi    132
Seems they put that functionality into a different Framework then. Under normal Mac OS X the documentation states "ApplicationServices" as the Framework.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this