Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 06-19-2009, 11:02 PM   #22 (permalink)
lokidil
Registered Member
 
Join Date: Apr 2009
Posts: 102
Default

Quote:
Originally Posted by simsimma View Post
Hi,

So in my application I want the user to be able to take as many photos as they like and store them for future lookup.

I use the sample code online for instantiating the camera.

Once the image is grabbed I use UIImageView to show the image to the user.

The problem is that after taking five pictures or so the application crashes!

Has anyone else had any issues with the camera and what did people have to do to fix it?!
Hey i m with solution now check out this code this will allow us to take infinite photos
Code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
	
	CGImageRef			imageRef = [image CGImage];
	CGImageAlphaInfo	alphaInfo = CGImageGetAlphaInfo(imageRef);
	unsigned char* rawData;
	CGRect thumbRect = CGRectMake(0,0,480,480);

	if (alphaInfo == kCGImageAlphaNone)
		alphaInfo = kCGImageAlphaNoneSkipLast;
	
	CGContextRef bitmap = CGBitmapContextCreate(
												NULL,
												thumbRect.size.width,		// width
												thumbRect.size.height,		// height
												CGImageGetBitsPerComponent(imageRef),	// really needs to always be 8
												//4 * thumbRect.size.width,	// rowbytes
												CGImageGetBytesPerRow(imageRef),
												CGImageGetColorSpace(imageRef),
												alphaInfo
												);
	
	CGContextRotateCTM (bitmap, radians(-90));
	CGContextTranslateCTM (bitmap, -thumbRect.size.width, 0);
	CGContextDrawImage(bitmap, thumbRect, imageRef);
	CGImageRef	ref = CGBitmapContextCreateImage(bitmap);
	image = [UIImage imageWithCGImage:ref];
	CGContextRelease(bitmap);	// ok if NULL
	thumbRect = CGRectMake(0,0,320,430);
	bitmap = CGBitmapContextCreate(
								   NULL,
								   thumbRect.size.width,		// width
								   thumbRect.size.height,		// height
								   CGImageGetBitsPerComponent(imageRef),	// really needs to always be 8
								   //4 * thumbRect.size.width,	// rowbytes
								   CGImageGetBytesPerRow(imageRef),
								   CGImageGetColorSpace(imageRef),
								   alphaInfo
								   );

	CGContextDrawImage(bitmap, thumbRect, ref);
	CGImageRelease (ref);///////////new

	ref = CGBitmapContextCreateImage(bitmap);
	
	image = [UIImage imageWithCGImage:ref];
	
	
	CGContextRelease(bitmap);	// ok if NULL
	CGImageRelease(ref);
	
	NSUInteger width = CGImageGetWidth(imageRef);
	NSUInteger height = CGImageGetHeight(imageRef);
	CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
	if(rawData)free(rawData);////////////////new
	rawData = malloc(height * width * 4);
	NSUInteger bytesPerPixel = 4;
	NSUInteger bytesPerRow = bytesPerPixel * width;
	NSUInteger bitsPerComponent = 8;
	CGContextRef contextC = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
	CGColorSpaceRelease(colorSpace);
	
	CGContextDrawImage(contextC, CGRectMake(0, 0, width, height), imageRef);
	CGContextRelease(contextC);

	imgView.image =[[[UIImage alloc] initWithData:UIImageJPEGRepresentation(image, 1.0)] autorelease];//Where imgView is the UIImageView

	[picker dismissModalViewControllerAnimated: YES];
	[picker release];
}
lokidil is offline   Reply With Quote
 
Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Online Users: 242
13 members and 229 guests
aniuco, GEEKSQUAD, hobbyist, iSdkDev, JasonR, kiancheong, LunarMoon, Noise, prathumca, RedM, refreshe, smilespray, spirestudios
Most users ever online was 779, 05-11-2009 at 09:55 AM.
» Stats
Members: 24,277
Threads: 39,070
Posts: 171,325
Top Poster: smasher (2,575)
Welcome to our newest member, GEEKSQUAD
Powered by vBadvanced CMPS v3.1.0

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