FROM : Robert W. Kuhn
DATE : Tue Nov 30 09:26:16 2004
On 29.11.2004 20:13 Uhr +0000 Marcel Weiher wrote:
> Try using NSBitmapImageRep directly, the code you are using may or may
> not do what you're thinking.
Thank you for your help. I discovered that I have to use
initWithBitmapDataPlanes:
pixelsWide:
pixelsHigh:
bitsPerSample:
samplesPerPixel:
hasAlpha:
isPlanar:
colorSpaceName:
bytesPerRow:
bitsPerPixel:
My code now looks like that:
mLeftImg = [NSImage alloc];
[mLeftImg setDataRetained:YES];
[mLeftImg
initWithContentsOfFile:@"/Users/rkuhn/Programmierung/Disparity/A_000_000.bmp"];
NSLog(@"BPP: %i", [mLeftImg bitsPerPixel]);
NSBitmapImageRep *bmpRep;
NSData *dat;
dat = [NSData dataWithContentsOfFile:
@"/Users/rkuhn/Programmierung/Disparity/A_000_000.bmp" ];
bmpRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned
char **)&dat
pixelsWide:[mLeftImg width]
pixelsHigh:[mLeftImg height]
bitsPerSample:8
samplesPerPixel:1
hasAlpha:NO
isPlanar:NO
colorSpaceName:NSDeviceWhiteColorSpace
bytesPerRow:[mLeftImg width]*1//pixelsWide*samplesPerPixel
bitsPerPixel:8//bitsPerSample*samplesPerPixel];
NSLog(@"BPP: %i", [bmpRep bitsPerPixel]);
The Log:
2004-11-30 09:22:32.383 Disparity[1513] BPP: 32
2004-11-30 09:22:32.390 Disparity[1513] BPP: 8
Ugly code. Not very handy to load first the image (to get width and
height)
and the the data again.
> This is probably a cached representation, so you are getting the depth
> of the bitmap cache. The last time I checked NSImage discards the
> original data unless you tell it to -setDataRetained:YES.
I also did try this. I always get only 32bit-Data. Also the NSImage has
always only one NSBitmaprepresentation - the 32bit data.
Mit freundlichen Grüßen
Robert W. Kuhn
DATE : Tue Nov 30 09:26:16 2004
On 29.11.2004 20:13 Uhr +0000 Marcel Weiher wrote:
> Try using NSBitmapImageRep directly, the code you are using may or may
> not do what you're thinking.
Thank you for your help. I discovered that I have to use
initWithBitmapDataPlanes:
pixelsWide:
pixelsHigh:
bitsPerSample:
samplesPerPixel:
hasAlpha:
isPlanar:
colorSpaceName:
bytesPerRow:
bitsPerPixel:
My code now looks like that:
mLeftImg = [NSImage alloc];
[mLeftImg setDataRetained:YES];
[mLeftImg
initWithContentsOfFile:@"/Users/rkuhn/Programmierung/Disparity/A_000_000.bmp"];
NSLog(@"BPP: %i", [mLeftImg bitsPerPixel]);
NSBitmapImageRep *bmpRep;
NSData *dat;
dat = [NSData dataWithContentsOfFile:
@"/Users/rkuhn/Programmierung/Disparity/A_000_000.bmp" ];
bmpRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:(unsigned
char **)&dat
pixelsWide:[mLeftImg width]
pixelsHigh:[mLeftImg height]
bitsPerSample:8
samplesPerPixel:1
hasAlpha:NO
isPlanar:NO
colorSpaceName:NSDeviceWhiteColorSpace
bytesPerRow:[mLeftImg width]*1//pixelsWide*samplesPerPixel
bitsPerPixel:8//bitsPerSample*samplesPerPixel];
NSLog(@"BPP: %i", [bmpRep bitsPerPixel]);
The Log:
2004-11-30 09:22:32.383 Disparity[1513] BPP: 32
2004-11-30 09:22:32.390 Disparity[1513] BPP: 8
Ugly code. Not very handy to load first the image (to get width and
height)
and the the data again.
> This is probably a cached representation, so you are getting the depth
> of the bitmap cache. The last time I checked NSImage discards the
> original data unless you tell it to -setDataRetained:YES.
I also did try this. I always get only 32bit-Data. Also the NSImage has
always only one NSBitmaprepresentation - the 32bit data.
Mit freundlichen Grüßen
Robert W. Kuhn
| Related mails | Author | Date |
|---|---|---|
| Robert W. Kuhn | Nov 25, 15:29 | |
| Marcel Weiher | Nov 29, 21:13 | |
| Robert W. Kuhn | Nov 30, 09:26 | |
| Marcel Weiher | Nov 30, 11:56 |






Cocoa mail archive

