Head.SmackOnTable();

Contains Nuts.

Code Snippets – Text on images

without comments

Two code snippets for you:

private void drawTextWithBackground (string Text, Font font, Graphics grpaphics, Brush backgroundBrush, Brush foregroundBrush, int x, int y)

{

SizeF size = grpaphics.MeasureString(Text, font);

grpaphics.FillRectangle(backgroundBrush, x,y,size.Width, size.Height);

grpaphics.DrawString(Text,font,foregroundBrush,x+1,y+1);

}

private void drawTextAtBottom (String Text, Font font, Graphics graphics, Image sourceImage, Brush backgroundBrush, Brush foregroundBrush)

{

SizeF size = graphics.MeasureString(Text, font);

int y = (int) (sourceImage.Height – size.Height);

drawTextWithBackground(Text,font,graphics,backgroundBrush,foregroundBrush,1,y);

}

Does exactly what it says on the tin!

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DotNetKicks
  • DZone

Written by Monty

May 4th, 2009 at 1:13 pm

Posted in .NET, Code Snippet, R&D Lab

Tagged with ,

Leave a Reply