0
다음 코드를 사용하여 NSImage
을 뒤집기 (180도 회전)하고 있습니다. 그러나 새 이미지는 디스크에 저장 될 때 원래 크기의 두 배 크기 (MB가 아닌 크기)입니다. 원본과 거의 같기를 바랍니다. 이것을 어떻게 할 수 있습니까? 나는 디스크에 이미지를 저장하기 위해 사용하고NSAffineTransform을 사용하여 NSImage 결과를 파일 크기의 두 배로 회전하십시오.
NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:[[_imageView image] TIFFRepresentation]];
NSImage *img = [[NSImage alloc] initWithSize:NSMakeSize(imageRep.pixelsWide, imageRep.pixelsHigh)];
[img lockFocus];
NSAffineTransform *rotator = [NSAffineTransform transform];
[rotator translateXBy:imageRep.pixelsWide yBy:imageRep.pixelsHigh];
[rotator scaleXBy:-1 yBy:-1];
[rotator concat];
[imageRep drawInRect:NSMakeRect(0, 0, imageRep.pixelsWide, imageRep.pixelsHigh)];
[img unlockFocus];
코드 : 사전에
[[NSFileManager defaultManager] createFileAtPath:path contents:[img TIFFRepresentation] attributes:nil];
감사합니다!
TIFF에는 이미지 압축 옵션이 있습니다. 아마도 이것이 문제입니다. – zaph
원본 이미지도 TIFF입니까? TIFF는 아름다운 이미지 형식이지만 JPEG 또는 PNG와 비교할 때 매우 장황합니다. 따라서 이것이 문제가 될 수 있습니다. –