Drawing 32-bit images into an NSBitmapImageRep
Drawing 32-bit images into an NSBitmapImageRep
- Subject: Drawing 32-bit images into an NSBitmapImageRep
- From: Julian Blow <email@hidden>
- Date: Sat, 16 Sep 2006 12:02:52 +0100
I'm having problems manipulating 32-bit graphics images with
NSBitmapImageRep and Core Image. My ultimate aim is to rotate the
image using the CIAffineTransform filter, but I'm having problems
just creating the image. The guts of the problem lie here:
NSSize newImageSize; // holds the size in pixels of the image to
be created
NSBitmapImageRep* oldImage; // holds an existing 128-bit image
NSBitmapImageRep* newBitmap=[[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL // automatically allocates
memory
pixelsWide:newImageSize.width
pixelsHigh:newImageSize.height
bitsPerSample:32
samplesPerPixel:4 // RGBA is required for 32-bit
precision graphics
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bitmapFormat:NSFloatingPointSamplesBitmapFormat; // alpha
last, premultiplied, floating point
bytesPerRow:newImageSize.width*16
bitsPerPixel:128];
CIContext* newCIContext=[[NSGraphicsContext
graphicsContextWithBitmapImageRep:newBitmap] CIContext];
CIImage* theCIImage=[[[CIImage alloc]
initWithBitmapImageRep:oldImage] autorelease];
[newCIContext drawImage:theCIImage atPoint:CGPointZero
fromRect:CGRectMake(0.0,0.0,newImageSize.width,newImageSize.height)];
When I draw the image, I get the following error message in the Console:
CGBitmapContextCreate: unsupported parameter combination: 32 integer
bits/component; 128 bits/pixel; 3-component colorspace;
kCGImageAlphaPremultipliedLast.
So Quartz seems to think I'm trying to make a 32-bit integer bitmap
rather than a 32-bit float bitmap. But I told NSBitmapImageRep the
format was NSFloatingPointSamplesBitmapFormat. If I replace
everything with the relevant numbers for a normal 8-bit (integer)
bitmap (bps 8, spp 4, bpp 32) it works fine.
Can anyone suggest what I'm doing wrong?
Thanks in advance,
Julian Blow
_______________________________________________
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