Drawing a font with a different outline colour

Below is an example of the code I'm using to draw a font onto an existing gif image, which works fine:

Bitmap bmpImage = new Bitmap(@"C:\bg.gif");
Graphics image = Graphics.FromImage(bmpImage);
image.SmoothingMode = SmoothingMode.AntiAlias;
image.TextRenderingHint = TextRenderingHint.AntiAlias;
Font someText = new Font("Arial", 15, FontStyle.Bold);
image.DrawString("Test", someText, Brush.Black, new Point(2, 2));

However, I also want a two pixel thick outline around the font in a different colour.  How can I achieve this?

Thanks in advance.
redstar_play247Asked:
Who is Participating?
 
gregoryyoungCommented:
umm Bob not to be critical but thats a rectangle :) just giving you a hard time ....

the easiest way to do this is to draw the string multiple times ...



image.DrawString("Test", someText, Brush.Red, new Point(1, 2));
image.DrawString("Test", someText, Brush.Red, new Point(3, 2));
image.DrawString("Test", someText, Brush.Red, new Point(2, 1));
image.DrawString("Test", someText, Brush.Red, new Point(2, 3));
image.DrawString("Test", someText, Brush.Black, new Point(2, 2));
0
 
Bob LearnedCommented:
Rectangle rect = new Rectangle(x, y, width, height);
Pen pen = new Pen(Color.Red, 2);

image.DrawRectangle(pen, rect);

pen.Dispose();

Bob
0
 
gregoryyoungCommented:
naturally you can loop this to do as many pixels as you want ...

also you can do drop shadows in the same way.

Cheers,

Greg
0
 
Bob LearnedCommented:
So, it's your way, my way, or the highway?  =:)

Bob
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.