Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
fixed size to int conversion and cordova 3.6 deprecation warnings for…
Browse files Browse the repository at this point in the history
… iOS
  • Loading branch information
basvanbeek authored and Ryan Willoughby committed Mar 30, 2015
1 parent 22a23b1 commit c2dcd87
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 111 deletions.
30 changes: 12 additions & 18 deletions src/ios/CDVBarcodeScanner.mm
Original file line number Diff line number Diff line change
Expand Up @@ -174,23 +174,17 @@ - (void)returnSuccess:(NSString*)scannedText format:(NSString*)format cancelled:
resultWithStatus: CDVCommandStatus_OK
messageAsDictionary: resultDict
];

NSString* js = [result toSuccessCallbackString:callback];
if (!flipped) {
[self writeJavascript:js];
}
[self.commandDelegate sendPluginResult:result callbackId:callback];
}

//--------------------------------------------------------------------------
- (void)returnError:(NSString*)message callback:(NSString*)callback {
CDVPluginResult* result = [CDVPluginResult
resultWithStatus: CDVCommandStatus_OK
resultWithStatus: CDVCommandStatus_ERROR
messageAsString: message
];

NSString* js = [result toErrorCallbackString:callback];

[self writeJavascript:js];
[self.commandDelegate sendPluginResult:result callbackId:callback];
}

@end
Expand Down Expand Up @@ -266,16 +260,16 @@ - (void)scanBarcode {
//--------------------------------------------------------------------------
- (void)openDialog {
[self.parentViewController
presentModalViewController:self.viewController
animated:YES
presentViewController:self.viewController
animated:YES completion:nil
];
}

//--------------------------------------------------------------------------
- (void)barcodeScanDone {
self.capturing = NO;
[self.captureSession stopRunning];
[self.parentViewController dismissModalViewControllerAnimated: YES];
[self.parentViewController dismissViewControllerAnimated:YES completion:nil];

// viewcontroller holding onto a reference to us, release them so they
// will release us
Expand Down Expand Up @@ -540,7 +534,7 @@ - (NSString*)formatStringFrom:(zxing::BarcodeFormat)format {
using namespace zxing;

Ref<LuminanceSource> luminanceSource (
new GreyscaleLuminanceSource(greyData, greyWidth, greyWidth, 0, 0, greyWidth, greyWidth)
new GreyscaleLuminanceSource(greyData, (int)greyWidth, (int)greyWidth, 0, 0, (int)greyWidth, (int)greyWidth)
);

return luminanceSource;
Expand Down Expand Up @@ -582,7 +576,7 @@ - (UIImage*)getImageFromSample:(CMSampleBufferRef)sampleBuffer {
size_t height = CVPixelBufferGetHeight(imageBuffer);

uint8_t* baseAddress = (uint8_t*) CVPixelBufferGetBaseAddress(imageBuffer);
int length = height * bytesPerRow;
int length = (int)(height * bytesPerRow);
uint8_t* newBaseAddress = (uint8_t*) malloc(length);
memcpy(newBaseAddress, baseAddress, length);
baseAddress = newBaseAddress;
Expand Down Expand Up @@ -666,8 +660,8 @@ - (void)loadView {
previewLayer.frame = self.view.bounds;
previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;

if ([previewLayer isOrientationSupported]) {
[previewLayer setOrientation:AVCaptureVideoOrientationPortrait];
if ([previewLayer.connection isVideoOrientationSupported]) {
[previewLayer.connection setVideoOrientation:AVCaptureVideoOrientationPortrait];
}

[self.view.layer insertSublayer:previewLayer below:[[self.view.layer sublayers] objectAtIndex:0]];
Expand All @@ -679,7 +673,7 @@ - (void)loadView {
- (void)viewWillAppear:(BOOL)animated {

// set video orientation to what the camera sees
self.processor.previewLayer.orientation = [[UIApplication sharedApplication] statusBarOrientation];
self.processor.previewLayer.connection.videoOrientation = [[UIApplication sharedApplication] statusBarOrientation];

// this fixes the bug when the statusbar is landscape, and the preview layer
// starts up in portrait (not filling the whole view)
Expand Down Expand Up @@ -889,7 +883,7 @@ - (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)orien
{
[CATransaction begin];

self.processor.previewLayer.orientation = orientation;
self.processor.previewLayer.connection.videoOrientation = orientation;
[self.processor.previewLayer layoutSublayers];
self.processor.previewLayer.frame = self.view.bounds;

Expand Down
Loading

0 comments on commit c2dcd87

Please sign in to comment.