FROM : Glen Simmons
DATE : Mon Oct 04 21:11:24 2004
On 4 Oct, 2004, at 1:27 PM, R. Scott Thompson wrote:
>>> On Oct 4, 2004, at 11:25 AM, Glen Simmons wrote:
>>>
>>>> I'm creating an NSImage from some 1 bit bitmap data using the
>>>> -[NSBitmapImageRep initWithBitmapDataPlanes:pixelsWide: ...] method
>>>> passing NSCalibratedBlackColorSpace so that 1 bits become black
>>>> pixels and 0 bits become white pixels. I'd like the 0 bits to
>>>> become a color of my choice instead of white. Is there an easy way
>>>> to do this?
>>>
>>> What you want is a different Compositing operation
>>> (NSCompositeSourceOver I think). There doesn't appear to be a way
>>> to do that with an NSImageView. Perhaps you could create a custom
>>> view and use NSImage calls yourself?
>>
>> I did say "easy". :-) I was thinking this could be done at the time
>> of creation. The replacement color would always be the same, so I
>> figured some particular value passed as the colorSpaceName: parameter
>> would do it. Not so?
>
> Nah... the color space name would just let you specify how you wanted
> that background color to be specified (i.e. I want to specify the
> background color as CMYK, or RGB, or RGB as intepreted by thus and
> such a digital camera). You might be able to do something wacky with
> creating an indexed color space and convincing it to use that... but I
> think you'd end up having to create a color profile on the fly and
> much pain and suffing would ensue. Before you got that far, you'd be
> better off using NSQuickDrawView and just create a GWorld with a
> custom palette.
>
> How about using NSBitmapImageRep and
> colorizeByMappingGray:toColor:blackMapping:whiteMapping: It's really
> long but might help.
I hadn't noticed colorizeByMappingGray:. That seems like just the
ticket. I'll try it and let everyone know.
Glen
DATE : Mon Oct 04 21:11:24 2004
On 4 Oct, 2004, at 1:27 PM, R. Scott Thompson wrote:
>>> On Oct 4, 2004, at 11:25 AM, Glen Simmons wrote:
>>>
>>>> I'm creating an NSImage from some 1 bit bitmap data using the
>>>> -[NSBitmapImageRep initWithBitmapDataPlanes:pixelsWide: ...] method
>>>> passing NSCalibratedBlackColorSpace so that 1 bits become black
>>>> pixels and 0 bits become white pixels. I'd like the 0 bits to
>>>> become a color of my choice instead of white. Is there an easy way
>>>> to do this?
>>>
>>> What you want is a different Compositing operation
>>> (NSCompositeSourceOver I think). There doesn't appear to be a way
>>> to do that with an NSImageView. Perhaps you could create a custom
>>> view and use NSImage calls yourself?
>>
>> I did say "easy". :-) I was thinking this could be done at the time
>> of creation. The replacement color would always be the same, so I
>> figured some particular value passed as the colorSpaceName: parameter
>> would do it. Not so?
>
> Nah... the color space name would just let you specify how you wanted
> that background color to be specified (i.e. I want to specify the
> background color as CMYK, or RGB, or RGB as intepreted by thus and
> such a digital camera). You might be able to do something wacky with
> creating an indexed color space and convincing it to use that... but I
> think you'd end up having to create a color profile on the fly and
> much pain and suffing would ensue. Before you got that far, you'd be
> better off using NSQuickDrawView and just create a GWorld with a
> custom palette.
>
> How about using NSBitmapImageRep and
> colorizeByMappingGray:toColor:blackMapping:whiteMapping: It's really
> long but might help.
I hadn't noticed colorizeByMappingGray:. That seems like just the
ticket. I'll try it and let everyone know.
Glen
| Related mails | Author | Date |
|---|---|---|
| Glen Simmons | Oct 4, 18:25 | |
| R. Scott Thompson | Oct 4, 19:39 | |
| Glen Simmons | Oct 4, 19:58 | |
| R. Scott Thompson | Oct 4, 20:27 | |
| Glen Simmons | Oct 4, 21:11 |






Cocoa mail archive

