我的應用讓用戶拍攝照片,每張照片中都有一個小水印。問題是:使用前置攝像頭拍攝照片時水印會變大。無論使用哪臺相機,我都希望水印尺寸相同。使用前置攝像頭拍攝的照片水印看起來更大
任何想法?
我的代碼:
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;
這不是很難,因爲所有不同的iPhone的分辨率都不一樣嗎? – Yomo
不,不是。決定你想要的相對大小(例如圖像高度的1/10),然後計算水印的實際高度應該是什麼,並相應地重新縮放。 – Amadan
不起作用,你能給我一些示例代碼嗎? – Yomo