i am working on a camera app. i want to restrict the image content in particular dimensions, but the image through camera is coming in full screen. How can i minimize it?
- (void) viewDidAppear:(BOOL)animated {
OvlayView *overlay = [[OvlayView alloc] initWithFrame:CGRectMake(472, 158, 240, 128)];
// Create a new image picker instance:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
// Set the image picker source:
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
// Hide the controls:
picker.showsCameraControls = YES;
picker.navigationBarHidden = YES;
// Make camera view full screen:
picker.wantsFullScreenLayout = NO;
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, CAMERA_TRANSFORM_X, CAMERA_TRANSFORM_Y);
// Insert the overlay:
picker.cameraOverlayView = overlay;
/*UIGraphicsBeginImageContext(CGSizeMake(480,320));
CGContextRef context = UIGraphicsGetCurrentContext();
[image drawInRect: CGRectMake(0, 0, 480, 320)];
UIImage *smallImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();*/
// Show the picker:
[self presentModalViewController:picker animated:YES];
[super viewDidAppear:YES];
}
Related
I am creating the simple customized camera application.
so. i tried to customize the buttons for flash setting button and capture.
It worked for iPhone4 and iPhone4s... but unfortunately.. it shows the white screen on iPhone3gs.
What's the problem?
#define CAMERA_TRANSFORM_X 1
#define CAMERA_TRANSFORM_Y 1
#define SCREEN_WIDTH 320
#define SCREEN_HEIGTH 480
- (void) showCamera
{
overlay = [[CustomOverlayView alloc]
initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGTH)];
overlay.delegate = self;
self.picker = [[UIImagePickerController alloc] init];
self.picker.delegate = self;
self.picker.navigationBarHidden = YES;
self.picker.toolbarHidden = YES;
self.picker.wantsFullScreenLayout = YES;
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.showsCameraControls = NO;
self.picker.cameraViewTransform = CGAffineTransformScale(self.picker.cameraViewTransform, CAMERA_TRANSFORM_X, CAMERA_TRANSFORM_Y);
self.picker.cameraOverlayView = overlay;
[self.view addsubview self.picker.view];
}
Call your showCamera method in your root view controller viewDidLoad method, or in its init method if you don't use IB.
You should present your camera controller by using
[self.navigationController presentModalViewContoller:self.picker animated:NO];
How can we bring rectangle on camera for barcode scanning like red laser with scanningound? is there any built in property?I tried following:
reader.readerView.tracksSymbols = YES;
reader.readerView.trackingColor = [UIColor redColor];
[reader setShowsZBarControls:NO];
reader.readerView.tracksSymbols = TRUE;
scanner.accessibilityFrame = CGRectMake(100, 100, 200, 300);
Add the rectange as an overlay on your camera view.Here is the code:
- (IBAction) scanButtonTapped
{
// ADD: present a barcode reader that scans from the camera feed
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
reader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = reader.scanner;
reader.showsZBarControls = NO;
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
// present and release the controller
[self presentModalViewController: reader
animated: YES];
reader.cameraOverlayView = [self CommomOverlay];
[reader release];
}
-(UIView*)CommomOverlay{
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,480)];
UIImageView *FrameImg = [[UIImageView alloc] initWithFrame:CGRectMake(70,160,203,180)];
[FrameImg setImage:[UIImage imageNamed:#"overlaygraphic.png"]];
[view addSubview:FrameImg];
return view;
}
hope this will help you..:)
Did you try
reader.cameraOverlayView = overLayView;
?? i.e cameraOverlayView property of UIImagePickerController.
There you can set what ever you want. Hope this is what you want.
I am new to iphone development. I am creating one camera app, in that i need to capture only some co-ordinates of the image for example (I have overlay image on camera. that image is dollar. In the middle of the dollar bill there is a rectangle. inside this rectangle i can set my own image and capture).That is working fine. But when i save i need to save only image inside the rectangle co-ordinates. How to capture that. Please can anyone help me. Here is my code sample.
OverlayView *overlay = [[OverlayView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGTH)];
// Create a new image picker instance:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
// Set the image picker source:
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
// Hide the controls:
picker.showsCameraControls = YES;
picker.navigationBarHidden = YES;
// Make camera view full screen:
picker.wantsFullScreenLayout = YES;
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, CAMERA_TRANSFORM_X, CAMERA_TRANSFORM_Y);
// Insert the overlay:
picker.cameraOverlayView = overlay;
// Show the picker:
[self presentModalViewController:picker animated:YES];
[picker release];
Is it possible to open webview during use of camera in app.if it is possible plz let me know.
You could try:
- (BOOL)startCameraPickerFromViewController:(UIViewController*)controller usingDelegate:(id<UIImagePickerControllerDelegate>)delegateObject
{
//NSLog(#"008 ::Create Postcard :: start photo camera");
if ((![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) || (delegateObject == nil) || (controller == nil)) {
return NO;
}
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
UIView *overlay = [[UIView alloc]initWithFrame:CGRectMake(x, y, w, h)];
// overlay.transform = CGAffineTransformMakeRotation(M_PI / 2.0);
// overlay.backgroundColor = [UIColor redColor];
{create your webview here}
[overlay addSubview:webview];
[webview release];
[picker.cameraOverlayView = overlay;
[controller presentModalViewController:picker animated:YES];
return YES;
}
If you have enough recources on the phone it might could work i guess
In my application I m using UIImagePickerControllerCropRect to crop the image but I want to reduce the size of that cropping box of iphone which comes automatically so that my image crop to its perfect size which I want. I'm using the following code for that:
-(IBAction) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if((UIButton *) sender == choosePhotoBtn) {
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
picker.allowsImageEditing = YES;
} else {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:picker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
[picker dismissModalViewControllerAnimated:YES];
imageView.image = image;
CGSize size = [imageView.image size];
CGRect cropRect = CGRectMake(0.0, 0.0, size.width, size.height);
NSLog(#"Original image size = (%f, %f)", size.width, size.height);
NSValue *cropRectValue = [editingInfo objectForKey:#"UIImagePickerControllerCropRect"];
cropRect = [cropRectValue CGRectValue];
UIImageWriteToSavedPhotosAlbum(imageView.image, self, nil, nil);
}