Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand
  • Advertisements

How to generate a bitmap dynamically in ASP.NET?

Posted by Paul on October 12, 2010

There are two steps in this process

Step1: Create the bitmap dynamically

private Bitmap GetDynamicBitmap()


Bitmap bitmap = new Bitmap(100, 100);

      Graphics graphics = Graphics.FromImage(bitmap);

      graphics.DrawString("Dynamic Bitmap", new Font("Calibri", 14, FontStyle.Bold), Brushes.Black,

      new PointF(10, 10));


      return bitmap;


Step2: Set the http response to bitmap

Bitmap bitmap = GetDynamicBitmap();

context.Response.ContentType = "image/bmp";

bitmap.Save(context.Response.OutputStream, ImageFormat.Bmp);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s