2012-08-08 59 views
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]; 

這並不適用於變焦原始圖像,但變焦在左上角&始終應用不是它在哪裏得到應用。

請提出解決方案。提前致謝。

+0

你有沒有最終的解決方案?請分享.. – 2014-06-16 14:37:00

回答

0

我有一個類似的問題,不同的一段代碼,並關閉自動佈局爲我修復它。不確定這是否適用,但值得一試。

相關問題