PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Blitting DC text

I'm currently implementing a routine that can draw text using a device context. Because I need many different font sizes the bitmap font is not feasible.

So far things work great and I can copy the text on to a GapiSurface. I have one problem, however. When copying to the destination surface, I would like that it is only the text pixel and not the background pixels that are copied. In other words, I need a Blit function that can ignore pixels of a certain color (make them transparent) and copy the rest. I believe this is normally called alpha keying, or something similar.

How is this possible with GapiDraw?

Thanks in advance.

Per Rasmussen.
Birdiestyle · 18 Sep 2009, 21:07 UTC
Dont you just want to set the SetColorKey of the CGapiSurface you are drawing the font to to the transparent color... And then when copied to the final surface it will do just as you say(for 1 color).
perrs wrote:I need a Blit function that can ignore pixels of a certain color (make them transparent) and copy the rest. I believe this is normally called alpha keying, or something similar.


Hello Per!

As BirdieStyle says - you do it as follows:
1. Call SetColorKey on the surface that contains your text and use the background color of your text surface.
2. Call BltFast and use the flag GDBLTFAST_KEYSRC

You can read more on it here:
http://www.gapidraw.com/docs/gapidraw/g ... -frame.htm

Sincerely
Johan
I actually realized this when I was browsing through the documentation again a few days ago. But thanks anyway for your answer. :-)

Currently I'm having a bit of problems because the background color kind of "shines through" when the font is anti-aliased. I am currently working on this. If you happen to have a good idea, please share.

Best regards,
Per Rasmussen.