본문 바로가기
ios 뽀개기/objective-c

이미지 자르기

by 인생여희 2019. 1. 27.
반응형

이미지 자르기


- (IBAction)CaptureAction:(id)sender {

    NSLog(@"캡쳐 버튼 눌렸습니다.");


        CGSize screenS = myImageView.frame.size;

        CGFloat delX = myImageView.image.size.width / screenS.width;

        CGFloat delY = myImageView.image.size.height / screenS.height;


        NSLog(@"myImageView.image.size.width : %f" ,myImageView.image.size.width );

        NSLog(@"myImageView.image.size.height : %f" ,myImageView.image.size.height );

        NSLog(@"screenS.width : %f" ,screenS.width );

        NSLog(@"screenS.height : %f" ,screenS.height );

        NSLog(@"delX : %f" ,delX );

        NSLog(@"delY : %f" ,delY );

    

        NSLog(@"viewFinder.frame.origin.x : %f" ,viewFinder.frame.origin.x );

        NSLog(@" viewFinder.frame.origin.y : %f" ,viewFinder.frame.origin.y );

        NSLog(@"viewFinder.bounds.size.width : %f" ,viewFinder.bounds.size.width );

        NSLog(@"viewFinder.bounds.size.height : %f" ,viewFinder.bounds.size.height );

    

        NSLog(@"***********************************************************************" );

    

        NSLog(@"viewFinder.frame.origin.x  * delX : %f" ,viewFinder.frame.origin.x * delX );

        NSLog(@" viewFinder.frame.origin.y * delY : %f" ,viewFinder.frame.origin.y * delY );

        NSLog(@"viewFinder.bounds.size.width * delX : %f" ,viewFinder.bounds.size.width * delX);

        NSLog(@"viewFinder.bounds.size.height  * delY : %f" ,viewFinder.bounds.size.height * delY );

    


    CGRect sourceRect = CGRectMake(viewFinder.frame.origin.x * delX, (viewFinder.frame.origin.y -110)* delY, viewFinder.bounds.size.width * delX, viewFinder.bounds.size.height * delY);

    CGImageRef imageRef = CGImageCreateWithImageInRect(myImageView.image.CGImage, sourceRect);

    UIImage *cropImage = [UIImage imageWithCGImage:imageRef];

    CGImageRelease(imageRef);


    ImageVC *imageVC = [[ImageVC alloc]init];

    imageVC.cropedimage = cropImage;

    [self presentViewController:imageVC animated:YES completion:nil];

    

}

반응형

댓글