Re: NSImage get / set Pixels
Re: NSImage get / set Pixels
- Subject: Re: NSImage get / set Pixels
- From: Ricky Sharp <email@hidden>
- Date: Thu, 16 Mar 2006 09:18:03 -0600
On Thursday, March 16, 2006, at 08:58AM, goessly <email@hidden> wrote:
>I'd like to copy a pixel to an NSImage *outputImage (at the NSPoint
>*targetCoordinates).
>The pixel is to be read from another NSImage *inputImage (at the
>NSPoint *sourceCoordinates).
>
>Something like
>[outputImage drawAt: targetCoordinates copiedPixelFrom: [inputImage
>pixelAt: sourceCoordinates] ]
>
>How can I accomplish this? NSImage seems to lack getters / setters
>for pixels at given coordinates.
NSImage is just a container. I'm going to assume that all your images have a bitmap image rep. If so, obtain the bitmap image reps from the NSImage instances. Then, use getPixel:atX:y: and setPixel:atX:y.
If you're only doing a few pixels at a time, this should be OK. However, if you're doing work with many pixels, you may want to consider using direct pixel access to do the reads/writes for better performance. There's an example of this in the TransformedImage sample code.
--
Rick Sharp
Instant Interactive(tm)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden