RE: Compositing to custom view in Cocoa
RE: Compositing to custom view in Cocoa
- Subject: RE: Compositing to custom view in Cocoa
- From: "Kenny Millar" <email@hidden>
- Date: Fri, 30 Jun 2006 15:09:39 +0100
- Organization: Kenny Millar
Hi, Thanks for the reply.
Indeed, I'm not using a font that exists anywhere, it's more a collection of
8x8 sprites that happen to include recogizable numbers, letters and symbols.
It is in fact and emulator for an old computer console from the '80s.
My approach comes from my windows version of this emulator, in which I use
the 8x8 cells as 'brushes' and can 'paint' them to the display device
context in just a few lines of code. BTW, I have some experience of
PlayStation programming, and it can use a similar approach (in 2D Sprite
programming) where you load a 'tiled' image into ram and can transfer
'cells' from it to the display, replacing colors as you go.
Since the system I'm emulating only supported 16 colors, I could just expand
my 128x128 source image to be 2048x2048 and thereby include every possible
color combination for every character.
-Kenny
-----Original Message-----
From: I. Savant [mailto:email@hidden]
Sent: 30 June 2006 14:53
To: Kenny Millar
Cc: email@hidden
Subject: Re: Compositing to custom view in Cocoa
Kenny:
There's no support directly in NSImage for replacing colors. The problem
you're facing is that not all images are bitmap graphics (where you work
with individual pixels). Some are vector-based.
NSImage is an abstraction of images in general. You can work with image
representations though, however after following the link you provided, I
think your approach could probably use an overhaul.
For one thing, if you'd use an image format that supports transparency
(like tiff, for example), you can simply do away with the white background
in your "characters" image and composite the correct section, which would
allow your view's background to show through the sides and insides of the
letters. That's one approach.
The other approach would be to composite the characters on the fly using
the Cocoa text system using the fixed-width font of your choice. If however
you're trying to use a font that is unavailable, not universal, not even in
a "font" format, or whatever, I can understand why you're using the above
approach.
--
I.S.
On Jun 30, 2006, at 7:56 AM, Kenny Millar wrote:
> Hi everyone.
> I'm still struggling to find out how to replace colors in an image,
> before I draw it to the screen.
>
> Basically I have a black and white image, as an image resource in my
> bundle, and subsequently as an NSImage in my app.
>
> When I draw it in my custom view, I'd like to replace all the 'white'
> pixels with my current background color, and all the black pixels with
> a specific fore-ground color.
>
> I've been all through the NSImage and NSView docs, but can't seem to
> come close to this.
>
> For an example of what I'm doing look at http://www.kmillar.co.uk/
> mac/macstuff.html
>
> Thanks in advance everyone.
>
> -Kenny
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> 40gmail.com
>
> This email sent to email@hidden
_______________________________________________
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