Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSImage drawInRect:fromRect:operation:fraction results in a flipped image

When I use:

[iconImage drawInRect:NSMakeRect(cellFrame.origin.x+5,yOffset+3,cellFrame.size.height-6, cellFrame.size.height-6)
                     fromRect:NSMakeRect(0,0,[iconImage size].width, [iconImage size].height)
                    operation:NSCompositeSourceOver
                     fraction:1.0];

to draw some images in the NSOutlineView cells, the images are vertically flipped upside down. How can I fix it ?

Thanks

like image 222
aneuryzm Avatar asked Feb 20 '23 10:02

aneuryzm


1 Answers

Use the method

- (void)drawInRect:(NSRect)dstSpacePortionRect
          fromRect:(NSRect)srcSpacePortionRect
         operation:(NSCompositingOperation)op
          fraction:(CGFloat)requestedAlpha
    respectFlipped:(BOOL)respectContextIsFlipped
             hints:(NSDictionary *)hints

along with - (void)lockFocusFlipped:(BOOL)flipped

to draw the image upside down. From the NSImage Reference manual.

like image 95
Mark Avatar answered Apr 13 '23 00:04

Mark