place NsImage by its center ?

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

  1. macrumors newbie

    Joined:
    Oct 7, 2009
    #1
    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
     
  2. macrumors regular

    Joined:
    Jun 7, 2009
    #2
    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. thread starter macrumors newbie

    Joined:
    Oct 7, 2009

Share This Page