Current location - Health Preservation Learning Network - Slimming men and women - Net to generate gif animation
Net to generate gif animation
For an article, please refer to:

Dynamically Generating gif Pictures in Web Pages (ASP.net)

As we all know, the K-line chart of stock websites is dynamically generated. When PHP is refreshed regularly, it has the function of dynamically generating pictures.

So how to use ASP.NET to dynamically generate pictures in web pages?

The example I want to give below is to dynamically generate a picture to show the current time.

Namespace Wmj

{

Use the system;

Use the system. Drawing;

Use the system. Web . UI

Public class MyTempImage: Page

{

Public string CreateImage ()

{

String str = date and time. now . ToString();

Bitmap image = new bitmap (200, 30);

Graph g = graph. FromImage;

string thefullname=Server。 MapPath("/"+" \ \ now time . gif ";

G. transparent (color. White);

G. pull rope (str, new font ("Courier New", 10), new SolidBrush (color. Red), 20, 5);

//Graphics class also has many drawing methods, which can draw straight lines, curves, circles and so on.

Image. Save(thefullname,System。 drawing . imaging . image format . gif);

return“/now time . gif”;

}

}

}

///////////////////////////////////////////

& lt% @ page language = " c# " & gt;

& lt% @ Import namespace = " Wmj " % & gt

& ltscript language = " c# " runat = " server " & gt;

Void Page_Load (object sender, event parameter e)

{

MyTempImage MyTempImage = new MyTempImage();

img 1。 Src=myTempImage。 create image();

}

& lt/script & gt;

& lthtml & gt

& lthead & gt

& lt! -automatically refresh every 10 second->

& ltmeta http-equiv = " refresh " content = " 10 " >

& lt/head & gt;

& ltbody & gt

& ltform runat = " server " & gt

& ltInput type="button" value= "manual refresh" onclick="location.reload () ">

& ltimg id = " img 1 " runat = " server "/& gt;

& lt/form & gt;

& lt/body & gt;

& lt/html & gt;