Image being Rotated

5 views
Skip to first unread message

da4thrza

unread,
Sep 4, 2009, 4:51:01 AM9/4/09
to simple-iphone-image-processing
Hi Chris,

I tried using your library in a new test project. I reused your sample
code of converting to greyscale and blurring. I apply these to an
image returned by the UIImagePickerController. When i apply the
resulting image back to a UIImageView though, the image ends up being
rotated automatically. Do you know why this is and how to prevent it?

Side note... if i directly assign the image returned from the
UIImagePickerController to the UIImageView, the image does not get
automatically rotated

Thanks!
Reza

Chris Greening

unread,
Sep 4, 2009, 7:02:05 AM9/4/09
to simple-iphone-i...@googlegroups.com
If you are taking a photograph with the camera it stamps it with the
rotation you had the phone at (landscape or portrait).

The sample code should take account of that and undue the rotation.

Maybe you could post some screen shots of what you are seeing.

Cheers
Chris.

da4thrza

unread,
Sep 4, 2009, 2:56:28 PM9/4/09
to simple-iphone-image-processing
Hi Chris,

I am taking the phone in portrait mode and when i convert the image to
greyscale and assign it to the UIImageView it rotates it to landscape.
The code im using is really straightforward:
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)
editingInfo{
ImageWrapper *greyScale=Image::createImage(image, image.size.width,
image.size.height);
imageView.image = greyScale.image->toUIImage();
[picker dismissModalViewControllerAnimated:YES];
}

I have uploaded a zip file containing screenshots to the Files section
of this Google Group. The screenshots included are:
centerpreview - The image preview after taking the photo with my
iPhone camera
centergrey - A screenshot of the image after its been assigned to the
UIImageView using the code above. This is with the View mode of the
UIImageView set to Center in the interface builder
scalepreview - The image preview after taking the photo with my iPhone
camera
scalegrey - A screenshot of the image after its been assigned to the
UIImageView using the code above. This is with the View mode of the
UIImageView set to Scale To Fit in the interface builder

I really appreciate your help!

Thanks,
Reza

Chris Greening

unread,
Sep 12, 2009, 12:48:46 PM9/12/09
to simple-iphone-i...@googlegroups.com
Hi Reza,

Sorry for taking so long to get in touch. It's been a bit hectic.

I'll take a look tomorrow at the files.

One thing I found when taking photos with the camera is that it seemed to mess up the orientation of the picture if I didn't have the following lines of code in controller that launches the UIImagePicker control:

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


Without this code I seemed to get the wrong values for the orientation in the image.

Cheers
Chris.
Reply all
Reply to author
Forward
0 new messages