Page 1 of 1

Using DrawFont with an RGBA font to draw into an RGB surface

PostPosted: Dec 6, 2009 @ 11:42pm
by Nacho84
Hi! Since I cannot use DrawFont on RGBA surfaces (see my previous ), I've decided to use RGB surfaces along with RGBA fonts instead.

Now, according to the library's docs the E2DSurface class accepts both E2DSurface and E2DSurfaceRGBA parameters for the DrawFont method. I tried using the latter one with a font that makes use of the alpha channel but I'm getting weird visual results (see the attached Visual Studio solution) so I'm not sure whether it's me that I'm making a mistake or it's the DrawFont method that it's not meant to be used with RGBA surfaces that make use of the alpha channel. Do you mind taking a look at the attachment? It's a very short example that:

1) Renders the RGBA text to an RGB surface (in the initialization phase).
2) Blits the surface from (1) at the top of the display every frame.
3) Uses the RGBA font surface to blit the same text from (2) directly to the display every frame.

Thanks in advance for your help!

--Nacho

PostPosted: Dec 11, 2009 @ 7:50pm
by edge
Hi Nacho,

I'm afraid your solution doesn't work. The RGBA font is blended with the magenta color of the normal surface. Try to write it to a PNG file and see the results, then use the bucket fill tool (using paint or another program) on the magenta color and what you see would be similar to the results in your EDGELIB application.

A better solution would be to create your own blitter. Use Lock() on both surfaces and transfer the pixel data manually.