은 내가 사용하여 해당 GIF의 프레임 번호와 같은 데이터를 반환하는 방법을 냈어요 : 나는 실제로 그 프레임에 액세스 할 수있는 방법에 관한
NSNumber *frames = [bitmapRep valueForProperty:@"NSImageFrameCount"];
는 그러나, 나는 조금 혼란 스러워요 그 자신의 개체.
당신 만
NSImageCurrentFrame
을 설정해야 작업이 완료되는 특별한 프레임
indexOfFrame
(
0 <= indexOfFrame < [frames intValue]
)에 액세스합니다. CG 기능을 사용하거나 프레임을 복사 할 필요가 없습니다. 당신은 객체 지향 코코아 세계에 머물 수 있습니다.
NSNumber *frames = [bitmapRep valueForProperty:@"NSImageFrameCount"];
if(frames!=nil){ // bitmapRep is a Gif imageRep
for(NSUInteger i=0; i<[frames intValue]; i++){
[bitmapRep setProperty:NSImageCurrentFrame
withValue:[NSNumber numberWithUnsignedInt:i] ];
NSLog(@"%2d duration=%@",
i, [bitmapRep valueForProperty:NSImageCurrentFrameDuration]);
}
}
는 또 다른 예 :
NSNumber *frames = [bitmapRep valueForProperty:@"NSImageFrameCount"];
if(frames!=nil){ // bitmapRep is a Gif imageRep
for(NSUInteger i=0; i<[frames intValue]; i++){
[bitmapRep setProperty:NSImageCurrentFrame
withValue:[NSNumber numberWithUnsignedInt:i] ];
NSData *repData = [bitmapRep representationUsingType:NSPNGFileType
properties:nil];
[repData writeToFile:
[NSString stringWithFormat:@"/tmp/gif_%02d.png", i ] atomically:YES];
}
}
: 파일 시스템에 PNG 파일로 GIF 이미지의 모든 프레임을 쓰기 작은 예는 모든 GIF 프레임의 지속 시간을 보여줍니다