Fwd: NSImage representations
Fwd: NSImage representations
- Subject: Fwd: NSImage representations
- From: Jeremy Rotsztain <email@hidden>
- Date: Sat, 7 Jul 2007 15:26:55 -0400
Hello.
My imaging software continuously updates a NSImage object with the
contents of a NSBitMapImageRepresentation.
I'm drawing into the image representation every frame, and adding the
image representation to the NSImage again, but I'm unable to see the
updated NSImage when I display it in a NSImageView or export it to
disk using [ NSData writeToFile ].
Any advice on getting this to work would be greatly appreciated.
Jeremy
In my code, it looks something like this.
init:
NSImage *myComposition = [[[NSImage allocWithZone:[self zone]]
initWithSize:compositionSize ] retain ];
// create img representation
NSBitmapImageRep *myCompositionRep = [[NSBitmapImageRep
allocWithZone:[self zone]]
initWithBitmapDataPlanes: nil // Nil pointer tells the kit to
allocate the pixel buffer for us.
pixelsWide: compositionSize.width
pixelsHigh: compositionSize.height
bitsPerSample: 8
samplesPerPixel: 4
hasAlpha: YES
isPlanar: NO
colorSpaceName: NSCalibratedRGBColorSpace // 0 = black, 1 = white
in this color space.
bytesPerRow: 0 // Passing zero means "you figure it out."
bitsPerPixel: 32]; // This must agree with bitsPerSample and
samplesPerPixel.
[ myCompositionRep retain ];
// add representation to main image
[ myComposition addRepresentation:myCompositionRep ];
drawing loop:
// draw into myCompositionRep
[ myComposition addRepresentation:myCompositionRep ];
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden