Re: New NSImage...
Re: New NSImage...
- Subject: Re: New NSImage...
- From: Ricky Sharp <email@hidden>
- Date: Fri, 30 Jul 2004 11:18:44 -0500
On Friday, July 30, 2004, at 11:05AM, Brian O'Brien <email@hidden> wrote:
>
I'm trying to create an NSImage to show in an NSImageView.
>
>
I want to be able to set the:
>
width,
>
height,
>
number of bits per pixel,
>
number of samples per pixel
>
and I have a pointer to an unsigned char * img[x*y*samplesPerPixel]
>
>
I don't know if the image width must be rounded in cocoa...
>
>
I gather I need to somehow create a bitmapImageRep and and NSImage and
>
that I add the representation
>
to the NSImage and then I add the NSImage to the NSImageView...
I believe you're on the right track.
In terms of rouding the image width, I don't think you need to worry about that.
Definitely check out the docs on NSBitmapImageRep. Specifically the initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel: API.
That should give you all the control you need.
Then, I believe you can create an "empty" image:
NSImage* anImage = [[NSImage alloc] initWithSize:someSize];
then add the representation:
[anImage addRepresentation:yourImageRep];
But check out the documentation for the addRepresentation: API. It mentions that you may need to some some additional work to set features on the image representation.
Also, you may have better luck posting this question on the quartz-dev list.
Rick Sharp
Instant Interactive(tm)
_______________________________________________
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.