Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在使用前置摄像头拍摄的照片上,水印显示得更大_Ios_Objective C - Fatal编程技术网

Ios 在使用前置摄像头拍摄的照片上,水印显示得更大

Ios 在使用前置摄像头拍摄的照片上,水印显示得更大,ios,objective-c,Ios,Objective C,我的应用程序允许用户拍照,每张照片中都有一个小水印。问题是:当使用前置摄像头拍摄照片时,水印会显得更大。我希望水印有相同的大小,无论哪个相机已被使用 有什么想法吗 我的代码: UIImage *backgroundImage = image; UIImage *watermarkImage = [UIImage imageNamed:@"Watermark.png"]; UIGraphicsBeginImageContext(backgroundImage.size); [backgroun

我的应用程序允许用户拍照,每张照片中都有一个小水印。问题是:当使用前置摄像头拍摄照片时,水印会显得更大。我希望水印有相同的大小,无论哪个相机已被使用

有什么想法吗

我的代码:

UIImage *backgroundImage = image;
UIImage *watermarkImage = [UIImage imageNamed:@"Watermark.png"];

UIGraphicsBeginImageContext(backgroundImage.size);

[backgroundImage drawInRect:CGRectMake(0, 0, backgroundImage.size.width, backgroundImage.size.height)];

[watermarkImage drawInRect:CGRectMake(backgroundImage.size.width - watermarkImage.size.width, backgroundImage.size.height - watermarkImage.size.height, watermarkImage.size.width, watermarkImage.size.height)];

UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.imageView.image = result;

水印大小相同。由于两个摄像头的分辨率不同,因此图像不是。您需要根据图像大小按比例调整水印大小。我相信你可以使用
scaleImage:toSize:
来解决这个问题。

想出了一个奇怪的解决方案。我打开了编辑模式:
[picker SetAllowsEdit:YES]
现在,无论您使用何种摄像头,水印的大小都是相同的。

这不是很难,因为所有不同的iPhone上的分辨率都不同吗?不,不太难。确定所需的相对大小(例如,图像高度的1/10),然后计算水印的实际高度,并相应地重新缩放。1)“不起作用”是一个无用的报告。你有没有弄错尺寸的水印?方法
scaleImage:toSize:
不存在吗?FBI会来没收你的相机吗?2) 对不起,我不是可可开发者。答案是概念性的,因为虽然我可以用另一种语言实现它,但我无法用ObjC演示如何实现它。如果有办法检测屏幕的分辨率,那么您的逻辑就会起作用。我肯定有,但我似乎找不到@阿马丹让我们来。