Re: Rasterizing an NSString to a bitmap
Re: Rasterizing an NSString to a bitmap
- Subject: Re: Rasterizing an NSString to a bitmap
- From: John Stiles <email@hidden>
- Date: Mon, 7 Jun 2004 15:02:46 -0700
OK, so I need to make an NSImage and then turn it into an
NSBitmapImageRep via initWithFocusedViewRect?
That's kind of perverse. I don't have an NSView, after all :)
I can do this, though. But how do I know what kind of NSBitmapImageRep
I got back? The documentation doesn't say, so theoretically does that
mean it could be according to the whims of the system? Maybe planar and
maybe chunky, maybe 32bpp or maybe 16 (certainly won't be the grayscale
that I'm aiming for), maybe with alpha and maybe without? Ick ick ick.
At this point is there any way to ask the NSBitmapImageRep to resample
itself to any sort of known parameters? Or to get it to draw itself
into a new NSBitmapImageRep of my choosing?
I have no problem with convoluting the image to make it do what I want,
but since the destination format of initWithFocusedViewRect is
undocumented, it seems like I need to write a whole blitter library to
do the resample, or force my app to assume that whatever
initWithFocusedViewRect does now is what it will do indefinitely.
On Jun 7, 2004, at 2:25 PM, Marcel Weiher wrote:
On 7 Jun 2004, at 19:26, John Stiles wrote:
I need to draw an NSString into a block of my own memory so I can do
effects on it. I just want one grayscale channel. I thought this
would be easy but I am stumped! :|
Here's what I've tried to do.
1:
...
- Make an NSBitmapImageRep with the parameters I want (grayscale
1byte per pixel)
...
2:
...
- Make another NSBitmapImageRep with the parameters I want (1 byte
per pixel, grayscale)
...
That's the problem right there. You can't make an NSImage draw into a
NSBitmapImageRep you provide. You can only get an NSBitmapImageRep
out of an NSImage, using the almost but not entirely appropriately
named -initWithFocusedViewRect: method.
That will give you an NSBitmapImageRep with the parameters *it* wants
;-)
If you need other parameters, the only way to get this is add some
image-processing. (You might be tempted to think that a CoreGraphics
bitmap context is the answer, but last time I checked most of the
parameter combinations are unsupported).
Cheers,
Marcel
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.