place NsImage by its center ?

Discussion in 'Mac Programming' started by oneHande, Oct 14, 2009.

  1. oneHande
    Expand Collapse
    macrumors newbie

    Oct 7, 2009
    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
  2. rossipoo
    Expand Collapse
    macrumors regular

    Jun 7, 2009
    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) };
  3. oneHande
    Expand Collapse
    thread starter macrumors newbie

    Oct 7, 2009

Share This Page