Re: Swapping NSBitmapImageRep bitmapData's
Re: Swapping NSBitmapImageRep bitmapData's
- Subject: Re: Swapping NSBitmapImageRep bitmapData's
- From: "Dennis C. De Mars" <email@hidden>
- Date: Mon, 11 Jun 2001 17:23:16 -0000
Ken Tabb <email@hidden> said:
>
Hi,
>
is there any way to swap the bitmapData array in an NSBitmapImageRep? I
>
have some image processing code in which I would like to swap the array
>
being pointed to by the NSBitmapImageRep. The 2 arrays are of the same
>
length / pixel order / depth etc., just showing a different picture.
>
>
Is this possible... the API docs only seem to suggest ways of getting an
>
NSBitmapImageRep's bitmapData, rather than setting it.
>
>
... Or am I missing the fact that doing so would screw any NSImages which
>
had formed from the NSBitmapImageRep? What would be the best way to
>
'rebuild' an NSImage from the (newly swapped) NSBitmapImageRep's
>
bitmapData, rather than having to re-allocate memory etc.?
Well, one of the initialization routines, initWithBitmapDataPlanes, allows you to
specify a pointer to the buffer containing your bitmap. However, I don't think you can
change the buffer pointer once you've created the NSBitmapImageRep.
However, what you can do is create two NSBitmapImageRep objects, each one with a
pointer to one of your buffers. Then you can just switch the representation used by the
NSImage displaying your bitmap using -addRepresentation: and -removeRepresentation: .
This should achieve the same effect.
- Dennis D.