2009-06-17 9 views

답변

1

NSRect으로 정의 된 영역을 원할 경우 this code해야합니다. 더 복잡한 영역 (직사각형이 아닌)이 필요하면 Apple의 Cropped Image example에 베 지어 곡선으로 자르기위한 코드가 포함됩니다 (CroppingImageView.m의 -croppedImage 참조).

나는이 작업을 수행하기 위해 내가 Bill DudneyCore Animation Book에서 가지고 몇 가지 코드를 적응
+1

"자른 이미지 예"링크가되지 않습니다 : CGImageRef를 얻으려면 :

- (NSArray*)splitImageIntoRects:(CGImageRef)anImage{ CGSize imageSize = CGSizeMake(CGImageGetWidth(anImage), CGImageGetHeight(anImage)); NSMutableArray *splitLayers = [NSMutableArray array]; kXSlices = 3; kYSlices = 3; for(int x = 0;x < kXSlices;x++) { for(int y = 0;y < kYSlices;y++) { CGRect frame = CGRectMake((imageSize.width/kXSlices) * x, (imageSize.height/kYSlices) * y, (imageSize.width/kXSlices), (imageSize.height/kYSlices)); CALayer *layer = [CALayer layer]; layer.frame = frame; CGImageRef subimage = CGImageCreateWithImageInRect(drawnImage, frame); layer.contents = (id)subimage; CFRelease(subimage); [splitLayers addObject:layer]; } } return splitLayers; } 

주 일 – Ramz

8

:

CGImageRef anImage = [myUIImage CGImage]; 
관련 문제