- 이미지의 부분 :
- (UIImage*) getSubImageFrom: (UIImage*) img WithRect: (CGRect) rect {
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
// translated rectangle for drawing sub image
CGRect drawRect = CGRectMake(-rect.origin.x, -rect.origin.y, img.size.width, img.size.height);
// clip to the bounds of the image context
// not strictly necessary as it will get clipped anyway?
CGContextClipToRect(context, CGRectMake(0, 0, rect.size.width, rect.size.height));
// draw image
[img drawInRect:drawRect];
// grab image
UIImage* subImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return subImage;
}
크기 조정를 들어 -
320 × 240에있는 UIImageView의 프레임을 넣어 다음 imageView.contentMode = UIViewContentModeScaleAspectFit;
당신은 작물을 의미하거나 크기를 조정 . 그것이 자르기에 관한 것 인 것처럼, 이미지의 어느 부분을 가운데, 왼쪽 위 등의 자르기를 원하십니까? – rptwsthi
자르기 또는 크기 조정 중 하나 일 수 있지만 품질 부족으로 320x240 크기의 결과 이미지 크기가 필요합니다 ... 자르기 의미 인 경우 자르기는 가운데에서해야합니다. –