有一种方法可以通过程序获得用iPhone拍摄的照片的尺寸?我想直接把尺寸,而不经过throught模型版本,因此该方案不能有效:Iphone以编程方式获取照片分辨率
检查模型版本 - >写与每部iPhone模型的维度字典 - >采取正确的索引
有一种方法可以通过程序获得用iPhone拍摄的照片的尺寸?我想直接把尺寸,而不经过throught模型版本,因此该方案不能有效:Iphone以编程方式获取照片分辨率
检查模型版本 - >写与每部iPhone模型的维度字典 - >采取正确的索引
尝试为获得最大的分辨率的相机这段代码:
- (CMVideoDimensions) getCameraMaxStillImageResolution:(AVCaptureDevicePosition) cameraPosition {
CMVideoDimensions max_resolution;
max_resolution.width = 0;
max_resolution.height = 0;
AVCaptureDevice *captureDevice = nil;
NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
for (AVCaptureDevice *device in devices) {
if ([device position] == cameraPosition) {
captureDevice = device;
break;
}
}
if (captureDevice == nil) {
return max_resolution;
}
NSArray* availFormats=captureDevice.formats;
for (AVCaptureDeviceFormat* format in availFormats) {
CMVideoDimensions resolution = format.highResolutionStillImageDimensions;
int w = resolution.width;
int h = resolution.height;
if ((w * h) > (max_resolution.width * max_resolution.height)) {
max_resolution.width = w;
max_resolution.height = h;
}
}
return max_resolution;
}
- (void) printCamerasInfo {
CMVideoDimensions res;
res = [self getCameraMaxStillImageResolution:AVCaptureDevicePositionBack];
NSLog(@" Back Camera max Image resolution: %d x %d", res.width, res.height);
res = [self getCameraMaxStillImageResolution:AVCaptureDevicePositionFront];
NSLog(@" Front Camera max Image resolution: %d x %d", res.width, res.height);
}
将上述给予解决? –
分辨率由像素高度的宽度(除以1M并四舍五入为小数点后第一位,以获得Mpixels) – Teejay