I would like to display an image that changes its content every 2 seconds (or something like that). Unfortunetly I can't use JavaScript, Flash or Silverlight because I want to use the animation in outgoing html emails with maximum compatibility between various email clients.
So, I tried to generate the image with an .ashx handler. But I am not able to refresh the image (or re-execute the ashx handler). I tried a loop, but that didn't work.
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "image/png";
string strDisplay = DateTime.Now.ToString();
Bitmap bmpOut = new Bitmap(400, 50);
Graphics g = Graphics.FromImage(bmpOut);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.FillRectangle(Brushes.Black, 0, 0, 400, 50);
g.DrawString(strDisplay, new Font("Verdana", 18), new SolidBrush(Color.White), 0, 0);
MemoryStream ms = new MemoryStream();
bmpOut.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte[] bmpBytes = ms.GetBuffer();
bmpOut.Dispose();
ms.Close();
context.Response.BinaryWrite(bmpBytes);
context.Response.End();
}
How do I have to do this, or is there an other solution?
Edit: The image content is not predefined. It contains for example a list of tweets.
Edit: Currently we are trying MJPEG. Does anyone know more about this and email clients?
Help much appreciated,
Vincent