i want crop tall images 3 quarters width, keeping top part of them.
although images being cropped correct ratio, position crop taken seems totally random, can top, middle, or bottom.
here code 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 missing, surely 0, 0 in nsrect means copy top left of source top left of target?
in advance assistance.
i'm not in front of computer right now, if i'm not mistaken, nsmakerect takes x, y, width , height. notice have x, y, width , width.
Forums Macs Mac Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
Comments
Post a Comment