Преглед на файлове

RA Image 1.20
Fix crash issue
Fix thread issue

Ray Zhang преди 3 години
родител
ревизия
dc0daad62c
променени са 3 файла, в които са добавени 49 реда и са изтрити 15 реда
  1. 1 1
      RA Image/RA Image/AppDelegate.m
  2. 18 9
      RA Image/RA Image/BasicModeViewController.m
  3. 30 5
      common/Camera/RACameraViewController.m

+ 1 - 1
RA Image/RA Image/AppDelegate.m

@@ -116,7 +116,7 @@ void UncaughtExceptionHandler(NSException *exception) {
     if(true)
     {
         
-        if(self.uploadManager.arr_queue!=nil)
+        if(true||self.uploadManager.arr_queue!=nil)
         {
             
             [self.uploadManager stopAllTasks];

+ 18 - 9
RA Image/RA Image/BasicModeViewController.m

@@ -243,11 +243,12 @@
     
     __weak typeof(self) weakself = self;
     RACameraViewController *cameraVC = [RACameraViewController showCameraFromViewController:self withTakeMode:RACameraTakeModeTakeASerial videoGravity:AVLayerVideoGravityResizeAspect completion:^(UIImage *img) {
-        
+        AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+        bool bcompress =appDelegate.compressFile;
         if (img) {
             dispatch_async(dispatch_get_global_queue(0, 0), ^{
                 UIImage *newImg = [img fixOrientation];
-                NSString *path = [weakself saveImage:newImg];
+                NSString *path = [weakself saveImage:newImg bcompress:bcompress];
                 dispatch_async(dispatch_get_main_queue(), ^{
                     if (path) {// 保存成功
                         [weakself receiveImage:newImg];
@@ -390,10 +391,10 @@
     [self receiveImage:img];
 }
 
-- (NSString *)saveImage:(UIImage *)img {
-    AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+- (NSString *)saveImage:(UIImage *)img bcompress:(bool) bcompress{
+  //  AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
     NSString *append = @"";
-    if (appDelegate.compressFile) {
+    if (bcompress) {
         img = [ImageUtils img_compress:img kbsize:1024];
         append = @"_scaled";
     }
@@ -514,8 +515,9 @@
 - (NSDictionary *)saveSignature:(UIImage *)img {
     
     if (img) {
-        
-        NSString *path = [self saveImage:img];
+        AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+        bool bcompress =appDelegate.compressFile;
+        NSString *path = [self saveImage:img bcompress:bcompress];
         
         if (path) {// 保存成功
             NSString *md5 = [RAUtils md5WithFile:path];
@@ -610,8 +612,12 @@
         __weak typeof(preVC) weakPreVC = preVC;
         preVC.photoHandler = ^(UIImage *img){
             if (img) {
+                
+                AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+                bool bcompress =appDelegate.compressFile;
+                
                 dispatch_async(dispatch_get_global_queue(0, 0), ^{
-                    NSString *path = [weakself saveImage:img];
+                    NSString *path = [weakself saveImage:img bcompress:bcompress];
                     dispatch_async(dispatch_get_main_queue(), ^{
                         if (path) {// 保存成功
                             [weakself receiveImage:img];
@@ -639,8 +645,11 @@
         
         image = [info objectForKey:UIImagePickerControllerOriginalImage];
         [picker dismissViewControllerAnimated:YES completion:nil];
+        AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+        bool bcompress =appDelegate.compressFile;
+        
         dispatch_async(dispatch_get_global_queue(0, 0), ^{
-            NSString *path = [self saveImage:image];
+            NSString *path = [self saveImage:image bcompress:bcompress];
             dispatch_async(dispatch_get_main_queue(), ^{
                 if (path) {// 保存成功
                     [self receiveImage:image];

+ 30 - 5
common/Camera/RACameraViewController.m

@@ -169,7 +169,17 @@
                     }];
                     
                     if (self.cameraInitial && !self.captureSession.isRunning) {
-                        [self.captureSession startRunning];
+//                        [self.captureSession startRunning];
+                        
+                        
+                        dispatch_async(dispatch_get_global_queue(0, 0), ^{
+                            [self.captureSession startRunning];
+                //            sleep(0.3);
+                //            dispatch_async(dispatch_get_main_queue(), ^{
+                //                [self.mask removeFromSuperview];
+                //            });
+
+                        });
                     }
                     
                 } else {
@@ -215,7 +225,17 @@
     [super viewWillAppear:animated];
     
     if (self.cameraInitial && !self.captureSession.isRunning) {
-        [self.captureSession startRunning];
+        
+        
+        dispatch_async(dispatch_get_global_queue(0, 0), ^{
+            [self.captureSession startRunning];
+//            sleep(0.3);
+//            dispatch_async(dispatch_get_main_queue(), ^{
+//                [self.mask removeFromSuperview];
+//            });
+
+        });
+       
     }
 }
 
@@ -302,7 +322,7 @@
 - (void)initCapture {
     
     
-    self.photoSetting= [AVCapturePhotoSettings photoSettings];
+    
     self.cameraInitial = NO;
     
     if (![self camerAuthorization]) {
@@ -350,7 +370,7 @@
         NSError *configErr;
         [self.captureDevice lockForConfiguration:&configErr];
 //        AVCapturePhotoSettings.flashMode
-        self.photoSetting.flashMode =AVCaptureFlashModeAuto;
+
 //        [self.captureDevice setFlashMode:AVCaptureFlashModeAuto];
         [self.captureDevice unlockForConfiguration];
     }
@@ -491,7 +511,12 @@
 //    NSLog(@"capture orientation %ld",connection.videoOrientation);
     ;
 //    __weak typeof(self) weakSelf = self;
-    
+    self.photoSetting= [AVCapturePhotoSettings photoSettings];
+    if(self.captureDevice.hasFlash)
+    {
+        
+        self.photoSetting.flashMode =AVCaptureFlashModeAuto;
+    }
     [self.photoOutput capturePhotoWithSettings:self.photoSetting delegate:self];
 //
 //    [self.captureOutput captureStillImageAsynchronouslyFromConnection:connection completionHandler:^(CMSampleBufferRef  _Nullable imageDataSampleBuffer, NSError * _Nullable error) {