NSImageViews and redrawing bitmap data
NSImageViews and redrawing bitmap data
- Subject: NSImageViews and redrawing bitmap data
- From: Don Murta <email@hidden>
- Date: Wed, 07 Nov 2001 16:37:57 -0700
Hi, I feel a little stupid asking this.
Basically what I'm trying to do is take a NSImageView, pull out the
bitmap data from it change its bitmap data, and have it redisplay. I
can get it to draw once at startup, and my bitmap data seems to be
changing ok, but I can't seem to get the bitmap back out to the screen
again.
Thanks in advance.
-Don-
// assume NSImageView *theImageView loads and draws once just fine
- (IBAction)doMyDraw:(id)sender
{
NSBitmapImageRep *theImageRep = [[[theImageView image]
representations] objectAtIndex:0];
unsigned char *data;
int i;
data = [theImageRep bitmapData];
// the image is RGB, 400 x 400
// flip black to white
for( i = 0; i < (400 * 400 * 3); i++ )
{
if( data[i] == 0 )
{
data[i] = 255;
}
else
{
data[i] = 0;
}
}
// how do I make my changes get redrawn?
}