Re: Need Help Displaying a Floating-Point Image
Re: Need Help Displaying a Floating-Point Image
- Subject: Re: Need Help Displaying a Floating-Point Image
- From: "Michael Ash" <email@hidden>
- Date: Fri, 4 Aug 2006 18:22:01 -0400
On 8/4/06, Robert Murley <email@hidden> wrote:
I have an NSBitmapImageRep with floating-point data samples. When I
attempt to display it, I get all white. Using the same code with 8-bit
integer samples works fine. The FP samples are all between zero and
one, and the alpha channel is all ones.
Could anyone enlighten me as to what I am doing wrong?
Code to create the image rep:
NSBitmapFormat format = NSAlphaFirstBitmapFormat |
NSFloatingPointSamplesBitmapFormat;
imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: data
Note that data must be a pointer to pointers. If your data is
non-planar (RGBA all interleaved in the same chunk) then it should
just be a pointer to your data pointer. If your data is planar
(different arrays for each color channel) then data should be an array
of pointers, one per channel.
pixelsWide: width
pixelsHigh: height
bitsPerSample: 32
32 bits per pixel is good, they're 32-bit floats.
samplesPerPixel: 4
4 samples per pixel, so RGBA.
hasAlpha: YES
isPlanar: YES
You're stating that it's planar, so data should be an array of
pointers. Planar data is rare in my experience, is this what you
actually have?
colorSpaceName: NSCalibratedRGBColorSpace
bitmapFormat: format
bytesPerRow: rowBytes
bitsPerPixel: 32];
32 bits per pixel is correct if your data is planar, badly incorrect
(it should be 128) if it's not.
Code to display it:
IBOutlet NSImageView *imageView;
NSImage *image;
- (void) displayView: (NSBitmapImageRep *) imageRep
{
image = [[NSImage alloc] init];
[image addRepresentation: imageRep];
[imageView setImage: image];
[imageView display];
}
You leak image if this is called more than once. The call to -display
is pointless.
You don't really have much information here. There's a lot more you
can gather to attempt to debug this problem. Here's a bunch of things
to investigate just off the top of my head:
- Does the program actually execute any of the code you've written?
- Are all of the relevant variables non-nil?
- Does anything get printed to your Console (or debugger console/run
log in Xcode)?
- Are all of your numbers sane? What are they?
Mike
_______________________________________________
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