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 06-20-2009, 12:02 AM   #22 (permalink)
lokidil
Registered Member
 
Join Date: Apr 2009
Location: Madurai
Posts: 111
Send a message via MSN to lokidil Send a message via Yahoo to lokidil Send a message via Skype™ to lokidil
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
 

» Advertisements
» Online Users: 626
22 members and 604 guests
adamwaite, AragornSG, bignoggins, Dani77, dljeffery, Domele, e2applets, foany, Hyde, john love, Keys, mer10, Monstertaco, oceanlablight, pill5b3rry, raKinesic, Speed, spiderguy84, thh022, Touchmint, tymex, waq963
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,746
Threads: 89,201
Posts: 380,567
Top Poster: BrianSlick (7,129)
Welcome to our newest member, raKinesic
Powered by vBadvanced CMPS v3.1.0

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