====== NSView ====== Below we are using the NSImageRep object to draw into the view, instead of using the NSImage class. The NSImageRep class allows us to select a representation, which is calculated elsewhere with "repOffset." actualSize is used to set the image size to the actual pixels. I don't fully understand why the system sometimes decides to use a size other than pixel size for a typical graphics file. - (void)drawRect:(NSRect)rect { if(image != nil){ NSImageRep *myRep = (NSImageRep *)[[image representations] objectAtIndex:repOffset]; NSSize actualSize = NSMakeSize([myRep pixelsWide],[myRep pixelsHigh]); [myRep setSize:actualSize]; rect.size = actualSize; // fix scrolling origin... // the superview of this class is the contentView of the scrollView, which // is of the NSClipView class NSRect contentFrame = [(NSView *)[self superview] frame]; rect.origin = contentFrame.origin; [self setFrameSize:actualSize]; [myRep drawInRect:rect]; } }