2012-05-06 9 views
2

私はこのgithubの画像クロッピングを使用していあらかじめCGImageCreateWithImageInRect不正な領域ですか? initメソッドでは、彼らはこれらの線有し、この画像クロッピングで<a href="https://github.com/iosdeveloper/ImageCropper" rel="nofollow">https://github.com/iosdeveloper/ImageCropper</a></p> <p>:

CGRect rect; 
     rect.size.width = image.size.width; 
     rect.size.height = image.size.height; 

     [imageView setFrame:rect]; 

を、私は画面に解像度ない点を画像のサイズを変更します。だから、コードをそのままの状態にしておくと、私のUIImageはUIImageViewを何らかの奇妙な理由でいっぱいにしませんし、contentModesも調整しようとしました。

しかし、私はこれまで、それを調整した場合(画像クロッパーがであることをUIPopoverのサイズ):

[imageView setFrame:CGRectMake(0, 0, 320, 480)]; 

UIImage UIPopoverを記入します。

本当の問題はここにある: 私は、画像の特定の部分にズームインすると、以下のコードを実行した場合、それはどこでトリミングした場所の近くにUIImageの左上部分のスクリーンショットを撮るんだろう〜に画像。それはscrollViewのzoomScaleに従いますが。ここで

スクリーンショットコードです:なぜこれが起こっている

- (void)finishCropping { 

    float zoomScale = 1.0/[scrollView zoomScale]; 

    CGRect rect; 
    rect.origin.x = [scrollView contentOffset].x * zoomScale; 
    rect.origin.y = [scrollView contentOffset].y * zoomScale; 
    rect.size.width = [scrollView bounds].size.width * zoomScale; 
    rect.size.height = [scrollView bounds].size.height * zoomScale; 

    CGImageRef cr = CGImageCreateWithImageInRect([[imageView image] CGImage], rect); 

    UIImage *cropped = [UIImage imageWithCGImage:cr]; 

    CGImageRelease(cr); 

    [delegate imageCropper:self didFinishCroppingWithImage:cropped]; 
} 

誰でも知っていますか?

ありがとうございます!

答えて

3

私はの代わりに[UIImage imageWithCGImage:cr]を作成すると思います。これは、方向性に関する多くの問題を解消し、幅と高さをrectの正しい方向に再確認します。

関連する問題

 関連する問題