FROM : Kenny Millar
DATE : Sat Jul 01 14:37:26 2006
List,
Thanks to I.Savant and George Orthwein, I can now colorize the
source image and then draw the tile to the view.
To make it faster I'd like to optimize the code, by only colorizing
one 8x8 'cell' at a time, rather than the full 128x128 image (as I
need to do it 25 x 40 times each time I refresh the display).
So my basic question is how can I create an NSImage, or
NSBitmapRepresentation, which contains just a specified rectangle of
a source image?
I've been all through the docs and can't figure out how to pull a
sepcific rectangle from an image, and store it in an NSImage or
NSBitmapRepresentation.
Any ideas?
-Kenny
On 30 Jun 2006, at 21:52, I. Savant wrote:
> George:
>
> Thanks for this - I hadn't considered that solution.
>
> --
> I.S.
>
>
> On Jun 30, 2006, at 11:17 AM, George Orthwein wrote:
>
>> On Jun 30, 2006, at 10:36 AM, Kenny Millar wrote:
>>> Because I need to change the foreground colour too, and every
>>> location on
>>> the 'screen' can have a different forground/background colour.
>>
>> It would take two operations. You'd composite the text with
>> transparent background with a solid fill color as source, using
>> CompositeSourceIn. That colorizes the text and leaves the
>> transparency. Then you'd draw that over the background color. At
>> least, I think that should work. :)
>>
>> If you can't add transparency, I just discovered -
>> colorizeByMappingGray:toColor:blackMapping:whiteMapping. It kinda
>> works for me but for some reason the white areas are using the
>> gray color instead of the specified white color. But I did end up
>> with custom back/foreground colors.
>>
>> I'm surprised there is not an NSImage method for using a grayscale
>> image as a mask. Half the messages in the archives asking about
>> this topic reference CompositeSourceIn, but I see now that that
>> will only work if you already have some transparency. There do
>> seem to be some Quartz methods though:
>> http://developer.apple.com/documentation/GraphicsImaging/
>> Conceptual/drawingwithquartz2d/dq_images/chapter_12_section_6.html
>>
>> Looks like a good candidate for an NSBitmapImageRef category. :)
>> (though I don't actually know how difficult using the quartz calls
>> would be...)
>>
>> George
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Cocoa-dev mailing list (<email_removed>)
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/idiotsavant2005%
>> 40gmail.com
>>
>> This email sent to <email_removed>
>
DATE : Sat Jul 01 14:37:26 2006
List,
Thanks to I.Savant and George Orthwein, I can now colorize the
source image and then draw the tile to the view.
To make it faster I'd like to optimize the code, by only colorizing
one 8x8 'cell' at a time, rather than the full 128x128 image (as I
need to do it 25 x 40 times each time I refresh the display).
So my basic question is how can I create an NSImage, or
NSBitmapRepresentation, which contains just a specified rectangle of
a source image?
I've been all through the docs and can't figure out how to pull a
sepcific rectangle from an image, and store it in an NSImage or
NSBitmapRepresentation.
Any ideas?
-Kenny
On 30 Jun 2006, at 21:52, I. Savant wrote:
> George:
>
> Thanks for this - I hadn't considered that solution.
>
> --
> I.S.
>
>
> On Jun 30, 2006, at 11:17 AM, George Orthwein wrote:
>
>> On Jun 30, 2006, at 10:36 AM, Kenny Millar wrote:
>>> Because I need to change the foreground colour too, and every
>>> location on
>>> the 'screen' can have a different forground/background colour.
>>
>> It would take two operations. You'd composite the text with
>> transparent background with a solid fill color as source, using
>> CompositeSourceIn. That colorizes the text and leaves the
>> transparency. Then you'd draw that over the background color. At
>> least, I think that should work. :)
>>
>> If you can't add transparency, I just discovered -
>> colorizeByMappingGray:toColor:blackMapping:whiteMapping. It kinda
>> works for me but for some reason the white areas are using the
>> gray color instead of the specified white color. But I did end up
>> with custom back/foreground colors.
>>
>> I'm surprised there is not an NSImage method for using a grayscale
>> image as a mask. Half the messages in the archives asking about
>> this topic reference CompositeSourceIn, but I see now that that
>> will only work if you already have some transparency. There do
>> seem to be some Quartz methods though:
>> http://developer.apple.com/documentation/GraphicsImaging/
>> Conceptual/drawingwithquartz2d/dq_images/chapter_12_section_6.html
>>
>> Looks like a good candidate for an NSBitmapImageRef category. :)
>> (though I don't actually know how difficult using the quartz calls
>> would be...)
>>
>> George
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Cocoa-dev mailing list (<email_removed>)
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/idiotsavant2005%
>> 40gmail.com
>>
>> This email sent to <email_removed>
>
| Related mails | Author | Date |
|---|---|---|
| Kenny Millar | Jun 30, 13:56 | |
| I. Savant | Jun 30, 15:52 | |
| Kenny Millar | Jun 30, 16:09 | |
| I. Savant | Jun 30, 16:23 | |
| Kenny Millar | Jun 30, 16:36 | |
| I. Savant | Jun 30, 16:45 | |
| George Orthwein | Jun 30, 17:17 | |
| I. Savant | Jun 30, 22:52 | |
| Kenny Millar | Jul 1, 14:37 | |
| Andy Lee | Jul 1, 14:56 | |
| Matt Neuburg | Jul 1, 16:19 |






Cocoa mail archive

