본문으로 바로가기

UIImage 해상도 사이즈 줄이기(용량)

category (IT)Program / IOS 2016. 11. 25. 16:39

사진을 찍을때 해상도가 커서 용량을 줄일때가 필요하다.

그럴때 이걸 쓰면 금방이다.

레퍼토리는 간단하다 사진 찍을껄 UIImage에 넣었다면 또하나에 UIImage를 사이즈를 줄이고 거기다 넣는 방식이다.

아래 소스를 참고 해주세요.


   UIImage *tempImage = nil;
   CGSize targetSize = CGSizeMake(imgCapture.size.width/5,
                                   imgCapture.size.height/5);
   UIGraphicsBeginImageContext(targetSize);
    
   CGRect thumbnailRect = CGRectMake(0, 0, 0, 0);
   thumbnailRect.origin = CGPointMake(0.0,0.0);
   thumbnailRect.size.width  = targetSize.width;
   thumbnailRect.size.height = targetSize.height;
    
   [imgCapture drawInRect:thumbnailRect];
   tempImage = UIGraphicsGetImageFromCurrentImageContext();
   UIGraphicsEndImageContext();