• 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 several NSImages into one
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compositing several NSImages into one


  • Subject: Re: Compositing several NSImages into one
  • From: Andrew Garber <email@hidden>
  • Date: Wed, 28 May 2003 21:13:40 -0700
  • Resent-date: Wed, 28 May 2003 21:14:25 -0700
  • Resent-from: Andrew Garber <email@hidden>
  • Resent-message-id: <email@hidden>
  • Resent-to: email@hidden

I wrote some code recently which does what you ant (I think):

quality = 0.95;

jpegProperties = [NSDictionary dictionaryWithObject:[NSNumber
numberWithFloat:quality] forKey:NSImageCompressionFactor];

image1 = [[NSImage alloc]
initWithContentsOfFile:pathToCurrentFirstImage];
image2 = [[NSImage alloc]
initWithContentsOfFile:pathToCurrentSecondImage];

[image1 lockFocus];
[image2 compositeToPoint:NSZeroPoint
operation:NSCompositeSourceAtop fraction:0.5];
[image1 unlockFocus];

// Save as a JPEG using the compression factor described in
jpegProperties
[[[NSBitmapImageRep imageRepWithData:[image1
TIFFRepresentation]] representationUsingType:NSJPEGFileType
properties:jpegProperties]
writeToFile:[@"/Users/splicer/"
stringByAppendingPathComponent:[@"compositeImage"
stringByAppendingPathExtension:@"jpg"]]
atomically:YES];

On Wednesday, May 28, 2003, at 07:39 PM, Andy Satori wrote:

> Ok, I'm feeling really dumb. I don't see a way to 'drawImageAtPoint'
> with an NSImage. What I have is a group of images that are masters
> that I want to programmatically build from, so I want to create an
> NSImage for output, place 3 or 4 NSImages loaded from disk, and then
> persist the output back to disk. The problem is that I don't see a
> way to composite them onto the output.
>
> What am I missing?
>
> Andy
> _______________________________________________
> 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.
_______________________________________________
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.

  • Prev by Date: port number for NSSocketPort
  • Next by Date: How-To: umbrella framework
  • Previous by thread: Compositing several NSImages into one
  • Next by thread: NSButtonCell title alignment
  • Index(es):
    • Date
    • Thread