對於任何人仍然在尋找一種方式來做到這一點,因爲我在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_