I want to crop some tall images so that they are three quarters their width, keeping the top part of them.
Although the images are being cropped to the correct ratio, the position from which the crop is taken seems to be totally random, it can be from the top, middle, or bottom.
Here is the code I am using:
What am I missing, surely the 0, 0 in the NSRect means it will copy from the top left of the source to the top left of the target?
Thanks in advance for any assistance.
Although the images are being cropped to the correct ratio, the position from which the crop is taken seems to be totally random, it can be from the top, middle, or bottom.
Here is the code I am using:
Code:
NSImage *originalImage = [[NSImage alloc] initWithContentsOfURL:[NSURL fileURLWithPath:previewFile]];
NSSize imageSize = [originalImage size];
NSRect newSize = NSMakeRect(0, 0, imageSize.width, imageSize.width / 1.333);
NSImage *croppedImage = [[NSImage alloc] initWithSize:imageSize.size];
[croppedImage lockFocus];
[originalImage drawInRect:newSize fromRect:newSize operation:NSCompositeCopy fraction:1.0];
[croppedImage unlockFocus];
What am I missing, surely the 0, 0 in the NSRect means it will copy from the top left of the source to the top left of the target?
Thanks in advance for any assistance.
Last edited: