PDA

View Full Version : place NsImage by its center ?




oneHande
Oct 14, 2009, 09:01 AM
hello,
when you drag and drop a NSImage,
it is placed by its "bounds" origin : point left down

is it an API method to force application to place them
by their center ?

thank you



rossipoo
Oct 14, 2009, 09:50 AM
All you have to do is subtract half of the image dimentions from the point of placement.

NSSize imageSize;
NSPoint center;
NSPoint placement = { center.x - (imageSize.width / 2), center.y - (imageSize.width / 2) };

oneHande
Oct 15, 2009, 05:07 PM
perfect

thanks a lot

:=)