Hello all,
I am developing an application where-in i pick the image from camera photo library and putting the image in a Sprite. The code is below:
// Launch photos library
-(void) PictureButtonChosen: (id) sender
{
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
[picker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary]; // UIImagePickerControllerSourceTypeSavedPhotosAlbum
[ [[Director sharedDirector] openGLView] addSubview:picker.view];
}
// After chosen the image from photos library, put it into my Sprite (frameBG)
- (void)releasePicker :(NSTimer*)pickerTimer {
UIImage *image = (UIImage*) [pickerTimer userInfo];
[pickedImage release]; // release old ones before using new ones
pickedImage = [image retain];
// frameBG is my Sprite. so i'm putting chosen image in my Sprite here..
// As the image is big, it is showing the image beyond the Sprite size. HOW TO FIT THE IMAGE TO FIT IN SPRITE?
Texture2D *imgToSet=[[Texture2D alloc]initWithImage:pickedImage];
[frameBG setTexture:imgToSet];
}
// Handle after choosing the picture from photo library
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
[picker dismissModalViewControllerAnimated:NO];
[picker.view removeFromSuperview];
[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(releasePicker:) userInfo:image repeats:NO];
}
The following are the problem that i am observing and unable to resolve it.
1. After choosing the image from photo library, it stretches the Sprite goes beyond the actual Sprite size. I mean, image doesn't fit into the Sprite size, and goes beyond it. How to make image fit into Sprite?
2. My application screens are in landscape mode. But when i launch camera photo library programmatically, it open in portrait mode. I want to know how to open photo library in portrait show?
Thank you. Appreciate your helps!
Clave/