Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created July 17, 2015 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/6e265fb16c0aafea23b3 to your computer and use it in GitHub Desktop.
Save bjoerntx/6e265fb16c0aafea23b3 to your computer and use it in GitHub Desktop.
// creates a new "DRAFT" sample image
private Bitmap CreateDraftImage()
{
string sText = "DRAFT";
Bitmap destination = new Bitmap(400, 400);
using (Graphics g = Graphics.FromImage(destination))
{
GraphicsUnit units = GraphicsUnit.Pixel;
g.Clear(Color.White);
StringFormat stringFormat = new StringFormat();
stringFormat.Alignment = StringAlignment.Center;
stringFormat.LineAlignment = StringAlignment.Center;
g.DrawString(sText, new Font(
"Arial",
90,
FontStyle.Bold,
GraphicsUnit.Pixel),
new SolidBrush(
Color.FromArgb(64, Color.Black)),
destination.GetBounds(ref units),
stringFormat);
}
return destination;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment