strange imagepicker problem

Discussion in 'iOS Programming' started by chhoda, Nov 12, 2009.

  1. macrumors 6502

    Joined:
    Oct 25, 2008
    #1
    Hi All,

    while using imagepicker sourcetype camera, I observed that when I use the image returned by

    Code:
    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
    straightaway, the image is rotated 90degre down. This happens only in camera mode. For the time being I was able to have my image rotate 90 degrees up. But is this problem a known issue ?

    furthermore, when i just put it in the backgound, the image seems alright. when I try to resize it, it gets rotated.

    bit strange though, anybody else has noticed this ?

    CH
     
  2. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    Up and down are not normal descriptions for 90º rotations in a 2D space. Usually it's left / right or counter-clockwise / clockwise. Care to explain?
     
  3. thread starter macrumors 6502

    Joined:
    Oct 25, 2008
    #3
    mostly when we get UIImage from camera or Camera Roll, we get UIImage with orientation UIImageOrientationRight

    I had to check that and rotate the movie to appear proper.

    but when the image was picked from album, it was proper

    CH
     
  4. thread starter macrumors 6502

    Joined:
    Oct 25, 2008
    #4
    surprising

    i observed, imagepicker when called from my app is very slow. visibly slower than native camera app. And in a few cases while using photo [clicking USE button] it crashed. I tried to see if any memory issues are there by using Leak detector of xcode. Memory leak was mostly caused from UIImagePickerViewController

    where as I am simply using a UIImagePickerController vriable with propery (nonatomic, retian)

    and releasing and allocating it again when i need to call it.

    I dont know what could be causing this problem.

    what does ObjectAlloc does ? how to interprete that graph ? There I saw total alloc somewhere 1.5 mb, is it normal ? any application while running will hold some memory, isn't it ? my executable is 2.5mb

    Any pointers in here would be appreceated.

    this is only happening in device, not in simulator
    CH
     
  5. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    We probably won't be able to provide any without seeing a lot more code.
     
  6. thread starter macrumors 6502

    Joined:
    Oct 25, 2008
    #6
    I am using simplistic approach.
    Code:
    @interface MyViewController : UIViewController < UIImagePickerControllerDelegate> {
    UIImage *pickedImage;
    UIImagePickerController *pickerController;
    }
    
    @property (nonatomic, retain) UIImage *pickedImage;
    @property (nonatomic, retain) UIImagePickerController *pickerController;
    
    @end
    
    @implementation MyViewController
    
    -(IBAction) buttonClick {
    	[pickerController release];
    	pickerController = [[UIImagePickerController alloc] init];
    	pickerController.delegate = self;
    	
    	if(currentImageIndex == 1)
    		pickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    	if(currentImageIndex == 0)
    		pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
    	
    	[appDelegate.window addSubview:pickerController.view];
    
    }
    
    
    // delegates
    
    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
    	[picker dismissModalViewControllerAnimated:YES];
    	[picker.view removeFromSuperview];
    	
    	currentImageIndex = -1;
    	[pickedImage release]; // release old ones before using new ones
    	// Sometimes, iphone camera automates the rotation to landscape, to catch this to proper mode, we need to check and reorient it
    	if(UIImageOrientationRight == [image imageOrientation]) {
    		pickedImage = [[image rotate:UIImageOrientationRight] retain]; // rotate(image, UIImageOrientationRight);
    	}
    	else
    		pickedImage = [image retain];
    }
    
    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
    	[picker dismissModalViewControllerAnimated:YES];
    	[picker.view removeFromSuperview];
    }
    
    @end
     
  7. thread starter macrumors 6502

    Joined:
    Oct 25, 2008
    #7
    Again, I observed, in instruments app, when imagepicker is alloced, memory allocation goes up by 40k when i release it memory comes downn only ~5k !

    CH
     
  8. thread starter macrumors 6502

    Joined:
    Oct 25, 2008
    #8
    As it turned out, the imagepicker returns an image with width 1200 and height 1600 , and my image manipulation work was failing. Why is it so, the camera returns so big an image ?

    CH
     

Share This Page