Two Methods for displaying automatically generated images on the ASP. NET page
Source: Internet
Author: User
Method 1: Save the automatically generated image to a location on the site, then you can set the SCR of the image control to the image URL in page_load on the page (the code for this method references the http://www.cnblogs.com/ahuang1118/archive/2005/05/27/163614.html)
Method 2: Set the SCR of the image control in webform1 to another genpicture URL that automatically generates images. See demousing system;
Using system. collections;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. Web;
Using system. Web. sessionstate;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. htmlcontrols;
Using system. Drawing. drawing2d;
Namespace webpageindex
{
/** // <Summary>
/// Summary of genpicture.
/// </Summary>
Public class genpicture: system. Web. UI. Page
{
Private void page_load (Object sender, system. eventargs E)
{
// Place user code here to initialize the page
String STR = "xingzhong company financial seal ";
Bitmap image = new Bitmap (300,300 );
Graphics G = graphics. fromimage (image );
Pen P = new pen (brushes. Red, 10 );
Pen p1 = new pen (brushes. Red, 5 );
Solidbrush B = new solidbrush (color. Red );
G. smoothingmode = smoothingmode. antialias;
Point point1 = new point (150, 50 );
Point point2 = new point (50,150 );
Point point3 = new point (230,150 );
Point [] curvepoints = {point1, point2, point3 };
G. fillpolygon (B, curvepoints, fillmode. Winding );
G. drawellipse (p, 10, 280,280 );
G. drawstring (STR, new font ("", 20, fontstyle. Bold), new
Solidbrush (color. fromargb (255,255, 0, 0), 40,200 );
G. drawline (P1, 80,240,220,240 );
G. drawline (P1, 80,250,220,250 );
Image. Save (response. outputstream, system. Drawing. imaging. imageformat. GIF );
}
Code generated by web form designer # code generated by region web Form Designer
Override protected void oninit (eventargs E)
{
//
// Codegen: This call is required by the ASP. NET web form designer.
//
Initializecomponent ();
Base. oninit (E );
}
/** // <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
Private void initializecomponent ()
{
This. Load + = new system. eventhandler (this. page_load );
}
# Endregion
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service