Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Painting into a NSImage / Combining two NSImage objects



On Tuesday, September 2, 2003, at 08:05 AM, Markus Hanauska wrote:

Very simple question:

I have two NSImage objects, both are parts of my resource bundle.

I want to combine both two a third NSImage object, so that image1 is overlayed by image2. How can I do that?

I'm only familiar to the Java way of doing things: You create an empty image, you paint image1 into the empty image, you paint image two into the (now not really) empty image at the desired position.

But I fail to see how you can actually paint one image into another one or combine two images in case of NSImage. I've read the NSImage documentation over and over again, but I fail to understand it.

It's such a simple task, two lines of code in Java, why can't it be that simple as well in Cocoa?

Check out lockFocus and unlockFocus and then consider using compositeToPoint:operation:fraction:.

[finalImage lockFocus];

[image1 compositeToPoint:...];
[image2 compositeToPoint:...];

[finalImage unlockFocus];

-Shawn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Painting into a NSImage / Combining two NSImage objects (From: Markus Hanauska <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.