2
我有一個自定義攝像頭控制滑塊來應用變焦。我可以放大縮小圖片與下面的代碼:如何將自定義縮放應用於UIImagePicker相機?
self.pickerReference.cameraViewTransform = CGAffineTransformScale(CGAffineTransformIdentity, zoom, zoom);
但是,當我在didFinishPickingMediaWithInfo
得到的圖像,我得到原始圖像爲UIImagePickerControllerOriginalImage
,而不是放大一個。而對於UIImagePickerControllerEditedImage
沒有圖像。
我也曾嘗試:
currentImage = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
UIImageView *v = [[UIImageView alloc]initWithImage:currentImage];
UIGraphicsBeginImageContext(v.bounds.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextScaleCTM(context, zoom, zoom);
[v drawRect:pickerReference.view.bounds];
CGContextRestoreGState(context);
zoomedCurImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// Write image to PNG file
[UIImageJPEGRepresentation(zoomedCurImg, 0.4) writeToFile:imgPath atomically:YES];
這並不適用於變焦原始圖像,但變焦在左上角&始終應用不是它在哪裏得到應用。
請提出解決方案。提前致謝。
你有沒有最終的解決方案?請分享.. – 2014-06-16 14:37:00