문제

TIFF 문서를 열고 표시 할 수있는 프로그램이 있습니다. 나는 setflipped를 사용하고 있습니다 : 예입니다.

단일 페이지 이미지 파일을 다루고 있다면 할 수 있습니다.

[image setFlipped: YES];

그리고 그것은 뷰가 뒤집힌 것 외에도 이미지를 올바르게 그린 것 같습니다.

그러나 어떤 이유로 든 이미지의 뒤집기를 설정한다고해서 개별 표현의 뒤집기에 영향을 미치지 않는 것 같습니다.

이것은 다중 페이지 TIFF의 여러 이미지가 동일한 이미지의 "표현"으로 나타나는 것처럼 보이기 때문에 관련이 있습니다. 따라서 이미지를 그리면 뒤집 히지 만 특정 표현을 그리면 뒤집지 않습니다. 또한 NSIMAGE를 그릴 때 그려지는 기본 표현이 어떤 표현인지 선택하는 방법을 알 수 없습니다.

감사해요.

도움이 되었습니까?

해결책 2

나는 대답은 그렇습니다. 다른 페이지가 별도의 표현이며, 올바른 방법은 그것들을 다음과 같이 이미지로 바꾸는 것입니다.

NSImage *im = [[NSImage alloc] initWithData:[representation TIFFRepresentation]];
[im setFlipped:YES];

다른 팁

이미지를 그린 방법을 제어하기 위해 -setflipped : 메소드를 사용해서는 안됩니다. 당신은 당신이 그리는 컨텍스트의 뒤집기를 기반으로 변환을 사용해야합니다. 이와 같은 것 (NSIMAGE의 범주) :

@implementation NSImage (FlippedDrawing)
- (void)drawAdjustedInRect:(NSRect)dstRect fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op fraction:(CGFloat)delta
{
    NSGraphicsContext* context = [NSGraphicsContext currentContext];
    BOOL contextIsFlipped      = [context isFlipped];

    if (contextIsFlipped)
    {
        NSAffineTransform* transform;

        [context saveGraphicsState];

        // Flip the coordinate system back.
        transform = [NSAffineTransform transform];
        [transform translateXBy:0 yBy:NSMaxY(dstRect)];
        [transform scaleXBy:1 yBy:-1];
        [transform concat];

        // The transform above places the y-origin right where the image should be drawn.
        dstRect.origin.y = 0.0;
    }

    [self drawInRect:dstRect fromRect:srcRect operation:op fraction:delta];

    if (contextIsFlipped)
    {
        [context restoreGraphicsState];
    }

}
- (void)drawAdjustedAtPoint:(NSPoint)point
{
    [self drawAdjustedAtPoint:point fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
}

- (void)drawAdjustedInRect:(NSRect)rect
{
    [self drawAdjustedInRect:rect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
}

- (void)drawAdjustedAtPoint:(NSPoint)aPoint fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op fraction:(CGFloat)delta
{
    NSSize size = [self size];
    [self drawAdjustedInRect:NSMakeRect(aPoint.x, aPoint.y, size.width, size.height) fromRect:srcRect operation:op fraction:delta];
}
@end
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top