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 > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 03-18-2010, 05:30 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 5
Default image mirrored and turned after takeing from cam

Hi guys,

I have a kind of funny problem..

What my program does:
first I can take a pic with the camera --> then it gets gropped --> after that it sould be displayed correctly on a UIImageView

The problem is that the image displayed on the imageview is mirrored and turned.. I dont know why but I hope someone does ^^

If I delete the part where it gets cropped, the image gets displayed correctly on the imageview. It seems that my cropping method is turning the image around.
Here is my code:

Code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
	[self.view addSubview:mainView];
	
	UIImage *camImage = [info objectForKey:UIImagePickerControllerOriginalImage];	
	
	UIImage *croppedImage = [self imageByCropping:camImage toRect:CGRectMake(1, 1,150, 160)];
	
	[mainView.imageView setImage:croppedImage];
	
	
	NSLog([NSString stringWithFormat:@"%f°", croppedImage.size.height]);
	//NSLog("Cropped Image size y %.02f", croppedImage.size.height);
	
	[[picker parentViewController] dismissModalViewControllerAnimated:YES];
	
	//[croppedImage release];
	//[camImage release];
	
}



- (UIImage*)imageByCropping:(UIImage *)imageToCrop toRect:(CGRect)rect	{
	
	
	
	
	UIGraphicsBeginImageContext(rect.size);
	
	CGContextRef currentContext = UIGraphicsGetCurrentContext();

	CGRect clippedRect = CGRectMake(0, 0, rect.size.width, rect.size.height);
	CGContextClipToRect( currentContext, clippedRect);

	CGRect drawRect = CGRectMake(rect.origin.x,
								 rect.origin.y,
								 imageToCrop.size.width,
								 imageToCrop.size.height);
	
	CGContextDrawImage(currentContext, drawRect, imageToCrop.CGImage);

	UIImage *cropped = UIGraphicsGetImageFromCurrentImageContext();

	UIGraphicsEndImageContext();

	return cropped;
	[cropped release];
	//CGContextRelease(currentContext);
	 
	 
}


I took two screenshots so that you can get into my problem..

Thats the cam view, exactly this pic will be shot by the camera:



With the cropping method, the imageview looks like that:



Without cropping:




By the way, do you see the little black gap between the cameraview an the black toolbar?
How can i get that away?

You may excuse any mistakes in my english language..


Thanx,

Robin R.

Last edited by robin1508; 03-18-2010 at 05:33 PM.
robin1508 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 252
24 members and 228 guests
ADY, bookesp, chillyh, ckgni, dacapo, Dani77, Davey555, Desert Diva, Dominus, glenn_sayers, HemiMG, JasonR, LEARN2MAKE, M.A.S., marshusensei, mer10, nobre84, prchn4christ, Raggou, Rudy, ryantcb, themathminister, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,230
Posts: 380,765
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:35 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0