How to composite several NSImages into one big image?

后端 未结 2 518
北恋
北恋 2021-02-13 02:51

I have a collection of objects which describe an image-name, its size and it\'s X/Y location. The collection is sorted by \"layers\", so I can composite the images in a sort of

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-13 03:09

    NSImage* resultImage = [[[NSImage alloc] initWithSize:imageSize] autorelease];
    [resultImage lockFocus];
    
    [anotherImage drawAtPoint:aPoint fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
    // Or any of the other about 6 options; see Apple's guide to pick.
    
    [resultImage unlockFocus];
    

    Check Apple's Drawing Guide for a much longer, more detailed answer.

提交回复
热议问题