• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Compositing two NSImages
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compositing two NSImages


  • Subject: Re: Compositing two NSImages
  • From: Brian Webster <email@hidden>
  • Date: Sun, 24 Jun 2001 23:36:36 -0500

On Sunday, June 24, 2001, at 07:58 PM, cocoa-dev-
email@hidden wrote:

Hi. I have two 32x32 px NSImage's and I would like to get one above the
other in a new, third one (or, on top of one of the original ones, since
I wont need the building blocks). How do I do this most easily...Do I
have to create multiple NSImageReps etc or is there a better way?

You can draw into an image the same way you draw into a view, by first locking focus on the image and then performing draw operations.

NSImage *image1, *image2, *destImage;
NSRect rect;

rect.origin = NSMakePoint(0, 0);
rect.size = [image1 size];
destImage = [[NSImage alloc] initWithSize:[image1 size]];
[destImage lockFocus];
[image1 compositeToPoint:NSMakePoint(0, 0) fromRect:rect operation:NSCompositeSourceOver];
[image2 compositeToPoint:NSMakePoint(0, 0) fromRect:rect operation:NSCompositeSourceOver];
[destImage unlockFocus];

--
Brian Webster
email@hidden
http://www.owlnet.rice.edu/~bwebster


  • Prev by Date: Re: PB widget
  • Next by Date: Re: PB widget
  • Previous by thread: Compositing two NSImages
  • Next by thread: Double Post
  • Index(es):
    • Date
    • Thread