Merge pull request #359 from teslamotors/cleanup-1

This commit is contained in:
Seph Soliman 2021-02-03 18:01:41 -08:00 committed by GitHub
commit 8a249bb6d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -831,61 +831,6 @@ RCT_ENUM_CONVERTER(CKCameraZoomMode, (@{
}
+ (UIImage *)imageWithImage:(UIImage *)image scaledToRect:(CGSize)newSize {
//UIGraphicsBeginImageContext(newSize);
// In next line, pass 0.0 to use the current device's pixel scaling factor (and thus account for Retina resolution).
// Pass 1.0 to force exact pixel size.
UIGraphicsBeginImageContextWithOptions(newSize, NO, 0.0);
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
+ (CGRect)cropRectForSize:(CGRect)frame overlayObject:(CKOverlayObject*)overlayObject {
CGRect ans = CGRectZero;
CGSize centerSize = CGSizeZero;
if (overlayObject.width < overlayObject.height) {
centerSize.width = frame.size.width;
centerSize.height = frame.size.height * overlayObject.ratio;
ans.origin.x = 0;
ans.origin.y = (frame.size.height - centerSize.height)*0.5;
}
else if (overlayObject.width > overlayObject.height){
centerSize.width = frame.size.width / overlayObject.ratio;
centerSize.height = frame.size.height;
ans.origin.x = (frame.size.width - centerSize.width)*0.5;
ans.origin.y = 0;
}
else { // ratio is 1:1
centerSize.width = frame.size.width;
centerSize.height = frame.size.width;
ans.origin.x = 0;
ans.origin.y = (frame.size.height - centerSize.height)/2;
}
ans.size = centerSize;
ans.origin.x += frame.origin.x;
ans.origin.y += frame.origin.y;
return ans;
}
+ (CGSize)cropImageToPreviewSize:(UIImage*)image size:(CGSize)previewSize {
float imageToPreviewWidthScale = image.size.width/previewSize.width;
float imageToPreviewHeightScale = image.size.width/previewSize.width;
return CGSizeMake(previewSize.width*imageToPreviewWidthScale, previewSize.height*imageToPreviewHeightScale);
}
#pragma mark - Frame for Scanner Settings
- (void)didMoveToWindow {