2012-07-12 64 views
-1

問題:我可以在縮放後的固定座標(50,50,200,200)處裁剪圖像嗎?我搜索了很多小時,看到了匹配的問題。但沒有得到答案。我可以裁剪縮放的圖像。固定座標

謝謝。

我種植的邏輯是在這裏..

CGSize itemSize = CGSizeMake(200, 200); 
UIGraphicsBeginImageContextWithOptions(itemSize, NO, 0); 
CGRect imageRect = CGRectMake(50, 50, 200, 200); 
[imageView1.image drawInRect:imageRect]; 
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

,但我不能在裁剪滾動查看完整的圖像。我想要縮放後顯示在scrollView中的裁剪圖像。

+1

如果你繼續問同一個問題的警告,你不會得到ANS,只需編輯原來的問題。 – Dhruv 2012-07-12 09:34:30

+0

@iApple我簡單地問了一遍。因爲我問的前一個問題非常詳細。 – QueueOverFlow 2012-07-12 09:37:42

回答

0

我自己的回答問題:谷歌搜索後,我找到了一個鏈接。 here經過一些修改後,它對我來說工作得很好。

可以省卻別人的時間和精力。感謝

UIGraphicsBeginImageContext(CGSizeMake(200, 200)); 

[scrollView.layer renderInContext:UIGraphicsGetCurrentContext()]; 

UIImage *fullScreenshot = UIGraphicsGetImageFromCurrentImageContext(); 

UIGraphicsEndImageContext(); 

imageView1.contentMode = UIViewContentModeScaleAspectFill; 

UIImageWriteToSavedPhotosAlbum(fullScreenshot, nil, nil, nil); 

return fullScreenshot; 

import QuartzCore/QuartzCore.h如果

UIGraphicsGetImageFromCurrentImageContext();