对于任何人仍然在寻找一种方式来做到这一点,因为我在ASOC写这个,我结束了使用此代码:
on rotateImage_byAngle_(startingImage, angle)
set rotated to current application's NSImage's alloc()'s initWithSize_({startingImage's |size|()'s height(), startingImage's |size|()'s |width|()})
rotated's lockFocus()
set transform to current application's NSAffineTransform's transform()
transform's translateXBy_yBy_((rotated's |size|()'s |width|())/2, (rotated's |size|()'s height())/2)
transform's rotateByDegrees_(angle)
transform's translateXBy_yBy_(-(rotated's |size|()'s height())/2, -(rotated's |size|()'s |width|())/2)
transform's concat()
startingImage's drawAtPoint_fromRect_operation_fraction_({0, 0}, {{0, 0}, {0, 0}}, current application's NSCompositeCopy, 1)
rotated's unlockFocus()
return rotated
end rotateImage_byAngle_