Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 12-02-2008, 09:14 PM   #2 (permalink)
pinpoint
Registered Member
 
Join Date: Oct 2008
Location: Columbus, OH
Posts: 57
Send a message via AIM to pinpoint
Smile This works for me

Here's a solution that has worked for me so far.
I got most if not all of the code from another post here. I did have to hard code the alpha setting or I got a run-time error.

I won't pretend to know how it works at this point, but it does the job.
I'm having memory leaks at the moment, but I suspect they're related to other parts of my code not this.

Code:
-(UIImage *)resizeImage:(UIImage *)image width:(int)width height:(int)height {
	
	CGImageRef imageRef = [image CGImage];
	CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(imageRef);
	
	//if (alphaInfo == kCGImageAlphaNone)
		alphaInfo = kCGImageAlphaNoneSkipLast;
	
	CGContextRef bitmap = CGBitmapContextCreate(NULL, width, height, CGImageGetBitsPerComponent(imageRef), 4 * width, CGImageGetColorSpace(imageRef), alphaInfo);
	CGContextDrawImage(bitmap, CGRectMake(0, 0, width, height), imageRef);
	CGImageRef ref = CGBitmapContextCreateImage(bitmap);
	UIImage *result = [UIImage imageWithCGImage:ref];
	
	CGContextRelease(bitmap);
	CGImageRelease(ref);
	
	return result;	
}
__________________
Dave Peat
Pinpoint Solutions, Inc.
pinpoint is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,810
Threads: 89,206
Posts: 380,628
Top Poster: BrianSlick (7,129)
Welcome to our newest member, madisonbrock
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:36 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.